Beispiel #1
0
 public IUndoableCommand Pop()
 {
     if (_commands.First != null)
     {
         IUndoableCommand first = _commands.First.Value;
         _commands.RemoveFirst();
         return(first);
     }
     return(EmptyCommand.GetEmptyCommand());
 }
Beispiel #2
0
        public void ClearTest()
        {
            var light    = new Light();
            var command0 = new OnCommand(light);
            var command1 = new OnCommand(light);
            var command2 = new OnCommand(light);
            var command3 = new OnCommand(light);

            _undoStack.Push(command0);
            _undoStack.Push(command1);
            _undoStack.Push(command2);
            _undoStack.Push(command3);

            _undoStack.Clear();

            var ret = _undoStack.Pop();

            Assert.AreEqual(ret, EmptyCommand.GetEmptyCommand());
        }
Beispiel #3
0
        public void PushPopTest()
        {
            var light    = new Light();
            var command0 = new OnCommand(light);
            var command1 = new OnCommand(light);
            var command2 = new OnCommand(light);
            var command3 = new OnCommand(light);

            _undoStack.Push(command0);
            _undoStack.Push(command1);
            _undoStack.Push(command2);
            _undoStack.Push(command3);

            var retCommand3 = _undoStack.Pop();
            var retCommand2 = _undoStack.Pop();
            var retCommand1 = _undoStack.Pop();
            var retCommand0 = _undoStack.Pop();

            Assert.AreEqual(retCommand0, EmptyCommand.GetEmptyCommand());
            Assert.AreEqual(command1, retCommand1);
            Assert.AreEqual(command2, retCommand2);
            Assert.AreEqual(command3, retCommand3);
        }