public void should_replace_variables_in_regex()
        {
            // Arrange
            var sessionVariables = new SessionVariables();
            sessionVariables.AddOrUpdateVariable("password", "tedx123");

            var matcher = new VerificationsMatcher(sessionVariables);

            var verifications = new List<VerificationItem>();
            verifications.Add(new VerificationItem("desc1", "({password})", VerifyType.Positive));

            string content = "<p>The password is tedx123</p>";

            // Act
            List<VerificationItem> results = matcher.MatchPositive(verifications, content);

            // Assert
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0].Success, Is.True);
            Assert.That(results[0].Description, Is.EqualTo("desc1"));
            Assert.That(results[0].Regex, Is.EqualTo("({password})"));
            Assert.That(results[0].TransformedRegex, Is.EqualTo("(tedx123)"));
        }
Ejemplo n.º 2
0
        public void ReplaceVariablesIn_should_replace_all_variables_and_escape_regex_characters_in_values()
        {
            // Arrange
            var sessionVariables = new SessionVariables();
            sessionVariables.AddOrUpdateVariable("nano", "$var leaf");
            sessionVariables.AddOrUpdateVariable("two", "(.*?) [a-z] ^perlmagic");

            string template = "{nano} {dummy} {two}";
            string expectedText = @"\$var\ leaf {dummy} \(\.\*\?\)\ \[a-z]\ \^perlmagic";

            // Act
            string actualText = sessionVariables.ReplaceVariablesIn(template);

            // Assert
            Assert.That(actualText, Is.EqualTo(expectedText));
        }
Ejemplo n.º 3
0
        public void AddOrUpdateVariable_should_set_variable()
        {
            // Arrange
            var sessionVariables = new SessionVariables();

            // Act
            sessionVariables.AddOrUpdateVariable("nano", "leaf");

            // Assert
            Assert.That(sessionVariables.GetVariableValue("nano"), Is.EqualTo("leaf"));
        }
Ejemplo n.º 4
0
        public void ReplacePlainTextVariablesIn_should_replace_all_variables()
        {
            // Arrange
            var sessionVariables = new SessionVariables();
            sessionVariables.AddOrUpdateVariable("nano", "leaf");
            sessionVariables.AddOrUpdateVariable("two", "ten");

            string template = "{nano} {dummy} {two}";
            string expectedText = "leaf {dummy} ten";

            // Act
            string actualText = sessionVariables.ReplacePlainTextVariablesIn(template);

            // Assert
            Assert.That(actualText, Is.EqualTo(expectedText));
        }