public new void SetUp() { base.SetUp(); myCommand = new MyTestCommand(); handler.Execute(myCommand); mockUndoRedo.Setup(x => x.Undo()).Returns(myCommand); }
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"); }
public void ShouldInvokeTheCommand() { //arrange var myCommand = new MyTestCommand(); //act handler.Execute(myCommand); //assert Assert.IsTrue(myCommand.HasExecuted, "should have been executed"); }
public void ShouldRethrowAnyExceptionFiredBy() { //arrange var myCommand = new MyTestCommand() { ThrowExceptionOnExecuting = true }; //act handler.Execute(myCommand); }
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 }
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"); }
public new void TearDown() { base.TearDown(); myCommand = null; }