예제 #1
0
        public void MatchCount()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.MatchCount(null as Regex, string.Empty, 1));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.MatchCount(new Regex(string.Empty), null, 1));
            Assert.ThrowsExact <ArgumentException>(() => Assert.MatchCount(new Regex(string.Empty), string.Empty, -1));

            Assert.DoesNotThrow(() => Assert.MatchCount(new Regex("abc"), "abcabc", 2));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount(new Regex("abc"), "abcabc", 1));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount(new Regex("abc"), "abcabc", 3));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount(new Regex("abc"), "cba", 1));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount(new Regex("abc"), "cba", 2));
            Assert.DoesNotThrow(() => Assert.MatchCount(new Regex("abc"), "cba", 0));
            Assert.DoesNotThrow(() => Assert.MatchCount("abc", "abcabc", 2));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount("abc", "abcabc", 1));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount("abc", "abcabc", 3));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount("abc", "cba", 1));
            Assert.ThrowsExact <AssertionException>(() => Assert.MatchCount("abc", "cba", 2));
            Assert.DoesNotThrow(() => Assert.MatchCount("abc", "cba", 0));
        }