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>(); }
public void KeyMatching_should_throw_FactAssertionFailedException_when_Key_of_all_cards_is_null() { var facts = Enumerable.Range(1, 5).Select(_ => new Fact()).ToList(); var sut = new FactSetAssertions(facts); Action act = () => sut.KeyMatching(".*"); act.ShouldThrow <FactAssertionFailedException>(); }
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>(); }
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>(); }
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>(); }
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>(); }
public void KeyMatching_should_throw_FactAssertionFailedException_when_trying_to_capture_groups_but_Key_of_all_cards_is_null() { IList <string> matches; var facts = Enumerable.Range(1, 5).Select(_ => new Fact()).ToList(); var sut = new FactSetAssertions(facts); Action act = () => sut.KeyMatching(".*", "(.*)", out matches); act.ShouldThrow <FactAssertionFailedException>(); }
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>(); }
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(); }
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>(); }
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(); }
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); }
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"); }
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); }