public void AnyWithNullCheckTest1() { //create a new null list that we will use to check List<int> ListToTestWith = null; //check the null list Assert.False(ListToTestWith.AnyWithNullCheck()); //create a new list ListToTestWith = new List<int>(); //check if the object instance has any items Assert.False(ListToTestWith.AnyWithNullCheck()); //add an item to the list ListToTestWith.Add(1); //do we see the 1 number Assert.True(ListToTestWith.AnyWithNullCheck()); //add another item ListToTestWith.Add(2); //should see the 2 items Assert.True(ListToTestWith.AnyWithNullCheck()); //clear all the items ListToTestWith.Clear(); //should resolve to false Assert.False(ListToTestWith.AnyWithNullCheck()); }
public void AnyWithNullCheckPredicateTest1() { //create a new null list that we will use to check List<int> ListToTestWith = null; //should return false since we don't have an instance of an object Assert.False(ListToTestWith.AnyWithNullCheck(x => x == 5)); //create an instance of the list now ListToTestWith = new List<int>(); //we still don't have any items in the list Assert.False(ListToTestWith.AnyWithNullCheck(x => x == 5)); //add an item now ListToTestWith.Add(1); //we should be able to find the == 1 Assert.True(ListToTestWith.AnyWithNullCheck(x => x == 1)); //we don't have anything greater then 5 Assert.False(ListToTestWith.AnyWithNullCheck(x => x > 5)); //add 2 ListToTestWith.Add(2); //should be able to find the 2 Assert.True(ListToTestWith.AnyWithNullCheck(x => x == 2)); //shouldn't be able to find any numbers greater then 5 Assert.False(ListToTestWith.AnyWithNullCheck(x => x > 5)); //clear the list ListToTestWith.Clear(); //we have no items because we just cleared the list Assert.False(ListToTestWith.AnyWithNullCheck(x => x <= 5)); }