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]; }
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)); } }
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()); } }