コード例 #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 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");
            }
コード例 #3
0
            public void ShouldInvokeTheCommand()
            {
                //arrange
                var myCommand = new MyTestCommand();

                //act
                handler.Execute(myCommand);

                //assert
                Assert.IsTrue(myCommand.HasExecuted, "should have been executed");
            }
コード例 #4
0
            public void ShouldRethrowAnyExceptionFiredBy()
            {
                //arrange
                var myCommand = new MyTestCommand()
                {
                    ThrowExceptionOnExecuting = true
                };

                //act
                handler.Execute(myCommand);
            }
コード例 #5
0
            public void ShouldInvokeTheCommand()
            {
                //arrange
                var myCommand = new MyTestCommand();

                //act
                handler.Execute(myCommand);

                //assert
                Assert.IsTrue(myCommand.HasExecuted, "should have been executed");
            }
コード例 #6
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");
            }
コード例 #7
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
            }
コード例 #8
0
            public void ShouldNotAddTheCommandToTheUndoStackIfTheExecutionOfTheCommandThrowsAnException()
            {
                //arrange
                var myCommand = new MyTestCommand()
                {
                    ThrowExceptionOnExecuting = true
                };

                //act
                try
                {
                    handler.Execute(myCommand);
                }
                catch { } //we're not interested in the exception here

                //assert
                mockUndoRedo.Verify(x => x.AddItem(myCommand), Times.Never(), "The command should not have been added as it threw an exception");
            }
コード例 #9
0
 public new void TearDown()
 {
     base.TearDown();
     myCommand = null;
 }
コード例 #10
0
            public void ShouldNotAddTheCommandToTheUndoStackIfTheExecutionOfTheCommandThrowsAnException()
            {
                //arrange
                var myCommand = new MyTestCommand()
                {
                    ThrowExceptionOnExecuting = true
                };

                //act
                try
                {
                    handler.Execute(myCommand);
                }
                catch { } //we're not interested in the exception here

                //assert
                mockUndoRedo.Verify(x => x.AddItem(myCommand), Times.Never(), "The command should not have been added as it threw an exception");
            }
コード例 #11
0
 public new void TearDown()
 {
     base.TearDown();
     myCommand = null;
 }
コード例 #12
0
            public new void SetUp()
            {
                base.SetUp();
                myCommand = new MyTestCommand();
                handler.Execute(myCommand);

                mockUndoRedo.Setup(x => x.Undo()).Returns(myCommand);
            }
コード例 #13
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
            }
コード例 #14
0
            public void ShouldRethrowAnyExceptionFiredBy()
            {
                //arrange
                var myCommand = new MyTestCommand()
                {
                    ThrowExceptionOnExecuting = true
                };

                //act
                handler.Execute(myCommand);
            }