コード例 #1
0
        public void IsStrictSubsetOf()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsStrictSubsetOf(null, new int[0]));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsStrictSubsetOf(new int[0], null));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsStrictSubsetOf("abcd", "abc", null as IEqualityComparer <char>));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsStrictSubsetOf(new int[0], new int[1]));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsStrictSubsetOf(new int[1], new int[0]));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsStrictSubsetOf(new int[1], new int[2]));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsStrictSubsetOf(new[] { 1 }, new[] { 1 }));

            Assert.DoesNotThrow(() => Assert.IsStrictSubsetOf("Musky", "usk"));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsStrictSubsetOf("Musky", "elk"));
            Assert.DoesNotThrow(() => Assert.IsStrictSubsetOf(new[] { 1, 2, 3, 4, 5 }, new[] { 1, 2, 3 }));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsStrictSubsetOf(new[] { 1, 2, 3, 4, 5 }, new[] { 1, 2, 3, 4, 5 }));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsStrictSubsetOf(new[] { 1, 2, 3, 4, 5 }, new[] { 1, 2, 3, 6 }));
            Assert.DoesNotThrow(() => Assert.IsStrictSubsetOf("Musky", "musk", new CharCaseInvariantComparer()));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsStrictSubsetOf("Musky", "abc", new CharCaseInvariantComparer()));
        }