Example #1
0
        public void WithFact_should_return_FactSetAssertions()
        {
            var facts       = FactTestData.CreateRandomFacts();
            var receiptCard = new ReceiptCard(facts: facts);

            var sut = new ReceiptCardAssertions(receiptCard);

            sut.WithFact().Should().BeAssignableTo <FactSetAssertions>().And.NotBeNull();
        }
Example #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();
        }
Example #3
0
        public void KeyMatching_should_throw_FactAssertionFailedException_when_regex_matches_no_cards(string regex)
        {
            var facts = FactTestData.CreateRandomFacts();

            var sut = new FactSetAssertions(facts);

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

            act.ShouldThrow <FactAssertionFailedException>();
        }
Example #4
0
        public void KeyMatching_should_pass_when_using_standard_regex_features(string key, string regex)
        {
            var facts = FactTestData.CreateFactSetWithOneFactThatHasSetProperties(key: key);

            var sut = new FactSetAssertions(facts);

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

            act.ShouldNotThrow <Exception>();
        }
Example #5
0
        public void KeyMatching_should_pass_if_regex_exactly_matches_Key_of_at_least_1_card_regardless_of_case(string key, string regex)
        {
            var facts = FactTestData.CreateFactSetWithOneFactThatHasSetProperties(key: key);

            var sut = new FactSetAssertions(facts);

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

            act.ShouldNotThrow <Exception>();
        }
Example #6
0
        public void KeyMatching_should_pass_if_regex_exactly_matches_message_Key_of_one_card(string keyAndRegex)
        {
            var facts = FactTestData.CreateFactSetWithOneFactThatHasSetProperties(key: keyAndRegex);

            var sut = new FactSetAssertions(facts);

            Action act = () => sut.KeyMatching(keyAndRegex);

            act.ShouldNotThrow <Exception>();
        }
Example #7
0
        public void KeyMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var facts = FactTestData.CreateRandomFacts();

            var sut = new FactSetAssertions(facts);

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

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

            var facts = FactTestData.CreateRandomFacts();

            var sut = new FactSetAssertions(facts);

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

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

            var facts = FactTestData.CreateRandomFacts();

            var sut = new FactSetAssertions(facts);

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

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

            var facts = FactTestData.CreateRandomFacts();

            var sut = new FactSetAssertions(facts);

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

            act.ShouldThrow <ArgumentNullException>();
        }
Example #11
0
        public void KeyMatching_should_not_output_matches_when_regex_does_not_match_Key_of_any_cards()
        {
            IList <string> matches = null;

            var facts = FactTestData.CreateRandomFacts();

            var sut = new FactSetAssertions(facts);

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

            act.ShouldThrow <FactAssertionFailedException>();
            matches.Should().BeNull();
        }
Example #12
0
        public void KeyMatching_should_output_matches_when_groupMatchingRegex_matches_Key_of_any_card()
        {
            IList <string> matches;

            const string someKey = "some text";
            var          facts   = FactTestData.CreateFactSetWithOneFactThatHasSetProperties(key: someKey);

            var sut = new FactSetAssertions(facts);

            sut.KeyMatching(someKey, $"({someKey})", out matches);

            matches.First().Should().Be(someKey);
        }
        public void Only_non_null_facts_from_list_of_Facts_should_be_available()
        {
            var nonNullFacts = FactTestData.CreateRandomFacts();
            var facts        = new List <Fact> {
                null
            };

            facts.AddRange(nonNullFacts);

            var assertions = new FactSetAssertions(facts);

            assertions.Facts.ShouldBeEquivalentTo(nonNullFacts);
        }
Example #14
0
        public void KeyMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Key_on_multiple_cards()
        {
            IList <string> matches;

            var facts = FactTestData.CreateRandomFacts();

            facts.Add(new Fact(key: "some text"));
            facts.Add(new Fact(key: "same text"));

            var sut = new FactSetAssertions(facts);

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

            matches.Should().Contain("some", "same", "text");
        }
Example #15
0
        public void KeyMatching_should_output_multiple_matches_when_groupMatchingRegex_matches_Key_several_times_for_a_single_card()
        {
            IList <string> matches;

            const string someKey = "some text";
            var          facts   = FactTestData.CreateFactSetWithOneFactThatHasSetProperties(key: someKey);

            var sut = new FactSetAssertions(facts);

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

            sut.KeyMatching(someKey, $"({match1}) ({match2})", out matches);

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