public void ApplyCommandWhenStateInvalidShouldRevertCommand() { var command = new MoveCursorCommand(-5); controller.ApplyCommand(command); controller.Text.Should().BeEquivalentTo(string.Empty); controller.CurrentPosition.Should().Be(0); }
public void ApplyShouldMoveCursorFromDifferentPositions(int startPosition) { state.CurrentPosition = startPosition; command = new MoveCursorCommand(1); var result = command.Apply(state); result.Should().BeTrue(); state.CurrentPosition.Should().Be(startPosition + 1); }
public void ApplyShouldMoveCursorToDifferentDistances(int targetPosition) { var oldPosition = state.CurrentPosition; command = new MoveCursorCommand(targetPosition); var result = command.Apply(state); result.Should().BeTrue(); state.CurrentPosition.Should().Be(oldPosition + targetPosition); }
public void RevertShouldRestoreStateFromDifferentDistances(int targetPosition) { command = new MoveCursorCommand(targetPosition); var oldState = new ControllerState(state); var applyResult = command.Apply(state); applyResult.Should().BeTrue(); var result = command.Revert(state); result.Should().BeTrue(); state.Should().Be(oldState); }
public void RevertShouldRestoreStateFromDifferentPositions(int startPosition) { state.CurrentPosition = startPosition; command = new MoveCursorCommand(1); var oldState = new ControllerState(state); var applyResult = command.Apply(state); applyResult.Should().BeTrue(); var result = command.Revert(state); result.Should().BeTrue(); state.Should().Be(oldState); }