public void Ntm_Add_TwoModels() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello"), CreateNode("world", "fnord"), } }; var spans = ntm.GetLineSpans(2); Assert.AreEqual(2, spans.Length); spans = ntm.GetLineSpans(1); Assert.AreEqual("fnord", spans[0].TextSpans[0].GetText()); }
public void Ntm_Add() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello", "world", "fnord"), } }; var spans = ntm.GetLineSpans(4); Assert.AreEqual(3, spans.Length); var delta = ntm.MoveToLine(ntm.CurrentPosition, 1); Assert.AreEqual(0, delta, "Should have been at the end"); }
public void Ntm_MoveAcrossBoundary() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello"), CreateNode("world", "control", "fnord"), } }; int delta = ntm.MoveToLine(ntm.CurrentPosition, 2); Assert.AreEqual(2, delta); var spans = ntm.GetLineSpans(1); Assert.AreEqual("control", spans[0].TextSpans[0].GetText()); }
public void Ntm_GetLineSpans() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello", "buy"), CreateNode("world", "control","fnord"), } }; ntm.MoveToLine(ntm.StartPosition, 1); var spans = ntm.GetLineSpans(5); Assert.AreEqual(4, spans.Length); Assert.AreEqual("buy", spans[0].TextSpans[0].GetText()); Assert.AreEqual("world", spans[1].TextSpans[0].GetText()); Assert.AreEqual("control", spans[2].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[3].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 0); spans = ntm.GetLineSpans(5); Assert.AreEqual(5, spans.Length); Assert.AreEqual("hello", spans[0].TextSpans[0].GetText()); Assert.AreEqual("buy", spans[1].TextSpans[0].GetText()); Assert.AreEqual("world", spans[2].TextSpans[0].GetText()); Assert.AreEqual("control", spans[3].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[4].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 3); spans = ntm.GetLineSpans(5); Assert.AreEqual(2, spans.Length); Assert.AreEqual("control", spans[0].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[1].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 2); spans = ntm.GetLineSpans(5); Assert.AreEqual(3, spans.Length); Assert.AreEqual("world", spans[0].TextSpans[0].GetText()); Assert.AreEqual("control", spans[1].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[2].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 4); spans = ntm.GetLineSpans(5); Assert.AreEqual(1, spans.Length); Assert.AreEqual("fnord", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(5, 5); spans = ntm.GetLineSpans(5); Assert.AreEqual(0, spans.Length); }
public void Ntm_SetPositionAsFraction() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello", "buy"), CreateNode("world", "control","fnord"), } }; ntm.SetPositionAsFraction(1, 5); var spans = ntm.GetLineSpans(1); Assert.AreEqual("buy", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(0, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("hello", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(3, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("control", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(2, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("world", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(4, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("fnord", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(5, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual(0, spans.Length); }
public void Ntm_SetPositionAsFraction() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello", "buy"), CreateNode("world", "control", "fnord"), } }; ntm.SetPositionAsFraction(1, 5); var spans = ntm.GetLineSpans(1); Assert.AreEqual("buy", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(0, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("hello", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(3, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("control", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(2, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("world", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(4, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual("fnord", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(5, 5); spans = ntm.GetLineSpans(1); Assert.AreEqual(0, spans.Length); }
public void Ntm_GetLineSpans() { var ntm = new NestedTextModel { Nodes = { CreateNode("hello", "buy"), CreateNode("world", "control", "fnord"), } }; ntm.MoveToLine(ntm.StartPosition, 1); var spans = ntm.GetLineSpans(5); Assert.AreEqual(4, spans.Length); Assert.AreEqual("buy", spans[0].TextSpans[0].GetText()); Assert.AreEqual("world", spans[1].TextSpans[0].GetText()); Assert.AreEqual("control", spans[2].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[3].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 0); spans = ntm.GetLineSpans(5); Assert.AreEqual(5, spans.Length); Assert.AreEqual("hello", spans[0].TextSpans[0].GetText()); Assert.AreEqual("buy", spans[1].TextSpans[0].GetText()); Assert.AreEqual("world", spans[2].TextSpans[0].GetText()); Assert.AreEqual("control", spans[3].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[4].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 3); spans = ntm.GetLineSpans(5); Assert.AreEqual(2, spans.Length); Assert.AreEqual("control", spans[0].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[1].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 2); spans = ntm.GetLineSpans(5); Assert.AreEqual(3, spans.Length); Assert.AreEqual("world", spans[0].TextSpans[0].GetText()); Assert.AreEqual("control", spans[1].TextSpans[0].GetText()); Assert.AreEqual("fnord", spans[2].TextSpans[0].GetText()); ntm.MoveToLine(ntm.StartPosition, 4); spans = ntm.GetLineSpans(5); Assert.AreEqual(1, spans.Length); Assert.AreEqual("fnord", spans[0].TextSpans[0].GetText()); ntm.SetPositionAsFraction(5, 5); spans = ntm.GetLineSpans(5); Assert.AreEqual(0, spans.Length); }