string name = GetName(); // assume this method returns null Assert.IsNotNull(name); // this will throw an AssertionException with the message "String reference not set to an instance of a String."
ListAssertNotNull is part of the Microsoft.VisualStudio.TestTools.UnitTesting namespace and is included in the Microsoft.VisualStudio.TestPlatform.TestFramework NuGet package.numbers = new List (); numbers.Add(1); numbers.Add(2); Assert.IsNotNull(numbers); // this will pass because the list is not null