2 * Copyright (C) 2013 FooProject
3 * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
13 using System.Collections.Generic;
16 using System.Threading.Tasks;
17 using Microsoft.VisualStudio.TestTools.UnitTesting;
23 public class UnitTest3
26 public void UpdateLineTest()
28 Document doc = new Document();
29 DummyRender render = new DummyRender();
30 DummyView view = new DummyView(doc,render);
32 doc.Append("a\nb\nc");
33 Assert.IsTrue(view.LayoutLines[0] == "a\n" && view.LayoutLines[1] == "b\n" && view.LayoutLines[2] == "c");
34 doc.Replace(0, 3, "x");
35 Assert.IsTrue(view.LayoutLines[0] == "x\n");
39 public void QueryTest()
41 Document doc = new Document();
42 DummyRender render = new DummyRender();
43 DummyView view = new DummyView(doc, render);
45 doc.Append("a\nb\nc");
46 Assert.IsTrue(view.LayoutLines.GetIndexFromLineNumber(1) == 2);
47 Assert.IsTrue(view.LayoutLines.GetLengthFromLineNumber(1) == 2);
48 Assert.IsTrue(view.LayoutLines.GetLineNumberFromIndex(2) == 1);
49 TextPoint tp = view.LayoutLines.GetTextPointFromIndex(2);
50 Assert.IsTrue(tp.row == 1 && tp.col == 0);
51 Assert.IsTrue(view.LayoutLines.GetIndexFromTextPoint(tp) == 2);