示例#1
0
        public void Undo_PerformsUndo()
        {
            var commandExecutionManager = new CommandExecutionManager();
            var commandMock             = new Mock <ICommand>();

            commandExecutionManager.ExecuteCommand(commandMock.Object);

            commandExecutionManager.Undo();

            commandMock.Verify(c => c.Undo(), Times.Once());
        }
示例#2
0
        public void Redo_PerformsRedo()
        {
            var commandExecutionManager = new CommandExecutionManager();
            var commandMock             = new Mock <ICommand>();

            commandExecutionManager.ExecuteCommand(commandMock.Object);
            commandExecutionManager.Undo();

            commandExecutionManager.Redo();

            commandMock.Verify(c => c.Execute(), Times.Exactly(2));
        }
示例#3
0
        public void ExecuteCommand_ClearsUndoHistory()
        {
            var commandExecutionManager = new CommandExecutionManager();
            var commandMock             = new Mock <ICommand>();

            commandExecutionManager.ExecuteCommand(commandMock.Object);
            commandExecutionManager.Undo();

            commandExecutionManager.ExecuteCommand(commandMock.Object);

            Assert.Throws <InvalidOperationException>(() => commandExecutionManager.Redo());
        }
示例#4
0
        public void Undo_NothingToUndo_InvalidOperationException()
        {
            var commandExecutionManager = new CommandExecutionManager();

            Assert.Throws <InvalidOperationException>(() => commandExecutionManager.Undo());
        }