Пример #1
0
        public void TitleMatching_should_throw_ReceiptItemAssertionFailedException_when_regex_matches_no_items(string regex)
        {
            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Пример #2
0
        public void TitleMatching_should_throw_ReceiptItemAssertionFailedException_when_Title_of_all_items_is_null()
        {
            var items = Enumerable.Range(1, 5).Select(_ => new ReceiptItem()).ToList();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Пример #3
0
        public void TitleMatching_should_pass_if_regex_exactly_matches_Title_of_at_least_1_item_regardless_of_case(string itemTitle, string regex)
        {
            var items = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(title: itemTitle);

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldNotThrow <Exception>();
        }
Пример #4
0
        public void TitleMatching_should_pass_when_using_standard_regex_features(string itemTitle, string regex)
        {
            var items = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(title: itemTitle);

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldNotThrow <Exception>();
        }
Пример #5
0
        public void TitleMatching_should_pass_if_regex_exactly_matches_message_Title_of_one_item(string itemTitleAndRegex)
        {
            var items = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(title: itemTitleAndRegex);

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldNotThrow <Exception>();
        }
Пример #6
0
        public void TitleMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Пример #7
0
        public void TitleMatching_should_throw_ReceiptItemAssertionFailedException_when_trying_to_capture_groups_but_Title_of_all_items_is_null()
        {
            IList <string> matches;

            var items = Enumerable.Range(1, 5).Select(_ => new ReceiptItem()).ToList();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Пример #8
0
        public void TitleMatching_should_throw_ArgumentNullException_if_groupMatchRegex_is_null()
        {
            IList <string> matches;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Пример #9
0
        public void TitleMatching_should_not_output_matches_when_groupMatchingRegex_does_not_match_Title_of_any_item()
        {
            IList <string> matches;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            matches.Should().BeNull();
        }
Пример #10
0
        public void TitleMatching_should_not_output_matches_when_regex_does_not_match_Title_of_any_items()
        {
            IList <string> matches = null;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
            matches.Should().BeNull();
        }
Пример #11
0
        public void TitleMatching_should_output_matches_when_groupMatchingRegex_matches_Title_of_any_item()
        {
            IList <string> matches;

            const string someTitle = "some text";
            var          items     = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(title: someTitle);

            var sut = new ReceiptItemSetAssertions(items);

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

            matches.First().Should().Be(someTitle);
        }
Пример #12
0
        public void TitleMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Title_on_multiple_items()
        {
            IList <string> matches;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            items.Add(new ReceiptItem(title: "some text"));
            items.Add(new ReceiptItem(title: "same text"));

            var sut = new ReceiptItemSetAssertions(items);

            sut.TitleMatching(".*", @"(s[oa]me) (text)", out matches);

            matches.Should().Contain("some", "same", "text");
        }
Пример #13
0
        public void TitleMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Title_several_times_for_a_single_item()
        {
            IList <string> matches;

            const string someTitle = "some text";
            var          items     = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(title: someTitle);

            var sut = new ReceiptItemSetAssertions(items);

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

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

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