コード例 #1
0
        public void WriteMoveHomeEndBackspaceMixedIntoTheEndOfBuffer()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'f');
            writer.Write(buffer, 'o');
            writer.Write(buffer, 'o');
            Assert.Equal(3, _currentIndex);
            for (int i = 0; i < 90; i++)
            {
                writer.Write(buffer, 'x');
            }
            Assert.Equal(93, _currentIndex);
            writer.MoveCursorHome();
            Assert.Equal(0, _currentIndex);
            for (int i = 0; i < 92; i++)
            {
                writer.MoveCursorRight();
            }
            Assert.Equal(92, _currentIndex);
            for (int i = 0; i < 89; i++)
            {
                writer.Backspace(buffer);
            }
            Assert.Equal(3, _currentIndex);
            writer.MoveCursorEnd();
            Assert.Equal(4, _currentIndex);
            writer.Backspace(buffer);
            Assert.Equal(3, _currentIndex);
            Assert.Equal("foo", buffer.ToString());
            Assert.Equal("foo", GetBuffer());
        }
コード例 #2
0
        public void WriteMoveHomeEndBackspaceMixed()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'f');
            writer.Write(buffer, 'o');
            writer.Write(buffer, 'o');
            for (int i = 0; i < 10; i++)
            {
                writer.Write(buffer, 'x');
            }
            writer.MoveCursorHome();
            for (int i = 0; i < 12; i++)
            {
                writer.MoveCursorRight();
            }
            for (int i = 0; i < 9; i++)
            {
                writer.Backspace(buffer);
            }
            writer.MoveCursorEnd();
            writer.Backspace(buffer);
            Assert.Equal("foo", buffer.ToString());
            Assert.Equal("foo", GetBuffer());
        }
コード例 #3
0
        public void WriteMoveBackspaceMixed()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'f');
            writer.Write(buffer, 'b');
            writer.Write(buffer, 'a');
            writer.Write(buffer, 'r');
            writer.MoveCursorLeft();
            writer.MoveCursorLeft();
            writer.MoveCursorLeft();
            writer.Write(buffer, 'o');
            writer.Write(buffer, 'o');
            writer.MoveCursorRight();
            writer.MoveCursorRight();
            writer.Backspace(buffer);
            writer.Backspace(buffer);
            writer.Write(buffer, 'B');
            writer.Write(buffer, '@');
            writer.MoveCursorLeft();
            writer.Write(buffer, 'A');
            Assert.Equal("fooBA@r", buffer.ToString());
            Assert.Equal("fooBA@r", GetBuffer());
        }
コード例 #4
0
        public void WriteAndBackspaceWithRemainingCharactersTest()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'a');
            writer.Write(buffer, 'b');
            writer.Write(buffer, 'c');
            writer.Write(buffer, 'd');
            writer.Backspace(buffer);
            writer.Backspace(buffer);
            writer.Backspace(buffer);
            Assert.Equal("a", buffer.ToString());
            Assert.Equal("a", GetBuffer());
        }
コード例 #5
0
        public void WriteAndBackspaceTest()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'a');
            writer.Write(buffer, 'b');
            writer.Write(buffer, 'c');
            writer.Write(buffer, 'd');
            writer.Backspace(buffer);
            writer.Backspace(buffer);
            writer.Backspace(buffer);
            writer.Backspace(buffer);
            Assert.Equal(String.Empty, buffer.ToString());
            Assert.Equal(String.Empty, GetBuffer());
        }
コード例 #6
0
        public void WriteMoveAndBackspace()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'a');
            writer.Write(buffer, 'b');
            writer.Write(buffer, 'c');
            writer.Write(buffer, 'd');
            writer.MoveCursorLeft();
            writer.MoveCursorLeft();
            writer.Backspace(buffer);
            writer.Write(buffer, 'x');
            Assert.Equal("axcd", buffer.ToString());
            Assert.Equal("axcd", GetBuffer());
        }
コード例 #7
0
        public void WriteMoveLeftAndBackspaceMoveEnd()
        {
            var console = BuildConsole();
            var writer  = BuildWriter(console);
            var buffer  = new CommandLineBuffer();

            writer.Write(buffer, 'f');
            writer.Write(buffer, 'o');
            writer.Write(buffer, 'o');
            writer.Write(buffer, 'b');
            Assert.Equal(4, _currentIndex);
            writer.MoveCursorLeft();
            Assert.Equal(3, _currentIndex);
            writer.Backspace(buffer);
            Assert.Equal(2, _currentIndex);
            writer.Write(buffer, 'o');
            Assert.Equal(3, _currentIndex);
            writer.MoveCursorEnd();
            Assert.Equal(4, _currentIndex);
            Assert.Equal("foob", buffer.ToString());
            Assert.Equal("foob", GetBuffer());
        }