Exemplo n.º 1
0
        protected void InitialiseGlobTestData(string GlobPattern, int numberOfMatchingStrings, int numberOfNonMatchingStrings)
        {
            if (!_testDataSet.ContainsKey(GlobPattern))
            {
                // generate test data.
                var tokens    = new GlobTokeniser().Tokenise(GlobPattern);
                var generator = new GlobMatchStringGenerator(tokens);

                int total    = numberOfMatchingStrings + numberOfNonMatchingStrings;
                var testData = new List <string>(total);

                for (int i = 0; i < numberOfMatchingStrings; i++)
                {
                    testData.Add(generator.GenerateRandomNonMatch());
                }

                for (int i = 0; i < numberOfNonMatchingStrings; i++)
                {
                    testData.Add(generator.GenerateRandomNonMatch());
                }

                _testDataSet.Add(GlobPattern, testData);
            }

            TestStrings = _testDataSet[GlobPattern];
        }
Exemplo n.º 2
0
        public void Can_Generate_Non_Matches(string pattern, int volume)
        {
            var glob = Glob.Parse(pattern);
            var sut  = new GlobMatchStringGenerator(glob.Tokens);

            for (int i = 0; i < volume; i++)
            {
                var generatedString = sut.GenerateRandomNonMatch();
                var result          = glob.IsMatch(generatedString);
                Assert.False(result, string.Format("{0} matched pattern {1}", generatedString, pattern));
            }
        }
Exemplo n.º 3
0
        public void SetupData()
        {
            _testMatchingStringsList    = new List <string>(NumberOfMatches);
            _testNonMatchingStringsList = new List <string>(NumberOfMatches);
            _glob = Globbing.Glob.Parse(GlobPattern);
            var generator = new GlobMatchStringGenerator(_glob.Tokens);

            for (int i = 0; i < 10000; i++)
            {
                _testMatchingStringsList.Add(generator.GenerateRandomMatch());
                _testNonMatchingStringsList.Add(generator.GenerateRandomNonMatch());
            }
        }
Exemplo n.º 4
0
        public void Can_Generate_Matches(string pattern, int volume)
        {
            //  var generatedStrings = new List<string>(testStrings);
            var glob = Glob.Parse(pattern);
            var sut  = new GlobMatchStringGenerator(glob.Tokens);

            for (int i = 0; i < volume; i++)
            {
                var generatedString = sut.GenerateRandomMatch();
                var result          = glob.IsMatch(generatedString);
                Assert.True(result, string.Format("{0} did not match pattern {1}", generatedString, pattern));
            }
        }