예제 #1
0
        public void EditExecutesCommand()
        {
            var command = new ChangeHeightCommand(shape, 10);
            commandProcessor.Do(command);

            Assert.AreEqual(10, shape.Height);
        }
예제 #2
0
        public void EditEnablesUndo()
        {
            var command = new ChangeHeightCommand(shape, 10);
            commandProcessor.Do(command);

            Assert.IsTrue(commandProcessor.CanUndo());
        }
예제 #3
0
        public void MultipleRedos()
        {
            var command = new ChangeHeightCommand(shape, 10);

            ChangeHeightManyTimes(commandProcessor, shape, 10);
            UndoMany(commandProcessor, 5);
            RedoMany(commandProcessor, 3);

            Assert.AreEqual(70, shape.Height);
        }
예제 #4
0
        public void AfterNewEditRedoIsDisabled()
        {
            var command = new ChangeHeightCommand(shape, 10);

            ChangeHeightManyTimes(commandProcessor, shape, 10);
            UndoMany(commandProcessor, 3);
            commandProcessor.Do(new ChangeWidthCommand(shape, 100));

            Assert.IsFalse(commandProcessor.CanRedo());
        }
예제 #5
0
 public ChangeHeightCommandTests()
 {
     shape = new Shape();
     shape.Height = 10;
     changeHeightCommand = new ChangeHeightCommand(shape, 50);
 }
예제 #6
0
 private void ChangeHeightManyTimes(CommandProcessor editor, Shape shape, Int32 numberOfTimes)
 {
     for (var i = 0; i < numberOfTimes; i++)
     {
         var command = new ChangeHeightCommand(shape, i * 10);
         editor.Do(command);
     }
 }
예제 #7
0
        public void UndoWithOneCommandEnablesRedo()
        {
            var command = new ChangeHeightCommand(shape, 10);
            commandProcessor.Do(command);
            commandProcessor.Undo();

            Assert.IsTrue(commandProcessor.CanRedo());
        }
예제 #8
0
        public void UndoWithOneCommandDisablesUndo()
        {
            var command = new ChangeHeightCommand(shape, 10);
            commandProcessor.Do(command);
            commandProcessor.Undo();

            Assert.IsFalse(commandProcessor.CanUndo());
        }
예제 #9
0
        public void UndoRedoIsDisabledBeforeEdit()
        {
            var command = new ChangeHeightCommand(shape, 10);

            Assert.IsFalse(commandProcessor.CanRedo());
            Assert.IsFalse(commandProcessor.CanUndo());
        }
예제 #10
0
        public void RedoCallsUnexecute()
        {
            var command = new ChangeHeightCommand(shape, 10);
            commandProcessor.Do(command);
            commandProcessor.Undo();
            commandProcessor.Redo();

            Assert.AreEqual(10, shape.Height);
        }