Ejemplo n.º 1
0
        public void WithReceiptItem_should_return_ReceiptItemSetAssertions()
        {
            var receiptItems = ReceiptItemTestData.CreateRandomReceiptItems();
            var cards        = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(items: receiptItems);

            var sut = new ReceiptCardSetAssertions(cards);

            sut.WithReceiptItem().Should().BeAssignableTo <ReceiptItemSetAssertions>().And.NotBeNull();
        }
Ejemplo n.º 2
0
        public void WithFact_should_return_FactSetAssertions()
        {
            var facts = FactTestData.CreateRandomFacts();
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithAllCardsWithSetProperties(facts: facts);

            var sut = new ReceiptCardSetAssertions(cards);

            sut.WithFact().Should().BeAssignableTo <FactSetAssertions>().And.NotBeNull();
        }
Ejemplo n.º 3
0
        public void WithTapAction_should_return_CardActionSetAssertions()
        {
            var tap   = new CardAction();
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(tap: tap);

            var sut = new ReceiptCardSetAssertions(cards);

            sut.WithTapAction().Should().BeAssignableTo <CardActionSetAssertions>().And.NotBeNull();
        }
Ejemplo n.º 4
0
        public void WithButtons_should_return_CardActionSetAssertions()
        {
            var buttons = CardActionTestData.CreateRandomCardActions();
            var cards   = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(buttons: buttons);

            var sut = new ReceiptCardSetAssertions(cards);

            sut.WithButtons().Should().BeAssignableTo <CardActionSetAssertions>().And.NotBeNull();
        }
Ejemplo n.º 5
0
        public void TotalMatching_should_throw_ReceiptCardAssertionFailedException_when_regex_matches_no_cards(string regex)
        {
            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ReceiptCardAssertionFailedException>();
        }
Ejemplo n.º 6
0
        public void TotalMatching_should_pass_when_using_standard_regex_features(string cardTotal, string regex)
        {
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(total: cardTotal);

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldNotThrow <Exception>();
        }
Ejemplo n.º 7
0
        public void TotalMatching_should_pass_if_regex_exactly_matches_Total_of_at_least_1_card_regardless_of_case(string cardTotal, string regex)
        {
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(total: cardTotal);

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldNotThrow <Exception>();
        }
Ejemplo n.º 8
0
        public void TotalMatching_should_pass_if_regex_exactly_matches_message_Total_of_one_card(string cardTotalAndRegex)
        {
            var cards = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(total: cardTotalAndRegex);

            var sut = new ReceiptCardSetAssertions(cards);

            Action act = () => sut.TotalMatching(cardTotalAndRegex);

            act.ShouldNotThrow <Exception>();
        }
Ejemplo n.º 9
0
        public void TotalMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Ejemplo n.º 10
0
        public void TotalMatching_should_throw_ArgumentNullException_if_groupMatchRegex_is_null()
        {
            IList <string> matches;

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Ejemplo n.º 11
0
        public void TotalMatching_should_not_output_matches_when_groupMatchingRegex_does_not_match_Total_of_any_card()
        {
            IList <string> matches;

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            matches.Should().BeNull();
        }
Ejemplo n.º 12
0
        public void TotalMatching_should_not_output_matches_when_regex_does_not_match_Total_of_any_cards()
        {
            IList <string> matches = null;

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

            var sut = new ReceiptCardSetAssertions(cards);

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

            act.ShouldThrow <ReceiptCardAssertionFailedException>();
            matches.Should().BeNull();
        }
Ejemplo n.º 13
0
        public void TotalMatching_should_output_matches_when_groupMatchingRegex_matches_Total_of_any_card()
        {
            IList <string> matches;

            const string someTotal = "some text";
            var          cards     = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(total: someTotal);

            var sut = new ReceiptCardSetAssertions(cards);

            sut.TotalMatching(someTotal, $"({someTotal})", out matches);

            matches.First().Should().Be(someTotal);
        }
Ejemplo n.º 14
0
        public void Extracted_receipt_cards_are_used_to_create_receipt_card_set_assertions()
        {
            var receiptCards = ReceiptCardTestData.CreateRandomReceiptCards();

            _extractor.ExtractCards <ReceiptCard>(Arg.Any <IEnumerable <Activity> >()).Returns(receiptCards);

            var sut = new ActivitySetAttachmentAssertions(ActivityTestData.CreateRandomActivities());

            var result = sut.OfTypeReceiptCard();

            result.Should().BeAssignableTo <ReceiptCardSetAssertions>();
            var assertions = (ReceiptCardSetAssertions)result;

            assertions.ReceiptCards.ShouldBeEquivalentTo(receiptCards);
        }
Ejemplo n.º 15
0
        public void TotalMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Total_on_multiple_cards()
        {
            IList <string> matches;

            var cards = ReceiptCardTestData.CreateRandomReceiptCards();

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

            var sut = new ReceiptCardSetAssertions(cards);

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

            matches.Should().Contain("some", "same", "text");
        }
Ejemplo n.º 16
0
        public void TotalMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Total_several_times_for_a_single_card()
        {
            IList <string> matches;

            const string someTotal = "some text";
            var          cards     = ReceiptCardTestData.CreateReceiptCardSetWithOneCardThatHasSetProperties(total: someTotal);

            var sut = new ReceiptCardSetAssertions(cards);

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

            sut.TotalMatching(someTotal, $"({match1}) ({match2})", out matches);

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