public void InsertBetweenExistingPositions() { TSBuilder builder = new TSBuilder(); builder.Text("ab"); BuilderPosition p1 = builder.CreatePosition(); builder.Text("cd"); BuilderPosition p2 = builder.CreatePosition(); builder.Text("ef"); Assert.AreEqual(2, p1.CharactersAfterPreviousPosition); Assert.AreEqual(2, p1.GetIndexInBuilder()); Assert.AreEqual(2, p2.CharactersAfterPreviousPosition); Assert.AreEqual(4, p2.GetIndexInBuilder()); builder.Insert(3, "Z"); Assert.AreEqual("abcZdef", builder.ToString()); Assert.AreEqual(2, p1.CharactersAfterPreviousPosition); Assert.AreEqual(2, p1.GetIndexInBuilder()); Assert.AreEqual(3, p2.CharactersAfterPreviousPosition); Assert.AreEqual(5, p2.GetIndexInBuilder()); }
public void InsertWithNoPositions() { TSBuilder builder = new TSBuilder(); builder.Insert(0, "abcd"); Assert.AreEqual("abcd", builder.ToString()); }
public void InsertAtAnExistingPosition() { TSBuilder builder = new TSBuilder(); BuilderPosition p = builder.CreatePosition(); builder.Insert(0, "abcd"); Assert.AreEqual("abcd", builder.ToString()); Assert.AreEqual(4, p.CharactersAfterPreviousPosition); Assert.AreEqual(4, p.GetIndexInBuilder()); }
public void InsertAfterAnExistingPosition() { TSBuilder builder = new TSBuilder(); builder.Text("abc"); BuilderPosition p = builder.CreatePosition(); builder.Text("df"); Assert.AreEqual(3, p.CharactersAfterPreviousPosition); Assert.AreEqual(3, p.GetIndexInBuilder()); builder.Insert(4, "e"); Assert.AreEqual(3, p.CharactersAfterPreviousPosition); Assert.AreEqual(3, p.GetIndexInBuilder()); }
protected void Insert(int index, string text) { builder.Insert(index, text); }