コード例 #1
0
        public void IsSubsetOfShouldFailWhenFalse()
        {
            // arrange
            var assert   = new Asserter();
            var superset = new List <object>()
            {
                new object(),
                new object(),
                new object(),
            };
            var subset = new List <object>()
            {
                superset[2],
                superset[0],
                new object(),
            };
            var comparer = EqualityComparer <object> .Default;

            try
            {
                // act
                assert.IsSubsetOf(subset, superset, comparer);
            }
            catch (AssertFailedException)
            {
                // assert
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }
コード例 #2
0
        public void IsSubsetOfShouldPassWhenTrue()
        {
            // arrange
            var assert   = new Asserter();
            var superset = new List <object>()
            {
                new object(),
                new object(),
                new object(),
            };
            var subset = new List <object>()
            {
                superset[2],
                superset[0],
            };
            var comparer = EqualityComparer <object> .Default;

            // act, assert
            assert.IsSubsetOf(subset, superset, comparer);
        }
コード例 #3
0
        public void IsSubsetOfShouldNotAllowNullComparer()
        {
            // arrange
            var assert   = new Asserter();
            var subset   = new object[0];
            var superset = new object[0];
            var comparer = default(IEqualityComparer <object>);

            try
            {
                // act
                assert.IsSubsetOf(subset, superset, comparer);
            }
            catch (AssertFailedException ex)
            {
                // assert
                Assert.AreEqual(GetExpectedMessage(nameof(comparer)), ex.Message);
                return;
            }

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