示例#1
0
        public void WithTitleMatching_should_pass_when_using_standard_regex_features(string itemTitle, string regex)
        {
            var receiptItem = new ReceiptItem(title: itemTitle);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.TitleMatching(regex);

            act.ShouldNotThrow <Exception>();
        }
示例#2
0
        public void WithTitleMatching_should_throw_ReceiptItemAssertionFailedException_for_non_matching_regexes(string itemTitle, string regex)
        {
            var receiptItem = new ReceiptItem(title: itemTitle);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.TitleMatching(regex);

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
示例#3
0
        public void WithTitleMatching_should_pass_if_regex_exactly_matches_message_Title(string itemTitleAndRegex)
        {
            var receiptItem = new ReceiptItem(title: itemTitleAndRegex);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.TitleMatching(itemTitleAndRegex);

            act.ShouldNotThrow <Exception>();
        }
示例#4
0
        public void WithTitleMatching_should_pass_regardless_of_case(string itemTitle, string regex)
        {
            var receiptItem = new ReceiptItem(title: itemTitle);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.TitleMatching(regex);

            act.ShouldNotThrow <Exception>();
        }
示例#5
0
        public void WithTitleMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

            Action act = () => sut.TitleMatching(null);

            act.ShouldThrow <ArgumentNullException>();
        }
示例#6
0
        public void WithTitleMatching_should_throw_ReceiptItemAssertionFailedException_when_title_is_null()
        {
            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

            Action act = () => sut.TitleMatching("anything");

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
示例#7
0
        public void WithTitleMatching_should_throw_ReceiptItemAssertionFailedException_when_trying_to_capture_groups_but_title_is_null()
        {
            IList <string> matches;
            var            item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

            Action act = () => sut.TitleMatching("anything", "(.*)", out matches);

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
示例#8
0
        public void WithTitleMatching_should_not_output_matches_when_groupMatchingRegex_does_not_match_title()
        {
            IList <string> matches;

            var receiptItem = new ReceiptItem(title: "some text");

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.TitleMatching("some text", "(non matching)", out matches);

            matches.Should().BeNull();
        }
示例#9
0
        public void WithTitleMatching_should_throw_ArgumentNullException_if_groupMatchRegex_is_null()
        {
            IList <string> matches;

            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

            Action act = () => sut.TitleMatching("(.*)", null, out matches);

            act.ShouldThrow <ArgumentNullException>();
        }
示例#10
0
        public void WithTitleMatching_should_output_matches_when_groupMatchingRegex_matches_title()
        {
            IList <string> matches;

            const string someTitle   = "some text";
            var          receiptItem = new ReceiptItem(title: someTitle);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.TitleMatching(someTitle, $"({someTitle})", out matches);

            matches.First().Should().Be(someTitle);
        }
示例#11
0
        public void WithTitleMatching_should_not_output_matches_when_regex_does_not_match_title()
        {
            IList <string> matches = null;

            var receiptItem = new ReceiptItem(title: "some text");

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.TitleMatching("non matching regex", "(some text)", out matches);

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
            matches.Should().BeNull();
        }
示例#12
0
        public void WithTitleMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_title_several_times()
        {
            IList <string> matches;

            const string someTitle   = "some text";
            var          receiptItem = new ReceiptItem(title: someTitle);

            var sut = new ReceiptItemAssertions(receiptItem);

            const string match1 = "some";
            const string match2 = "text";

            sut.TitleMatching(someTitle, $"({match1}) ({match2})", out matches);

            matches.Should().Contain(match1, match2);
        }