private void AssertMethodLine(int expectedStartLine, int expectedStartColumn, int expectedStartIndex, int expectedEndLine, int expectedEndColumn, int expectedEndIndex, IMethodLine actualLine) { Assert.AreEqual(expectedStartLine, actualLine.StartLine); Assert.AreEqual(expectedStartColumn, actualLine.StartColumn); Assert.AreEqual(expectedStartIndex, actualLine.StartIndex); Assert.AreEqual(expectedEndColumn, actualLine.EndColumn); Assert.AreEqual(expectedEndIndex, actualLine.EndIndex); }
public void GetSourceFileTest() { Assert.AreEqual(SourceFilePath, _methodMetadata1.GetSourceFilePath()); IEnumerable <IMethodLine> sourceLocations = _methodMetadata1.GetSourceLocations(); Assert.AreEqual(3, sourceLocations.Count()); IMethodLine methodLine = sourceLocations.First(); Assert.AreEqual(12, methodLine.StartLine); Assert.AreEqual(12, methodLine.EndLine); Assert.AreEqual(160, methodLine.StartIndex); Assert.AreEqual(220, methodLine.EndIndex); Assert.AreEqual(10, methodLine.StartColumn); Assert.AreEqual(70, methodLine.EndColumn); }
protected void FindConstructorBody(MethodMetadata method, out int startLine, out int endline) { IMethodLine openingBrace = method.GetSourceLocations().FirstOrDefault(sl => sl.EndIndex - sl.StartIndex == 1); IMethodLine closingBrace = method.GetSourceLocations().LastOrDefault(sl => sl.EndIndex - sl.StartIndex == 1); if (openingBrace != null && closingBrace != null) { startLine = openingBrace.StartLine; endline = closingBrace.EndLine; } else { startLine = method.GetSourceLocations().First().StartLine; endline = method.GetSourceLocations().Last().EndLine; } }