public List <TestClass> GetTests() { var classes = new List <TestClass>(); var results = new ScanResults(); foreach (var path in _filePaths) { var scanner = new FileScanner(_parser); results = scanner.ScanCode(File.ReadAllText(path), results, path); } var foundClasses = results.FoundClasses.Where( p => results.FoundPotentialTests.Any( e => string.Equals(p.Name, e.Name.Schema, StringComparison.OrdinalIgnoreCase))); var foundTests = results.FoundPotentialTests.Where( p => results.FoundPotentialTests.Any( s => string.Equals(s.Name.Schema, p.Name.Schema, StringComparison.OrdinalIgnoreCase))); return(classes); }
private ScanResults AppendResults(ScanResults results, string batch, string path, int offset, int lineOffset) { var reader = new StringReader(batch); IList <ParseError> errors; var fragment = _parser.Parse(reader, out errors); var visitor = new TestVisitor(path, offset, lineOffset); fragment.Accept(visitor); results.FoundProperties.AddRange(visitor.ExtendedProperties); results.FoundClasses.AddRange(visitor.Schemas); results.FoundPotentialTests.AddRange(visitor.Procedures); return(results); }
public virtual ScanResults ScanCode(string code, ScanResults results, string path) { var batches = code.Split(new[] { "\r\nGO\r\n", "\nGO\n" }, StringSplitOptions.None); var offset = 0; var lineOffset = 0; foreach (var batch in batches) { results = AppendResults(results, batch, path, offset, lineOffset); //this won't be exact, depending which split option is used we will be 4 or 6 chars off... :( offset += batch.Length; lineOffset = batch.Split('\n').Length; } return(results); }