public void GivenParamCommandWithCanExec_WhenRegisteringEvent_ThenItReactWithProperHandler() { TEST_OUTPUT = String.Empty; paramsCommandRelayerSubject = new RelayCommand <object>(o => TEST_OUTPUT += "1", o => false); paramsCommandRelayerSubject.CanExecuteChanged += (sender, args) => TEST_OUTPUT += "5"; RandomProperty = new object(); DispatcherTestHelper.ProcessWorkItems(DispatcherPriority.Background); Assert.Equal("5", TEST_OUTPUT); }
public void GivenSimpleCommandWithCanExec_WhenUnRegisteringEvent_ThenItDoesNothing() { TEST_OUTPUT = String.Empty; simpleCommandRelayerSubject = new RelayCommand(() => TEST_OUTPUT += "1", () => false); EventHandler handler = (sender, args) => TEST_OUTPUT += "5"; simpleCommandRelayerSubject.CanExecuteChanged += handler; simpleCommandRelayerSubject.CanExecuteChanged -= handler; RandomProperty = new object(); DispatcherTestHelper.ProcessWorkItems(DispatcherPriority.Background); Assert.Equal(String.Empty, TEST_OUTPUT); }