예제 #1
0
        public void ApplyCommandWhenStateInvalidShouldRevertCommand()
        {
            var command = new MoveCursorCommand(-5);

            controller.ApplyCommand(command);

            controller.Text.Should().BeEquivalentTo(string.Empty);
            controller.CurrentPosition.Should().Be(0);
        }
예제 #2
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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }