コード例 #1
0
        public void ContainsOne_Predicate_CollectionEmpty_ThrowsException()
        {
            var collection = new List <string>();
            var ex         = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne(collection, s => s.IndexOf("e") == 0));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection is empty.", ex.Message);
        }
コード例 #2
0
        public void ContainsOne_OneElementMatches_MultipleElementsInList()
        {
            var collection = new List <string> {
                "expected", "notexpected", "also not expected"
            };

            EnumerableAssert.ContainsOne(collection, "expected");
        }
コード例 #3
0
        public void ContainsOne_Predicate_OneElementMatches_MultipleElementsInList()
        {
            var collection = new List <string> {
                "expected", "notexpected", "also not expected"
            };

            EnumerableAssert.ContainsOne(collection, s => s.IndexOf("e") == 0);
        }
コード例 #4
0
        public void ContainsOne_OneElementMatches_Size1()
        {
            var collection = new List <string> {
                "expected"
            };

            EnumerableAssert.ContainsOne(collection, "expected");
        }
コード例 #5
0
        public void ContainsOne_Predicate_OneElementMatches_Size1()
        {
            var collection = new List <string> {
                "expected"
            };

            EnumerableAssert.ContainsOne(collection, s => s.IndexOf("e") == 0);
        }
コード例 #6
0
        public void ContainsOne_Predicate_ExpectedItemNull_ThrowsException()
        {
            var collection = new List <string> {
                "element"
            };
            var ex = Assert.ThrowsException <ArgumentNullException>(() => EnumerableAssert.ContainsOne(collection, null as Func <string, bool>));

            Assert.AreEqual($"Value cannot be null.{Environment.NewLine}Parameter name: predicate", ex.Message);
        }
コード例 #7
0
        public void ContainsOne_MultipleElementsMatch_ThrowsException()
        {
            var collection = new List <string> {
                "expected", "notexpected", "expected"
            };
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne(collection, "expected"));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection contains the expected element more than once.", ex.Message);
        }
コード例 #8
0
        public void ContainsOne_NoElementMatches_ThrowsException()
        {
            var collection = new List <string> {
                "element"
            };
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne(collection, "expected"));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection does not contain the expected element.", ex.Message);
        }
コード例 #9
0
        public void ContainsOne_Predicate_MultipleElementsMatch_ThrowsException()
        {
            var collection = new List <string> {
                "expected", "notexpected", "expected as well"
            };
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne(collection, s => s.IndexOf("e") == 0));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection contains more than one element that matches the predicate.", ex.Message);
        }
コード例 #10
0
        public void ContainsOne_Predicate_NoElementMatches_ThrowsException()
        {
            var collection = new List <string> {
                "element"
            };
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne(collection, s => s.IndexOf("e") == 1));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection does not contain an element that matches the predicate.", ex.Message);
        }
コード例 #11
0
        public void ContainsOne_Predicate_CollectionNull_ThrowsException()
        {
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne <string>(null, s => s.IndexOf("e") == 0));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection is null.", ex.Message);
        }
コード例 #12
0
        public void ContainsOne_CollectionNull_ThrowsException()
        {
            var ex = Assert.ThrowsException <AssertFailedException>(() => EnumerableAssert.ContainsOne(null, "test"));

            Assert.AreEqual("EnumerableAssert.ContainsOne failed. Collection is null.", ex.Message);
        }