Exemplo n.º 1
0
        public void ComplexOperationTests()
        {
            var          gapBuffer = new GapBuffer();
            const string lorem     = "Lorem";

            gapBuffer.Insert(' ', 0);

            foreach (var character in lorem)
            {
                gapBuffer.Insert(character, gapBuffer.GetLength());
            }

            var actualResult = gapBuffer.GetText(0, gapBuffer.GetLength() - 1);

            Assert.AreEqual(" Lorem", actualResult, "The returned text differs.");


            foreach (var character in lorem)
            {
                gapBuffer.Insert(character, 0);
            }

            actualResult = gapBuffer.GetText(0, gapBuffer.GetLength() - 1);
            Assert.AreEqual("meroL Lorem", actualResult, "The returned text differs.");

            gapBuffer.Delete(3, 3);
            actualResult = gapBuffer.GetText(0, gapBuffer.GetLength() - 1);
            Assert.AreEqual("merL Lorem", actualResult, "The returned text differs.");

            gapBuffer.Delete(0, gapBuffer.GetLength() - 1);
            actualResult = gapBuffer.GetText(0, 0);
            Assert.AreEqual(default, actualResult, "The returned text differs.");
Exemplo n.º 2
0
        public void InsertStringTest()
        {
            // Arrange.
            var gapBuffer      = new GapBuffer();
            var expectedResult = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse nisl.";

            // Act.
            gapBuffer.Insert(expectedResult, 0);
            var actualResult = gapBuffer.GetText(0, gapBuffer.GetLength() - 1);

            // Assert.
            Assert.AreEqual(expectedResult, actualResult, "The buffer storage content differs.");
        }
Exemplo n.º 3
0
        public void GetTextMiddleStringTest()
        {
            // Arrange.
            var gapBuffer      = new GapBuffer();
            var expectedResult = "ipsum";

            gapBuffer.Insert("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse nisl.", 0);

            // Act.
            var actualResult = gapBuffer.GetText(6, 10);

            // Assert.
            Assert.AreEqual(expectedResult, actualResult, "The returned text differs.");
        }
Exemplo n.º 4
0
        public void InsertCharTest()
        {
            // Arrange.
            var gapBuffer      = new GapBuffer();
            var expectedResult = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse nisl.";

            // Act.
            var index = 0;

            foreach (var character in expectedResult)
            {
                gapBuffer.Insert(character, index);
                index++;
            }

            var actualResult = gapBuffer.GetText(0, gapBuffer.GetLength() - 1);

            // Assert.
            Assert.AreEqual(expectedResult, actualResult, "The buffer storage content differs.");
        }