public void ShouldBubbleException() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); BadDivisionCommand testCommand = new BadDivisionCommand(); multiCommand.RegisterCommand(testCommand); multiCommand.Execute(null); }
public void ShouldDelegateExecuteToSingleRegistrant() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommand = new TestCommand(); multiCommand.RegisterCommand(testCommand); Assert.False(testCommand.ExecuteCalled); multiCommand.Execute(null); Assert.True(testCommand.ExecuteCalled); }
public void ShouldDelegateExecuteToSingleRegistrant() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommand = new TestCommand(); multiCommand.RegisterCommand(testCommand); Assert.IsFalse(testCommand.ExecuteCalled); multiCommand.Execute(null); Assert.IsTrue(testCommand.ExecuteCalled); }
public void ShouldBubbleException() { Assert.Throws <DivideByZeroException>(() => { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); BadDivisionCommand testCommand = new BadDivisionCommand(); multiCommand.RegisterCommand(testCommand); multiCommand.Execute(null); }); }
public void ExecuteDoesNotThrowWhenAnExecuteCommandModifiesTheCommandsCollection() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); SelfUnregisterableCommand commandOne = new SelfUnregisterableCommand(multiCommand); SelfUnregisterableCommand commandTwo = new SelfUnregisterableCommand(multiCommand); multiCommand.RegisterCommand(commandOne); multiCommand.RegisterCommand(commandTwo); multiCommand.Execute(null); Assert.IsTrue(commandOne.ExecutedCalled); Assert.IsTrue(commandTwo.ExecutedCalled); }
public void ShouldDelegateExecuteToMultipleRegistrants() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand(); TestCommand testCommandTwo = new TestCommand(); multiCommand.RegisterCommand(testCommandOne); multiCommand.RegisterCommand(testCommandTwo); Assert.False(testCommandOne.ExecuteCalled); Assert.False(testCommandTwo.ExecuteCalled); multiCommand.Execute(null); Assert.True(testCommandOne.ExecuteCalled); Assert.True(testCommandTwo.ExecuteCalled); }
public void ShouldDelegateExecuteToMultipleRegistrants() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand(); TestCommand testCommandTwo = new TestCommand(); multiCommand.RegisterCommand(testCommandOne); multiCommand.RegisterCommand(testCommandTwo); Assert.IsFalse(testCommandOne.ExecuteCalled); Assert.IsFalse(testCommandTwo.ExecuteCalled); multiCommand.Execute(null); Assert.IsTrue(testCommandOne.ExecuteCalled); Assert.IsTrue(testCommandTwo.ExecuteCalled); }
public void UnregisterCommandRemovesFromExecuteDelegation() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand() { CanExecuteValue = true }; multiCommand.RegisterCommand(testCommandOne); multiCommand.UnregisterCommand(testCommandOne); Assert.IsFalse(testCommandOne.ExecuteCalled); multiCommand.Execute(null); Assert.IsFalse(testCommandOne.ExecuteCalled); }
public void ShouldBubbleException() { Assert.Throws<DivideByZeroException>(() => { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); BadDivisionCommand testCommand = new BadDivisionCommand(); multiCommand.RegisterCommand(testCommand); multiCommand.Execute(null); }); }
public void ExecuteDoesNotThrowWhenAnExecuteCommandModifiesTheCommandsCollection() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); SelfUnregisterableCommand commandOne = new SelfUnregisterableCommand(multiCommand); SelfUnregisterableCommand commandTwo = new SelfUnregisterableCommand(multiCommand); multiCommand.RegisterCommand(commandOne); multiCommand.RegisterCommand(commandTwo); multiCommand.Execute(null); Assert.True(commandOne.ExecutedCalled); Assert.True(commandTwo.ExecutedCalled); }
public void UnregisterCommandRemovesFromExecuteDelegation() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand() { CanExecuteValue = true }; multiCommand.RegisterCommand(testCommandOne); multiCommand.UnregisterCommand(testCommandOne); Assert.False(testCommandOne.ExecuteCalled); multiCommand.Execute(null); Assert.False(testCommandOne.ExecuteCalled); }