public void Insert_past_end() { var sut = new LineEditor("ab", 5); var index = sut.Insert(10, "c", null); Assert.AreEqual(3, index); Assert.AreEqual("abc", sut.Line); }
public void Insertion_with_linebreaks() { var sut = new LineEditor("ab cd efg", 5); var result = ""; var index = sut.Insert(5, "x\ny\nz", excessText => result = excessText); Assert.AreEqual(6, index); Assert.AreEqual("ab cdx", sut.Line); Assert.AreEqual("y\nz efg", result); index = sut.Insert(1, "\n", excessText => result = excessText); Assert.AreEqual(1, index); Assert.AreEqual("a", sut.Line); Assert.AreEqual("b cdx", result); }
public void Insertions() { var sut = new LineEditor(5); var index = sut.Insert(0, "a", null); Assert.AreEqual(1, index); Assert.AreEqual("a", sut.Line); Assert.AreEqual(new[] { "a" }, sut.SoftLines); sut.Insert(1, "b", null); sut.Insert(2, " ", null); index = sut.Insert(3, "cd", null); Assert.AreEqual(5, index); Assert.AreEqual("ab cd", sut.Line); Assert.AreEqual(new[] { "ab cd" }, sut.SoftLines); sut.Insert(5, " ", null); Assert.AreEqual("ab cd ", sut.Line); Assert.AreEqual(new[] { "ab cd " }, sut.SoftLines); index = sut.Insert(6, "e", null); Assert.AreEqual(7, index); Assert.AreEqual("ab cd e", sut.Line); Assert.AreEqual(new[] { "ab cd ", "e" }, sut.SoftLines); }