Beispiel #1
0
        public void IterationSetup()
        {
            var patternBuilder = new StringBuilder(new Bogus.Randomizer().AlphaNumeric(StringLength));

            var random = new Random();

            var singleCharacterLocations = Enumerable.Range(0, SingleCharacterMatchCount)
                                           .Select(x => random.Next(SingleCharacterStart, SingleCharacterEnd))
                                           .ToList();

            singleCharacterLocations.ForEach(x => patternBuilder[x] = '?');

            var multiCharacterLocations = Enumerable.Range(0, MultiCharacterMatchCount)
                                          .Select(x => random.Next(MultiCharacterStart, MultiCharacterEnd))
                                          .ToList();

            multiCharacterLocations.ForEach(x => patternBuilder[x] = '*');

            _pattern = patternBuilder.ToString();

            _fastWildcardMatcher  = new FastWildcardMatcher();
            _regexMatcher         = new RegexMatcher(_pattern, RegexOptions.None);
            _regexMatcherCompiled = new RegexMatcher(_pattern, RegexOptions.Compiled);
#if !NETCOREAPP
            _wildcardMatchMatcher = new WildcardMatchMatcher();
#endif

            _str = new Bogus.Randomizer().AlphaNumeric(StringLength);
        }
Beispiel #2
0
        public void GlobalSetup()
        {
            (_pattern, _, _) = IterationBuilder.BuildPattern(PatternLength, SingleCharacterCount, MultiCharacterCount);

            _str = IterationBuilder.BuildTestString(_pattern);

            _fastWildcardMatcher = new FastWildcardMatcher();
#if !NETCOREAPP2_1
            _likeMatcher = new LikeMatcher();
#endif
#if NETCOREAPP
            _powerShellMatcher         = new PowerShellMatcher(_pattern, System.Management.Automation.WildcardOptions.None);
            _powerShellMatcherCompiled = new PowerShellMatcher(_pattern, System.Management.Automation.WildcardOptions.Compiled);
#endif
            _regexMatcher         = new RegexMatcher(_pattern, RegexOptions.None);
            _regexMatcherCompiled = new RegexMatcher(_pattern, RegexOptions.Compiled);
            _wildcardMatchMatcher = new WildcardMatchMatcher();
        }
Beispiel #3
0
        public void MultiCharacterWildcard_WithNoMatch_ReturnsFalse(string str, string pattern)
        {
            var regexMatcher = new RegexMatcher(pattern, RegexOptions.None);

#if !NETCOREAPP
            var wildcardMatchMatcher = new WildcardMatchMatcher();
#endif
            var fastWildcardMatcher = new FastWildcardMatcher();

            var regexMatcherResult = regexMatcher.Match(str);
#if !NETCOREAPP
            var wildcardMatchMatcherResult = wildcardMatchMatcher.Match(pattern, str);
#endif
            var fastWildcardMatcherResult = fastWildcardMatcher.Match(str, pattern);

            regexMatcherResult.Should().BeFalse();
#if !NETCOREAPP
            wildcardMatchMatcherResult.Should().BeFalse();
#endif
            fastWildcardMatcherResult.Should().BeFalse();
        }