public void ShouldReEnableButtonIfCanExecuteChangedRaises() { var clickableObject = new MockClickableObject(); var mockCommand = new MockCommand() { CanExecuteReturnValue = false }; var behavior = new ButtonBaseClickCommandBehavior(clickableObject); behavior.Command = mockCommand; Assert.IsFalse(clickableObject.IsEnabled); mockCommand.CanExecuteReturnValue = true; mockCommand.RaiseCanExecuteChanged(); Assert.IsTrue(clickableObject.IsEnabled); }
public void DisposedControlDoesNotThrowOnCanExecuteChanged() { var clickableObject = new MockClickableObject(); var command = new MockCommand(); var behavior = new ButtonBaseClickCommandBehavior(clickableObject); behavior.Command = command; WeakReference controlWeakReference = new WeakReference(clickableObject); clickableObject = null; behavior = null; GC.Collect(); command.CanExecuteReturnValue = false; command.RaiseCanExecuteChanged(); }
public void DisposedControlStopsMonitoringCommandAfterFirstCanExecuteChanged() { var clickableObject = new MockClickableObject(); var command = new MockCommand(); var behavior = new ButtonBaseClickCommandBehavior(clickableObject); behavior.Command = command; clickableObject = null; WeakReference commandReference = new WeakReference(command); GC.Collect(); command.CanExecuteReturnValue = false; command.RaiseCanExecuteChanged(); command = null; GC.Collect(); Assert.IsFalse(commandReference.IsAlive); }
public void ShouldNotMonitorCanExecuteChangedOnDisconnectedCommand() { var clickableObject = new MockClickableObject(); var command = new MockCommand(); var behavior = new ButtonBaseClickCommandBehavior(clickableObject); behavior.Command = command; behavior.Command = null; Assert.IsTrue(clickableObject.IsEnabled); command.CanExecuteReturnValue = false; command.RaiseCanExecuteChanged(); Assert.IsTrue(clickableObject.IsEnabled); }