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

            controller.ApplyCommand(command);

            controller.Text.Should().BeEquivalentTo(string.Empty);
            controller.CurrentPosition.Should().Be(0);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }