public void Or_AddComOrOrg_RegexIsAsExpecteds()
        {
            verbEx = VerbalExpressions.DefaultExpression;
            verbEx.Add("com").Or("org");

            Assert.AreEqual("(com)|(org)", verbEx.ToString());
        }
        public void StartOfLine_ThenHttpMaybeWww_DoesMatchHttpInStart()
        {
            verbEx = VerbalExpressions.DefaultExpression;
            verbEx.StartOfLine()
            .Then("http")
            .Maybe("www");

            var isMatch = Regex.IsMatch("http", verbEx.ToString());

            Assert.IsTrue(isMatch, "Should match http in start");
        }
        public void RepeatPrevious_WhenBetweenTwoAndFourA_RegesIsAsExpected()
        {
            // Arrange
            VerbalExpressions verbEx = VerbalExpressions.DefaultExpression;

            // Act
            verbEx.BeginCapture()
            .Add("A")
            .RepeatPrevious(2, 4)
            .EndCapture();

            // Assert
            Assert.AreEqual("(A{2,4})", verbEx.ToString());
        }
Пример #4
0
        public void RepeatPrevious_WhenThreeA_RegesIsAsExpected()
        {
            // Arrange
            VerbalExpressions verbEx = VerbalExpressions.DefaultExpression;

            // Act
            verbEx.BeginCapture()
            .Add("A")
            .RepeatPrevious(3)
            .EndCapture();

            // Assert
            Assert.Equal("(A{3})", verbEx.ToString());
        }
        public void BeginCaptureAndEndCapture_AddComOrOrg_RegexIsAsExpected()
        {
            // Arrange
            VerbalExpressions verbEx = VerbalExpressions.DefaultExpression;

            // Act
            verbEx.BeginCapture()
            .Add("com")
            .Or("org")
            .EndCapture();

            // Assert
            Assert.Equal("((com)|(org))", verbEx.ToString());
        }
        public void Range_WhenOddNumberOfItemsInArray_ShouldAppendWithPipe()
        {
            //Arrange
            verbEx = VerbalExpressions.DefaultExpression;
            object[] range = new object[3] {
                1, 6, 7
            };
            string expectedExpression = "[1-6]|7";

            //Act
            verbEx.Range(range);

            //Assert
            Assert.AreEqual(expectedExpression, verbEx.ToString());
        }
        public void Multiple_WhenParamIsGiven_ShouldMatchOneOrMultipleValuesGiven()
        {
            //Arrange
            verbEx = VerbalExpressions.DefaultExpression;
            string text = "testesting 123 yahoahoahou another test";
            string expectedExpression = "y(aho)+u";

            //Act
            verbEx.Add("y")
            .Multiple("aho")
            .Add("u");

            //Assert
            Assert.IsTrue(verbEx.Test(text));
            Assert.AreEqual(expectedExpression, verbEx.ToString());
        }
        public void BeginCaptureWithName_CreateRegexGroupNameAsExpected()
        {
            // Arrange
            VerbalExpressions verbEx = VerbalExpressions.DefaultExpression;

            // Act
            verbEx.Add("COD")
            .BeginCapture("GroupNumber")
            .Any("0-9")
            .RepeatPrevious(3)
            .EndCapture()
            .Add("END");

            // Assert
            Assert.Equal(@"COD(?<GroupNumber>[0-9]{3})END", verbEx.ToString());
            Assert.Equal("123", verbEx.Capture("COD123END", "GroupNumber"));
        }
        public void BeginCaptureAndEndCapture_DuplicatesIdentifier_DoesMatch()
        {
            // Arrange
            VerbalExpressions verbEx      = VerbalExpressions.DefaultExpression;
            const string      TEST_STRING = "He said that that was the the correct answer.";

            // Act
            verbEx.BeginCapture()
            .Word()
            .EndCapture()
            .Add(@"\s", false)
            .BeginCapture()
            .Add(@"\1", false)
            .EndCapture();

            // Assert
            Assert.Equal(@"(\w+)\s(\1)", verbEx.ToString());
            Assert.True(verbEx.Test(TEST_STRING), "There is no duplicates in the textString.");
        }
 public void StartOfLine_CreatesCorrectRegex()
 {
     verbEx.StartOfLine();
     Assert.AreEqual("^", verbEx.ToString(), "missing start of line regex");
 }
 public void StartOfLine_CreatesCorrectRegex()
 {
     verbEx = VerbalExpressions.DefaultExpression;
     verbEx.StartOfLine();
     Assert.AreEqual("^", verbEx.ToString(), "missing start of line regex");
 }
Пример #12
0
 public string ToStringImpl()
 {
     return(_verbalExpression.ToString());
 }