I'm probably missing something about CollectionAssert.AllItemsAreNotNull
Verifies that all items in the specified collection are not null. The assertion fails if any element is null.
var foo = new List<string>();
//Passes - why?
CollectionAssert.AllItemsAreNotNull(foo);
//Sanity check
var isnull = foo.FirstOrDefault();
//Yes indeed the first item in the collection is null
Assert.IsTrue(isnull == null, "isnull is not null");
//Now I'm getting what I expected (fail)
Assert.IsTrue(foo.Any(), "foo has no items");
Welp...thnx!
Update
Thanks to all for the clarifications/explanations - completely makes sense. I had a different/opinionated/wrong interpretation (aka "NullOrEmpty").
For those who want to dig a bit more, this reference should fully clarify:
public static void AllItemsAreNotNull(ICollection collection, string message, params object[] parameters)
{
Assert.CheckParameterNotNull(collection, "CollectionAssert.AllItemsAreNotNull", "collection", string.Empty);
foreach (object current in collection)
{
if (current == null)
{
Assert.HandleFail("CollectionAssert.AllItemsAreNotNull", message, parameters);
}
}
}
Hth and thnx again!