public void IteratorReturnsCorrectLine() { var code = "\r\nF = 1;\r\nD = 2;\r\nX = 3;\r\n"; var iterator = new SourceCodeIterator(code); Assert.Equal(1, iterator.CurrentLine); Assert.Equal(-1, iterator.CurrentColumn); iterator.MoveToContent(); Assert.Equal(2, iterator.CurrentLine); Assert.Equal(1, iterator.CurrentColumn); Assert.Equal("F = 1;\r", iterator.GetCodeLine(2)); iterator.MoveNext(); Assert.Equal(2, iterator.CurrentColumn); iterator.MoveNext(); Assert.Equal(3, iterator.CurrentColumn); Assert.Equal('=', iterator.CurrentSymbol); while (iterator.CurrentSymbol != 'D' && iterator.MoveNext()) { ; } Assert.Equal(1, iterator.CurrentColumn); Assert.Equal(3, iterator.CurrentLine); }
public void Retrieve_Line_Of_Code() { string code = @"А = 1; Б = 2; // comment В = 7-11; Г = 8"; var iterator = new SourceCodeIterator(code); while (iterator.CurrentLine < 4) { if (!iterator.MoveNext()) { throw new Xunit.Sdk.XunitException("Code is less than 4 lines"); } } Assert.True(iterator.CurrentLine == 4); Assert.True(iterator.CurrentSymbol == '\n'); iterator.MoveNext(); Assert.True(iterator.GetCodeLine(4).Trim() == "В = 7-11;"); }