Ejemplo n.º 1
0
        public void IsSubsetOf()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsSubsetOf(null, new int[0]));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsSubsetOf(new int[0], null));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsSubsetOf("abcd", "abc", null as IEqualityComparer <char>));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsSubsetOf(new int[0], new int[1]));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsSubsetOf(new int[1], new int[0]));
            Assert.ThrowsExact <ArgumentException>(() => Assert.IsSubsetOf(new int[1], new int[2]));
            Assert.DoesNotThrow(() => Assert.IsSubsetOf(new[] { 1 }, new[] { 1 }));

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