C# – Assert that a string is not null or empty with NUnit

If you want to Assert that a result string in a NUnit test is not null or empty, use:

Assert.That(string.IsNullOrEmpty(result), Is.False, "Result string must not be null or empty");

Leave a Reply

Your email address will not be published. Required fields are marked *

One comment

  1. Mark Hone says:

    Hi Roel,

    I believe you can also do the following (in NUnit 3 at least):
    Assert.That(result, Is.Not.Null.Or.Empty, “Result string must not be null or empty”);

    Further details: