예제 #1
0
        public void QuantityMatching_should_throw_ReceiptItemAssertionFailedException_when_regex_matches_no_items(string regex)
        {
            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
예제 #2
0
        public void QuantityMatching_should_throw_ReceiptItemAssertionFailedException_when_Quantity_of_all_items_is_null()
        {
            var items = Enumerable.Range(1, 5).Select(_ => new ReceiptItem()).ToList();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
예제 #3
0
        public void QuantityMatching_should_pass_if_regex_exactly_matches_Quantity_of_at_least_1_item_regardless_of_case(string itemQuantity, string regex)
        {
            var items = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(quantity: itemQuantity);

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldNotThrow <Exception>();
        }
예제 #4
0
        public void QuantityMatching_should_pass_when_using_standard_regex_features(string itemQuantity, string regex)
        {
            var items = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(quantity: itemQuantity);

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldNotThrow <Exception>();
        }
예제 #5
0
        public void QuantityMatching_should_pass_if_regex_exactly_matches_message_Quantity_of_one_item(string itemQuantityAndRegex)
        {
            var items = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(quantity: itemQuantityAndRegex);

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldNotThrow <Exception>();
        }
예제 #6
0
        public void QuantityMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ArgumentNullException>();
        }
예제 #7
0
        public void QuantityMatching_should_throw_ReceiptItemAssertionFailedException_when_trying_to_capture_groups_but_Quantity_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.QuantityMatching(".*", "(.*)", out matches);

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
예제 #8
0
        public void QuantityMatching_should_throw_ArgumentNullException_if_groupMatchRegex_is_null()
        {
            IList <string> matches;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ArgumentNullException>();
        }
예제 #9
0
        public void QuantityMatching_should_not_output_matches_when_groupMatchingRegex_does_not_match_Quantity_of_any_item()
        {
            IList <string> matches;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            matches.Should().BeNull();
        }
예제 #10
0
        public void QuantityMatching_should_not_output_matches_when_regex_does_not_match_Quantity_of_any_items()
        {
            IList <string> matches = null;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

            var sut = new ReceiptItemSetAssertions(items);

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

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
            matches.Should().BeNull();
        }
예제 #11
0
        public void QuantityMatching_should_output_matches_when_groupMatchingRegex_matches_Quantity_of_any_item()
        {
            IList <string> matches;

            const string someQuantity = "some text";
            var          items        = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(quantity: someQuantity);

            var sut = new ReceiptItemSetAssertions(items);

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

            matches.First().Should().Be(someQuantity);
        }
예제 #12
0
        public void QuantityMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Quantity_on_multiple_items()
        {
            IList <string> matches;

            var items = ReceiptItemTestData.CreateRandomReceiptItems();

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

            var sut = new ReceiptItemSetAssertions(items);

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

            matches.Should().Contain("some", "same", "text");
        }
예제 #13
0
        public void QuantityMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Quantity_several_times_for_a_single_item()
        {
            IList <string> matches;

            const string someQuantity = "some text";
            var          items        = ReceiptItemTestData.CreateReceiptItemSetWithOneItemThatHasSetProperties(quantity: someQuantity);

            var sut = new ReceiptItemSetAssertions(items);

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

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

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