示例#1
0
        public void Map_Command_Should_Not_Move_Up_When_Key_Up_Arrow_And_At_Start_Of_Text_Area()
        {
            // arrange
            var text = new StringBuilder();

            text.Append("test code 1\ntest code 2");

            var originalRowPosition = 1;

            var state = new ConsoleState(new InputHistory())
            {
                Text            = text,
                ColPosition     = 4,
                RowPosition     = originalRowPosition,
                TextRowPosition = 0,
            };

            var console = new Mock <IConsole>();

            var navigateCommands = new NavigateCommands(console.Object);

            // act
            navigateCommands.MoveCursorUp(state);

            // assert
            Assert.That(state.RowPosition, Is.EqualTo(originalRowPosition));
            Assert.That(state.TextRowPosition, Is.EqualTo(0));
        }
示例#2
0
        public void Map_Command_Should_Move_Up_When_Key_Up_Arrow()
        {
            // arrange
            var text = new StringBuilder();

            text.Append("test code 1\ntest code 2");

            var state = new ConsoleState(new InputHistory())
            {
                Text            = text,
                ColPosition     = 4,
                RowPosition     = 9,
                TextRowPosition = 2,
            };

            var console = new Mock <IConsole>();

            var navigateCommands = new NavigateCommands(console.Object);

            // act
            navigateCommands.MoveCursorUp(state);

            // assert
            Assert.That(state.ColPosition, Is.EqualTo(4));
            Assert.That(state.RowPosition, Is.EqualTo(8));
            Assert.That(state.TextRowPosition, Is.EqualTo(1));
        }