示例#1
0
        public void VatMatching_should_throw_ReceiptCardAssertionFailedException_when_regex_matches_no_cards(string regex)
        {
            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ReceiptCardAssertionFailedException>();
        }
示例#2
0
        public void VatMatching_should_throw_ReceiptCardAssertionFailedException_when_Vat_of_all_cards_is_null()
        {
            var cards = Enumerable.Range(1, 5).Select(_ => new ReceiptCard()).ToList();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ReceiptCardAssertionFailedException>();
        }
示例#3
0
        public void VatMatching_should_pass_if_regex_exactly_matches_Vat_of_at_least_1_card_regardless_of_case(string cardVat, string regex)
        {
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(vat: cardVat);

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldNotThrow <Exception>();
        }
示例#4
0
        public void VatMatching_should_pass_when_using_standard_regex_features(string cardVat, string regex)
        {
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(vat: cardVat);

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldNotThrow <Exception>();
        }
示例#5
0
        public void VatMatching_should_pass_if_regex_exactly_matches_message_Vat_of_one_card(string cardVatAndRegex)
        {
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(vat: cardVatAndRegex);

            var sut = new ReceiptCardSetAssertions(cards);

            Action act = () => sut.VatMatching(cardVatAndRegex);

            act.ShouldNotThrow <Exception>();
        }
示例#6
0
        public void VatMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

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

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

            var sut = new ReceiptCardSetAssertions(cards);

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

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

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

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

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            matches.Should().BeNull();
        }
示例#10
0
        public void VatMatching_should_not_output_matches_when_regex_does_not_match_Vat_of_any_cards()
        {
            IList <string> matches = null;

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ReceiptCardAssertionFailedException>();
            matches.Should().BeNull();
        }
示例#11
0
        public void VatMatching_should_output_matches_when_groupMatchingRegex_matches_Vat_of_any_card()
        {
            IList <string> matches;

            const string someVat = "some text";
            var          cards   = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(vat: someVat);

            var sut = new ReceiptCardSetAssertions(cards);

            sut.VatMatching(someVat, $"({someVat})", out matches);

            matches.First().Should().Be(someVat);
        }
示例#12
0
        public void VatMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Vat_on_multiple_cards()
        {
            IList <string> matches;

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            cards.Add(new ReceiptCard(vat: "some text"));
            cards.Add(new ReceiptCard(vat: "same text"));

            var sut = new ReceiptCardSetAssertions(cards);

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

            matches.Should().Contain("some", "same", "text");
        }
示例#13
0
        public void VatMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Vat_several_times_for_a_single_card()
        {
            IList <string> matches;

            const string someVat = "some text";
            var          cards   = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(vat: someVat);

            var sut = new ReceiptCardSetAssertions(cards);

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

            sut.VatMatching(someVat, $"({match1}) ({match2})", out matches);

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