void GetLineAndColumn(string breakpointMarker, int offset, string statement, out int line, out int col) { int i = SourceFile.Text.IndexOf("/*" + breakpointMarker + "*/", StringComparison.Ordinal); if (i == -1) { Assert.Fail("Break marker not found: " + breakpointMarker + " in " + SourceFile.Name); } SourceFile.GetLineColumnFromPosition(i, out line, out col); line += offset; if (statement != null) { int lineStartPosition = SourceFile.GetPositionFromLineColumn(line, 1); string lineText = SourceFile.GetText(lineStartPosition, lineStartPosition + SourceFile.GetLineLength(line)); col = lineText.IndexOf(statement, StringComparison.Ordinal) + 1; if (col == 0) { Assert.Fail("Failed to find statement:" + statement + " at " + SourceFile.Name + "(" + line + ")"); } } else { col = 1; } }
public bool CheckPosition(string guid, int offset = 0, string statement = null, bool silent = false, ITextFile file = null) { file = file ?? SourceFile; if (!targetStoppedEvent.WaitOne(6000)) { if (!silent) { Assert.Fail("CheckPosition failure: Target stop timeout"); } return(false); } if (lastStoppedPosition.FileName == file.Name) { int i = file.Text.IndexOf("/*" + guid + "*/", StringComparison.Ordinal); if (i == -1) { if (!silent) { Assert.Fail("CheckPosition failure: Guid marker not found:" + guid + " in file:" + file.Name); } return(false); } int line, col; file.GetLineColumnFromPosition(i, out line, out col); if ((line + offset) != lastStoppedPosition.Line) { if (!silent) { Assert.Fail("CheckPosition failure: Wrong line Expected:" + (line + offset) + " Actual:" + lastStoppedPosition.Line + " in file:" + file.Name); } return(false); } if (!string.IsNullOrEmpty(statement)) { int position = file.GetPositionFromLineColumn(lastStoppedPosition.Line, lastStoppedPosition.Column); string actualStatement = file.GetText(position, position + statement.Length); if (statement != actualStatement) { if (!silent) { Assert.AreEqual(statement, actualStatement); } return(false); } } } else { if (!silent) { Assert.Fail("CheckPosition failure: Wrong file Excpected:" + file.Name + " Actual:" + lastStoppedPosition.FileName); } return(false); } return(true); }