public void RegisterACommandShouldRaiseCanExecuteEvent() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommand = new TestCommand(); multiCommand.RegisterCommand(new TestCommand()); Assert.IsTrue(multiCommand.CanExecuteChangedRaised); }
public void ShouldDelegateCanExecuteToSingleRegistrant() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommand = new TestCommand(); multiCommand.RegisterCommand(testCommand); Assert.IsFalse(testCommand.CanExecuteCalled); multiCommand.CanExecute(null); Assert.IsTrue(testCommand.CanExecuteCalled); }
public void ShouldDelegateCanExecuteToMultipleRegistrants() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand(); TestCommand testCommandTwo = new TestCommand(); multiCommand.RegisterCommand(testCommandOne); multiCommand.RegisterCommand(testCommandTwo); Assert.IsFalse(testCommandOne.CanExecuteCalled); Assert.IsFalse(testCommandTwo.CanExecuteCalled); multiCommand.CanExecute(null); Assert.IsTrue(testCommandOne.CanExecuteCalled); Assert.IsTrue(testCommandTwo.CanExecuteCalled); }
public void CanExecuteShouldReturnTrueIfAllRegistrantsTrue() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand() { CanExecuteValue = true }; TestCommand testCommandTwo = new TestCommand() { CanExecuteValue = true }; multiCommand.RegisterCommand(testCommandOne); multiCommand.RegisterCommand(testCommandTwo); Assert.IsTrue(multiCommand.CanExecute(null)); }
public void RegisteringCommandTwiceThrows() { var compositeCommand = new CompositeCommand(); var duplicateCommand = new TestCommand(); compositeCommand.RegisterCommand(duplicateCommand); compositeCommand.RegisterCommand(duplicateCommand); }
public void UnregisterCommandDisconnectsCanExecuteChangedDelegate() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand() { CanExecuteValue = true }; multiCommand.RegisterCommand(testCommandOne); multiCommand.UnregisterCommand(testCommandOne); multiCommand.CanExecuteChangedRaised = false; testCommandOne.FireCanExecuteChanged(); Assert.IsFalse(multiCommand.CanExecuteChangedRaised); }
public void UnregisterCommandShouldRaiseCanExecuteEvent() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand(); multiCommand.RegisterCommand(testCommandOne); multiCommand.CanExecuteChangedRaised = false; multiCommand.UnregisterCommand(testCommandOne); Assert.IsTrue(multiCommand.CanExecuteChangedRaised); }
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 ShouldReraiseCanExecuteChangedEventAfterCollect() { TestableCompositeCommand multiCommand = new TestableCompositeCommand(); TestCommand testCommandOne = new TestCommand() { CanExecuteValue = true }; Assert.IsFalse(multiCommand.CanExecuteChangedRaised); multiCommand.RegisterCommand(testCommandOne); multiCommand.CanExecuteChangedRaised = false; GC.Collect(); testCommandOne.FireCanExecuteChanged(); Assert.IsTrue(multiCommand.CanExecuteChangedRaised); }
public void RegisteringCommandTwiceThrows() { var compositeCommand = new CompositeCommand(); var duplicateCommand = new TestCommand(); compositeCommand.RegisterCommand(duplicateCommand); Assert.ThrowsException<InvalidOperationException>(() => compositeCommand.RegisterCommand(duplicateCommand)); }