示例#1
0
        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());
        }
示例#2
0
        public void InsertWithNoPositions()
        {
            TSBuilder builder = new TSBuilder();

            builder.Insert(0, "abcd");
            Assert.AreEqual("abcd", builder.ToString());
        }
示例#3
0
        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());
        }
示例#4
0
        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());
        }
示例#5
0
 protected void Insert(int index, string text)
 {
     builder.Insert(index, text);
 }