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

            Assert.DoesNotThrow(() => Assert.EndsWith("hello", "llo"));
            Assert.DoesNotThrow(() => Assert.EndsWith(new[] { 1, 2, 3, 4 }, new[] { 3, 4 }));
            Assert.ThrowsExact <AssertionException>(() => Assert.EndsWith("hello", "kko"));
            Assert.ThrowsExact <AssertionException>(() => Assert.EndsWith(new[] { 1, 2, 3, 4 }, new[] { 2, 3 }));
            Assert.DoesNotThrow(() => Assert.EndsWith("hello", "LLO", new CharCaseInvariantComparer()));
            Assert.ThrowsExact <AssertionException>(() => Assert.EndsWith("hello", "KKO", new CharCaseInvariantComparer()));
        }