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)); }
public void Map_Command_Should_Not_Move_Right_When_Key_Right_Arrow_And_End_Of_Line() { // arrange var text = new StringBuilder(); text.Append("test code"); var originalLinePosition = Prompt.Standard.Length + text.Length + 1; var state = new ConsoleState(new InputHistory()) { Text = text, ColPosition = originalLinePosition, }; var console = new Mock <IConsole>(); var navigateCommands = new NavigateCommands(console.Object); // act navigateCommands.MoveCursorRight(state); // assert Assert.That(state.ColPosition, Is.EqualTo(originalLinePosition)); }
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)); }
public void Map_Command_Should_Not_Move_Left_When_Key_Left_Arrow_And_Start_Of_Line() { // arrange var originalLinePosition = Prompt.Standard.Length + 1; var state = new ConsoleState(new InputHistory()) { ColPosition = originalLinePosition, }; var console = new Mock <IConsole>(); var navigateCommands = new NavigateCommands(console.Object); // act navigateCommands.MoveCursorLeft(state); // assert Assert.That(state.ColPosition, Is.EqualTo(originalLinePosition)); }
public void Map_Command_Should_Move_Right_When_Key_Right_Arrow() { // arrange var text = new StringBuilder(); text.Append("test code"); var state = new ConsoleState(new InputHistory()) { Text = text, ColPosition = 4, }; var console = new Mock <IConsole>(); var navigateCommands = new NavigateCommands(console.Object); // act navigateCommands.MoveCursorRight(state); // assert Assert.That(state.ColPosition, Is.EqualTo(5)); }
protected override void DefaultValues() { base.DefaultValues(); this.NavigationCommand = NavigateCommands.Back; }