public void matchvariables_should_not_concatenate_multiple_matches_into_variable_value()
        {
            // given
            var parseResponses = new List <CapturedVariable>()
            {
                new CapturedVariable("var1", @"(\d+)"),
            };
            string content = "<html>The number 3 and the number 4 combined make 7</html>";

            // when
            List <Variable> variables = CapturedVariableProvider.MatchVariables(parseResponses, content, new TestFileRunnerLogger());

            // then
            Assert.That(variables.ValueByName("var1"), Is.EqualTo("3"));
        }
        public void matchvariables_should_set_value_to_empty_string_when_regex_is_invalid()
        {
            // given
            var parseResponses = new List <CapturedVariable>()
            {
                new CapturedVariable("var1", @"(\d+)"),
                new CapturedVariable("var2", @"(() this is a bad regex?("),
            };
            string content = "<html>123 abc</html>";

            // when
            List <Variable> variables = CapturedVariableProvider.MatchVariables(parseResponses, content, new TestFileRunnerLoggerMock());

            // then
            Assert.That(variables.Count, Is.EqualTo(2));
            Assert.That(variables.ValueByName("var1"), Is.EqualTo("123"));
            Assert.That(variables.ValueByName("var2"), Is.EqualTo(""));
        }
        public void matchvariables_should_match_regex_groups_and_set_variable_names_and_values_to_matched_items()
        {
            // given
            var parseResponses = new List <CapturedVariable>()
            {
                new CapturedVariable("var1", @"(\d+)"),
                new CapturedVariable("varFoo", "(<html.+?>)")
            };
            string content = "<html class='bootstrap'><p>Tap tap tap 123</p></html>";

            // when
            List <Variable> variables = CapturedVariableProvider.MatchVariables(parseResponses, content, new TestFileRunnerLoggerMock());

            // then
            Assert.That(variables.Count, Is.EqualTo(2));
            Assert.That(variables.ValueByName("var1"), Is.EqualTo("123"));
            Assert.That(variables.ValueByName("varFoo"), Is.EqualTo("<html class='bootstrap'>"));
        }