コード例 #1
0
        public void ApplyCommandWhenCommandCantBeAppliedShouldReturnFalse()
        {
            var command = new DeleteCharCommand();

            var result = controller.ApplyCommand(command);

            result.Should().BeFalse();
            controller.Text.Should().BeEquivalentTo(string.Empty);
            controller.CurrentPosition.Should().Be(0);
        }
コード例 #2
0
        public void ApplyShouldDeleteChar(int position)
        {
            state.CurrentPosition = position;
            command = new DeleteCharCommand();
            var oldState = new ControllerState(state);

            var result = command.Apply(state);

            result.Should().BeTrue();
            state.Text.ToString().Should().BeEquivalentTo(oldState.Text.Remove(position, 1).ToString());
            state.CurrentPosition.Should().Be(position);
        }
コード例 #3
0
        public void RevertShouldRestoreState(int position)
        {
            state.CurrentPosition = position;
            command = new DeleteCharCommand();
            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);
        }