Beispiel #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.");
Beispiel #2
0
        public void DeleteMiddleCharTest()
        {
            // Arrange.
            var gapBuffer      = new GapBuffer();
            var expectedResult = "Loremipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse nisl.";

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

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

            // Assert.
            Assert.AreEqual(expectedResult, actualResult, "The buffer storage content differs.");
        }
Beispiel #3
0
        public void GetLengthDeleteTest()
        {
            // Arrange.
            var gapBuffer      = new GapBuffer();
            var expectedResult = 0;

            gapBuffer.Insert("Lorem", 0);

            // Act.
            gapBuffer.Delete(0, gapBuffer.GetLength() - 1);
            var actualResult = gapBuffer.GetLength();

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