Example #1
0
        public void WithCardImage_should_return_CardImageAssertions()
        {
            var cardImage   = new CardImage();
            var receiptItem = new ReceiptItem(image: cardImage);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.WithCardImage().Should().BeAssignableTo <CardImageAssertions>().And.NotBeNull();
        }
Example #2
0
        public void WithTapAction_should_return_CardActionAssertions()
        {
            var tap         = new CardAction();
            var receiptItem = new ReceiptItem(tap: tap);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.WithTapAction().Should().BeAssignableTo <CardActionAssertions>().And.NotBeNull();
        }
Example #3
0
        public void WithTextMatching_should_pass_regardless_of_case(string itemText, string regex)
        {
            var receiptItem = new ReceiptItem(text: itemText);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldNotThrow <Exception>();
        }
Example #4
0
        public void WithTextMatching_should_pass_if_regex_exactly_matches_message_Text(string itemTextAndRegex)
        {
            var receiptItem = new ReceiptItem(text: itemTextAndRegex);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.TextMatching(itemTextAndRegex);

            act.ShouldNotThrow <Exception>();
        }
Example #5
0
        public void WithPriceMatching_should_pass_when_using_standard_regex_features(string itemPrice, string regex)
        {
            var receiptItem = new ReceiptItem(price: itemPrice);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldNotThrow <Exception>();
        }
Example #6
0
        public void WithQuantityMatching_should_throw_ReceiptItemAssertionFailedException_for_non_matching_regexes(string itemQuantity, string regex)
        {
            var receiptItem = new ReceiptItem(quantity: itemQuantity);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Example #7
0
        public void WithPriceMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Example #8
0
        public void WithPriceMatching_should_pass_regardless_of_case(string itemPrice, string regex)
        {
            var receiptItem = new ReceiptItem(price: itemPrice);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldNotThrow <Exception>();
        }
Example #9
0
        public void WithPriceMatching_should_pass_if_regex_exactly_matches_message_Price(string itemPriceAndRegex)
        {
            var receiptItem = new ReceiptItem(price: itemPriceAndRegex);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.PriceMatching(itemPriceAndRegex);

            act.ShouldNotThrow <Exception>();
        }
Example #10
0
        public void WithPriceMatching_should_throw_ReceiptItemAssertionFailedException_when_price_is_null()
        {
            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Example #11
0
        public void WithPriceMatching_should_throw_ReceiptItemAssertionFailedException_for_non_matching_regexes(string itemPrice, string regex)
        {
            var receiptItem = new ReceiptItem(price: itemPrice);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Example #12
0
        public void WithQuantityMatching_should_pass_when_using_standard_regex_features(string itemQuantity, string regex)
        {
            var receiptItem = new ReceiptItem(quantity: itemQuantity);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldNotThrow <Exception>();
        }
Example #13
0
        public void WithQuantityMatching_should_pass_regardless_of_case(string itemQuantity, string regex)
        {
            var receiptItem = new ReceiptItem(quantity: itemQuantity);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldNotThrow <Exception>();
        }
Example #14
0
        public void WithQuantityMatching_should_pass_if_regex_exactly_matches_message_Quantity(string itemQuantityAndRegex)
        {
            var receiptItem = new ReceiptItem(quantity: itemQuantityAndRegex);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.QuantityMatching(itemQuantityAndRegex);

            act.ShouldNotThrow <Exception>();
        }
Example #15
0
        public void WithPriceMatching_should_throw_ReceiptItemAssertionFailedException_when_trying_to_capture_groups_but_price_is_null()
        {
            IList <string> matches;
            var            item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Example #16
0
        public void WithPriceMatching_should_throw_ArgumentNullException_if_groupMatchRegex_is_null()
        {
            IList <string> matches;

            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Example #17
0
        public void WithPriceMatching_should_not_output_matches_when_groupMatchingRegex_does_not_match_price()
        {
            IList <string> matches;

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

            var sut = new ReceiptItemAssertions(receiptItem);

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

            matches.Should().BeNull();
        }
Example #18
0
        public void WithQuantityMatching_should_throw_ArgumentNullException_if_when_capturing_groups_regex_is_null()
        {
            IList <string> matches;

            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Example #19
0
        public void WithTextMatching_should_output_matches_when_groupMatchingRegex_matches_text()
        {
            IList <string> matches;

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

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.TextMatching(someText, $"({someText})", out matches);

            matches.First().Should().Be(someText);
        }
Example #20
0
        public void WithPriceMatching_should_not_output_matches_when_regex_does_not_match_price()
        {
            IList <string> matches = null;

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

            var sut = new ReceiptItemAssertions(receiptItem);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
            matches.Should().BeNull();
        }
Example #21
0
        public void WithQuantityMatching_should_output_matches_when_groupMatchingRegex_matches_quantity()
        {
            IList <string> matches;

            const string someQuantity = "some text";
            var          receiptItem  = new ReceiptItem(quantity: someQuantity);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.QuantityMatching(someQuantity, $"({someQuantity})", out matches);

            matches.First().Should().Be(someQuantity);
        }
Example #22
0
        public void WithPriceMatching_should_output_matches_when_groupMatchingRegex_matches_price()
        {
            IList <string> matches;

            const string somePrice   = "some text";
            var          receiptItem = new ReceiptItem(price: somePrice);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.PriceMatching(somePrice, $"({somePrice})", out matches);

            matches.First().Should().Be(somePrice);
        }
Example #23
0
        public void WithPriceMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_price_several_times()
        {
            IList <string> matches;

            const string somePrice   = "some text";
            var          receiptItem = new ReceiptItem(price: somePrice);

            var sut = new ReceiptItemAssertions(receiptItem);

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

            sut.PriceMatching(somePrice, $"({match1}) ({match2})", out matches);

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