public void Target_Command_CallCount_Is_Zero_After_Initialization_Of_CommandBinder() { var source = new MockEventSource(); var target = new MockViewModelWithAction(); var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command); binder.Bind(); Assert.AreEqual(0, target.Command.CallCount); }
public void Source_Gets_Disabled_When_Target_Command_Is_Disabled_During_Initialization_With_Expression() { 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(); Assert.IsFalse(source.IsEnabled); }
public void Source_Is_Enabled_When_Target_ICommand_CanExecute_Is_True_During_Initialization() { var source = new MockEventSource(); var target = new MockViewModelWithAction(); var binder = new CommandBinder<MockEventArgs>(source, "MockEvent", target.Command); binder.Bind(); Assert.IsTrue(source.IsEnabled); }
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_Gets_Disabled_After_Initialization() { var source = new MockEventSource(); var target = new MockViewModelWithAction() {IsActionEnabled = true}; var binder = new MethodBinder<MockEventArgs>(source, "MockEvent", e => target.Action(), p => target.IsActionEnabled,target); binder.Bind(); target.IsActionEnabled = false; Assert.IsFalse(source.IsEnabled); }
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_constructed_with_action_disabled_then_source_gets_disabled() { 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(); Assert.IsFalse(source.IsEnabled); }
public void When_constructed_then_subscribes_to_event() { var source = new MockEventSource(); var binder = new MethodBinder<MockEventArgs>(source, "MockEvent", e => this.SetAction()); binder.Bind(); Assert.IsNotNull(source.EventHandler); }
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); }
public void Source_Is_Enabled_When_Target_Command_Is_Enabled_During_Initialization() { var source = new MockEventSource(); var target = new MockViewModelWithAction() {IsActionEnabled = true}; var binder = new MethodBinder<MockEventArgs>(source, "MockEvent", e => this.SetAction(), p => target.IsActionEnabled,target); Assert.IsTrue(source.IsEnabled); }