Beispiel #1
0
        public void CanCheckCollectionForNullValue()
        {
            var collection = new List <string> {
                "foo", "bar", null
            };

            Assert.Throws <CollectionContainsNullValueException>(() => Insist.HasNoNulls(collection));

            collection.Remove(null);

            Insist.HasNoNulls(collection);
        }
Beispiel #2
0
        public void CanCheckTypedCollectionForNullValue()
        {
            var dogs = new List <Dog>
            {
                new Dog {
                    Id = 1, Name = "Matilda", Type = "German Shepherd", Age = 9
                },
                new Dog {
                    Id = 2, Name = "Lancelot", Type = "German Shepherd", Age = 9
                },
                new Dog {
                    Id = 3, Name = "Zeus", Type = "Leonberger", Age = 4
                }
            };

            Insist.HasNoNulls(dogs, nameof(Dog.Age));

            dogs[2].Age = null;

            Assert.Throws <CollectionContainsNullValueException>(() => Insist.HasNoNulls(dogs, nameof(Dog.Age)));
        }