Ejemplo n.º 1
0
        public void ContainsShouldFailWhenFalse()
        {
            // arrange
            var assert   = new Asserter();
            var sequence = new List <object>()
            {
                new object(),
                new object(),
                new object(),
            };
            var element  = new object();
            var comparer = EqualityComparer <object> .Default;

            try
            {
                // act
                assert.Contains(sequence, element, comparer);
            }
            catch (AssertFailedException)
            {
                // assert
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }
Ejemplo n.º 2
0
        public void ContainsShouldPassWhenTrue()
        {
            // arrange
            var assert   = new Asserter();
            var sequence = new List <object>()
            {
                new object(),
                new object(),
                new object(),
            };
            var comparer = EqualityComparer <object> .Default;

            // act, assert
            assert.Contains(sequence, sequence.Last(), comparer);
        }
Ejemplo n.º 3
0
        public void ContainsShouldNotAllowNullComparer()
        {
            // arrange
            var assert   = new Asserter();
            var sequence = new object[0];
            var element  = new object();
            var comparer = default(IEqualityComparer <object>);

            try
            {
                // act
                assert.Contains(sequence, element, comparer);
            }
            catch (AssertFailedException ex)
            {
                // assert
                Assert.AreEqual(GetExpectedMessage(nameof(comparer)), ex.Message);
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }