示例#1
0
            public new void SetUp()
            {
                base.SetUp();
                myCommand = new MyTestCommand();
                handler.Execute(myCommand);

                mockUndoRedo.Setup(x => x.Undo()).Returns(myCommand);
            }
示例#2
0
            public void ShouldInvokeTheCommand()
            {
                // Arrange
                var myCommand = new MyTestCommand();

                // Act
                handler.Execute(myCommand);

                // Assert
                Assert.IsTrue(myCommand.HasExecuted, "should have been executed");
            }
示例#3
0
            public void ShouldRethrowAnyExceptionFiredBy()
            {
                // Arrange
                var myCommand = new MyTestCommand()
                {
                    ThrowExceptionOnExecuting = true
                };

                // Act / assert
                Assert.ThrowsException <ApplicationException>(() => { handler.Execute(myCommand); });
            }
示例#4
0
            public void ShouldAddTheCommandToTheUndoStack()
            {
                // Arrange
                var myCommand = new MyTestCommand();

                // Act
                handler.Execute(myCommand);

                // Assert
                mockUndoRedo.Verify(x => x.AddItem(myCommand), Times.Once(), "The command should have been added to the undo stack");
            }
示例#5
0
            public new void SetUp()
            {
                base.SetUp();
                myCommand = new MyTestCommand();

                mockUndoRedo.Setup(x => x.Undo()).Returns(myCommand);
                mockUndoRedo.Setup(x => x.Redo()).Returns(myCommand);

                handler.Execute(myCommand);
                handler.Undo();

                myCommand.HasExecuted = false; // Reset it
            }
示例#6
0
 public new void TearDown()
 {
     base.TearDown();
     myCommand = null;
 }