private static Tuple <int, string[], string[]> GetTestData(ICSharpFile cSharpFile) { string code = cSharpFile.GetText(); var match = patternCountRegex.Match(code); if (!match.Success) { Assert.Fail("Unable to find number of patterns. Make sure the '// Patterns:' comment is correct"); } int count = Convert.ToInt32(match.Groups["patterns"].Value); if (count == 0) { return(Tuple.Create(0, EmptyArray <string> .Instance, EmptyArray <string> .Instance)); } match = matchesRegex.Match(code); if (!match.Success) { Assert.Fail("Unable to find matched files. Make sure the '// Matched:' comment is correct"); } string[] matches = match.Groups["files"].Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); match = notMatchesRegex.Match(code); if (!match.Success) { Assert.Fail("Unable to find not-matched files. Make sure the '// NotMatched:' comment is correct"); } string[] notMatches = match.Groups["files"].Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); return(Tuple.Create(count, matches, notMatches)); }
protected void RunTest(string testName, Action <ILambdaExpression> action) { string fileName = testName + Extension; WithSingleProject(fileName, (lifetime, project) => RunGuarded(() => { ICSharpFile file = GetCodeFile(fileName); if (file == null || string.IsNullOrWhiteSpace(file.GetText())) { Assert.Fail("The file '{0}' was not found or was empty.", fileName); } file.ProcessChildren(action); })); }