コード例 #1
0
        public void WithAnyCase_SetsCorrectIgnoreCaseRegexOptionAndHasMultiLineRegexOptionAsDefault()
        {
            verbEx.WithAnyCase();

            var regex = verbEx.ToRegex();

            Assert.IsTrue(regex.Options.HasFlag(RegexOptions.IgnoreCase), "RegexOptions should have ignoreCase");
            Assert.IsTrue(regex.Options.HasFlag(RegexOptions.Multiline), "RegexOptions should have MultiLine as default");
        }
コード例 #2
0
        public void RemoveModifier_RemoveModifierM_RemovesMulitilineAsDefault()
        {
            verbEx = VerbalExpressions.DefaultExpression;
            var regex = verbEx.ToRegex();

            Assert.IsTrue(regex.Options.HasFlag(RegexOptions.Multiline), "RegexOptions should have MultiLine as default");

            verbEx.RemoveModifier('m');
            regex = verbEx.ToRegex();

            Assert.IsFalse(regex.Options.HasFlag(RegexOptions.Multiline), "RegexOptions should now have been removed");
        }
コード例 #3
0
        public void UseOneLineSearchOption_WhenCalled_ShouldChangeMultilineModifier()
        {
            //Arrange
            verbEx.UseOneLineSearchOption(false);
            var regex = verbEx.ToRegex();

            Assert.IsTrue(regex.Options.HasFlag(RegexOptions.Multiline), "RegexOptions should now be present");
            //Act
            verbEx.UseOneLineSearchOption(true);
            //Assert
            regex = verbEx.ToRegex();
            Assert.IsFalse(regex.Options.HasFlag(RegexOptions.Multiline), "RegexOptions should now have been removed");
        }
コード例 #4
0
        public void Word_WhenCalled_ReturnsExpectedNumberOfWords()
        {
            //Arrange
            verbEx = VerbalExpressions.DefaultExpression;
            string text          = "three words here";
            int    expectedCount = 3;

            //Act
            verbEx.Word();
            Regex currentExpression = verbEx.ToRegex();
            int   result            = currentExpression.Matches(text).Count;

            //Assert
            Assert.AreEqual(expectedCount, result);
        }
コード例 #5
0
        RegexTest()
        {
            // PM> Install-Package VerbalExpressions-official

            // http[s]://www.domain.com

            VerbalExpressions expression = new VerbalExpressions()
                                           .StartOfLine()
                                           .Then("http")
                                           .Maybe("s")
                                           .AnythingBut(" ")
                                           .EndOfLine();

            Regex regex = expression.ToRegex();

            string url = "http://www.vavatech.pl:8080";

            bool isValid = expression.Test(url);
        }