Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
 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);
 }