public void GetOptions_returnsAllRegexOptionsOfDotNet()
        {
            RegexParsingOptions translated = controller.GetOptions();

            //there are actually 10 but one is just a multiple bit flag (RegexOptions.None)
            Assert.AreEqual(9, translated.Count, "all 9 regex options should be accounted for in the get options of a dotnet regex");
        }
        private void setup_setParsingOptionOnController(string optionName, bool selected)
        {
            RegexParsingOptions options = controller.GetOptions();

            options.GetByName(optionName).Selected = selected;
            controller.SetOptions(options);
        }
        private void verifyValidExpressionOptionIsSelected(RegexOptions option)
        {
            controller.DotNetRegexOptions = option;
            RegexParsingOptions translated = controller.GetOptions();

            Assert.AreEqual(1, getSelectedOptionCount(translated), "one regex option [{0}] should have been selected", option);
        }
Beispiel #4
0
 public override void SetOptions(RegexParsingOptions options)
 {
     setParsingOption(options, RegexOptions.IgnorePatternWhitespace);
     setParsingOption(options, RegexOptions.Compiled);
     setParsingOption(options, RegexOptions.CultureInvariant);
     setParsingOption(options, RegexOptions.ECMAScript);
     setParsingOption(options, RegexOptions.ExplicitCapture);
     setParsingOption(options, RegexOptions.IgnoreCase);
     setParsingOption(options, RegexOptions.Multiline);
     setParsingOption(options, RegexOptions.RightToLeft);
     setParsingOption(options, RegexOptions.Singleline);
 }
        private int getSelectedOptionCount(RegexParsingOptions options)
        {
            int selectedCount = 0;

            foreach (ExpressionOption option in options)
            {
                if (option.Selected)
                {
                    selectedCount++;
                }
            }
            return(selectedCount);
        }
        public override RegexParsingOptions GetOptions()
        {
            RegexParsingOptions options = new RegexParsingOptions();
            ExpressionOption[] flags = new ExpressionOption[]
            {
                new ExpressionOption(getOptionFlag(RegexOptions.Compiled)			,"Compiled"),
                new ExpressionOption(getOptionFlag(RegexOptions.CultureInvariant)	,"CultureInvariant"),
                new ExpressionOption(getOptionFlag(RegexOptions.ExplicitCapture)	,"ExplicitCapture"),
                new ExpressionOption(getOptionFlag(RegexOptions.ECMAScript)			,"ECMAScript"),
                new ExpressionOption(getOptionFlag(RegexOptions.IgnoreCase)			,"IgnoreCase"),
                new ExpressionOption(getOptionFlag(RegexOptions.IgnorePatternWhitespace)	,"IgnorePatternWhitespace"),
                new ExpressionOption(getOptionFlag(RegexOptions.Multiline)			,"Multiline"),
                new ExpressionOption(getOptionFlag(RegexOptions.RightToLeft)		,"RightToLeft"),
                new ExpressionOption(getOptionFlag(RegexOptions.Singleline)			,"Singleline")
            };

            options.AddRange(flags);
            return options;
        }
Beispiel #7
0
        public override RegexParsingOptions GetOptions()
        {
            RegexParsingOptions options = new RegexParsingOptions();

            ExpressionOption[] flags = new ExpressionOption[]
            {
                new ExpressionOption(getOptionFlag(RegexOptions.Compiled), "Compiled"),
                new ExpressionOption(getOptionFlag(RegexOptions.CultureInvariant), "CultureInvariant"),
                new ExpressionOption(getOptionFlag(RegexOptions.ExplicitCapture), "ExplicitCapture"),
                new ExpressionOption(getOptionFlag(RegexOptions.ECMAScript), "ECMAScript"),
                new ExpressionOption(getOptionFlag(RegexOptions.IgnoreCase), "IgnoreCase"),
                new ExpressionOption(getOptionFlag(RegexOptions.IgnorePatternWhitespace), "IgnorePatternWhitespace"),
                new ExpressionOption(getOptionFlag(RegexOptions.Multiline), "Multiline"),
                new ExpressionOption(getOptionFlag(RegexOptions.RightToLeft), "RightToLeft"),
                new ExpressionOption(getOptionFlag(RegexOptions.Singleline), "Singleline")
            };

            options.AddRange(flags);
            return(options);
        }
Beispiel #8
0
        private void setParsingOption(RegexParsingOptions options, RegexOptions flagToSet)
        {
            string           parsingOptionName = Enum.GetName(typeof(RegexOptions), flagToSet);
            ExpressionOption option            = options.GetByName(parsingOptionName);
            bool             shouldBeSelected  = option.Selected;
            bool             isSelected        = getOptionFlag(flagToSet);

            //for readability
            bool shouldNotBeSelected = !shouldBeSelected;
            bool isNotSelected       = !isSelected;


            if (shouldBeSelected && isNotSelected)
            {
                DotNetRegexOptions |= flagToSet;
                return;
            }

            if (shouldNotBeSelected && isSelected)
            {
                DotNetRegexOptions ^= flagToSet;
            }
        }
Beispiel #9
0
 public abstract void SetOptions(RegexParsingOptions options);
 public override void SetOptions(RegexParsingOptions options)
 {
     setParsingOption(options, RegexOptions.IgnorePatternWhitespace);
     setParsingOption(options, RegexOptions.Compiled);
     setParsingOption(options, RegexOptions.CultureInvariant);
     setParsingOption(options, RegexOptions.ECMAScript);
     setParsingOption(options, RegexOptions.ExplicitCapture);
     setParsingOption(options, RegexOptions.IgnoreCase);
     setParsingOption(options, RegexOptions.Multiline);
     setParsingOption(options, RegexOptions.RightToLeft);
     setParsingOption(options, RegexOptions.Singleline);
 }
        private void setParsingOption(RegexParsingOptions options,RegexOptions flagToSet)
        {
            string parsingOptionName = Enum.GetName(typeof(RegexOptions), flagToSet);
            ExpressionOption option = options.GetByName(parsingOptionName);
            bool shouldBeSelected = option.Selected;
            bool isSelected = getOptionFlag(flagToSet);

            //for readability
            bool shouldNotBeSelected = !shouldBeSelected;
            bool isNotSelected = !isSelected;

            if(shouldBeSelected && isNotSelected)
            {
                DotNetRegexOptions |= flagToSet;
                return;
            }

            if(shouldNotBeSelected && isSelected)
            {
                DotNetRegexOptions ^= flagToSet;
            }
        }
 private int getSelectedOptionCount(RegexParsingOptions options)
 {
     int selectedCount = 0;
     foreach (ExpressionOption option in options)
     {
         if (option.Selected)
             selectedCount++;
     }
     return selectedCount;
 }
        public void GetOptions_ZeroExpressionOptionsAreSetByDefault()
        {
            RegexParsingOptions translated = controller.GetOptions();

            Assert.AreEqual(0, getSelectedOptionCount(translated), "no regex option shoudl have been selected");
        }
 public abstract void SetOptions(RegexParsingOptions options);