Ejemplo n.º 1
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.º 2
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);
 }
 private void Bind(Delegate d)
 {
     MethodBinder.Bind(d, this);
 }
Ejemplo n.º 4
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.º 5
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.º 6
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.º 7
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);
 }