public void Construction(string content, int[] expectedStarts, int[] expectedLengths, int[] expectedLineBreakLengths) { var b = new EditorBuffer(content, "R"); var s = new EditorBufferSnapshot(b, content, 2); s.Version.Should().Be(2); s.GetText().Should().Be(content); s.LineCount.Should().Be(expectedStarts.Length); for (var i = 0; i < s.LineCount; i++) { var lineFromNumber = s.GetLineFromLineNumber(i); lineFromNumber.LineNumber.Should().Be(i); var lineStart = expectedStarts[i]; var lineEnd = expectedStarts[i] + expectedLengths[i]; lineFromNumber.Start.Should().Be(lineStart); lineFromNumber.End.Should().Be(lineEnd); lineFromNumber.Length.Should().Be(lineEnd - lineStart); lineFromNumber.LineBreak.Length.Should().Be(expectedLineBreakLengths[i]); for (var j = lineStart; j < lineEnd; j++) { var lineFromPosition = s.GetLineFromPosition(j); lineFromPosition.Should().Be(lineFromNumber); } } }
public void InvalidLines(string content, int position) { var b = new EditorBuffer(content, "R"); var s = new EditorBufferSnapshot(b, content, 1); Action a = () => s.GetLineFromPosition(position); a.ShouldThrow <ArgumentOutOfRangeException>(); }
public void Lines(string content, int position, int expectedLineNumber, int expectedCharIndex) { var b = new EditorBuffer(content, "R"); var s = new EditorBufferSnapshot(b, content, 2); var line = s.GetLineFromPosition(position); line.LineNumber.Should().Be(expectedLineNumber); (position - line.Start).Should().Be(expectedCharIndex); }