public void Target_Command_Is_Executed_When_Source_Event_Is_Raised_And_Command_Is_Enabled() { var source = new MockEventSource(); var target = new MockViewModelWithAction(); var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command); binder.Bind(); source.RaiseMockEvent("foo"); Assert.AreEqual(1, target.Command.CallCount); }
public void Source_Is_Disabled_When_Target_Command_Becomes_Disabled() { var source = new MockEventSource(); var target = new MockViewModelWithAction(); var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command); target.Command.MaxCalls = 1; binder.Bind(); source.RaiseMockEvent("foo"); Assert.IsFalse(source.IsEnabled); }
public void When_event_is_raised_then_action_is_called() { var source = new MockEventSource(); var binder = new MethodBinder<MockEventArgs>(source, "MockEvent", e => this.SetAction()); binder.Bind(); source.RaiseMockEvent("foo"); Assert.IsTrue(this._actionWasCalled); }
public void When_command_is_disabled_and_event_is_raised_then_action_is_not_called() { var source = new MockEventSource(); var target = new MockViewModelWithAction() {IsActionEnabled = false}; var binder = new MethodBinder<MockEventArgs>(source, "MockEvent", e => this.SetAction(), p => target.IsActionEnabled,target); binder.Bind(); source.RaiseMockEvent("foo"); Assert.IsFalse(this._actionWasCalled); }