Example #1
0
        public void EmptyBuffer()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Contents.Should().BeEmpty();
            buffer.CursorIndex.Should().Be(0);
            buffer.Length.Should().Be(0);
            buffer.CursorIsAtEnd.Should().BeTrue();
            buffer.ToString().Should().BeEmpty();
        }
Example #2
0
        public void InsertStringAtEnd()
        {
            const string s      = "xyzzy";
            var          buffer = new ConsoleInputBuffer();

            buffer.Insert(s);

            buffer.Contents.Should().Be(s);
            buffer.CursorIndex.Should().Be(0);
            buffer.Length.Should().Be(s.Length);
            buffer.CursorIsAtEnd.Should().BeFalse();
            buffer.ToString().Should().Be(s);
        }
Example #3
0
        public void InsertCharAtEnd()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert('x');

            buffer.Contents.Should().Be("x");
            buffer.CursorIndex.Should().Be(0);
            buffer.Length.Should().Be(1);
            buffer.CursorIsAtEnd.Should().BeFalse();
            buffer.ToString().Should().Be("x");
            buffer[0].Should().Be('x');
        }
Example #4
0
        public void InsertStringInMiddle()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");
            buffer.MoveCursor(SeekOrigin.Begin, 2);

            buffer.Insert("xyz");

            buffer.Contents.Should().Be("abxyzcd");
            buffer.CursorIndex.Should().Be(2);
            buffer.Length.Should().Be(7);
            buffer.CursorIsAtEnd.Should().BeFalse();
            buffer.ToString().Should().Be("abxyzcd");
        }
Example #5
0
        public void RemoveMultipleChars()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");
            buffer.MoveCursor(SeekOrigin.Begin, 1);

            buffer.Remove(2).Should().BeTrue();

            buffer.Contents.Should().Be("ad");
            buffer.CursorIndex.Should().Be(1);
            buffer.Length.Should().Be(2);
            buffer.CursorIsAtEnd.Should().BeFalse();
            buffer.ToString().Should().Be("ad");
        }
Example #6
0
        public void RemoveLastChar()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");
            buffer.MoveCursor(SeekOrigin.Begin, 3);

            buffer.Remove().Should().BeTrue();

            buffer.Contents.Should().Be("abc");
            buffer.CursorIndex.Should().Be(3);
            buffer.Length.Should().Be(3);
            buffer.CursorIsAtEnd.Should().BeTrue();
            buffer.ToString().Should().Be("abc");
        }
Example #7
0
        public void Truncate()
        {
            var buffer = new ConsoleInputBuffer();

            buffer.Insert("abcd");
            buffer.MoveCursor(SeekOrigin.Begin, 2);

            buffer.Truncate();

            buffer.Contents.Should().Be("ab");
            buffer.CursorIndex.Should().Be(2);
            buffer.Length.Should().Be(2);
            buffer.CursorIsAtEnd.Should().BeTrue();
            buffer.ToString().Should().Be("ab");
        }