public void WhenChangingProperty_ThenUpdatesCommand() { var someControl = new TextBox(); var oldCommand = new MockCommand(); var newCommand = new MockCommand(); var commandAction = new InvokeCommandAction(); commandAction.Attach(someControl); commandAction.Command = oldCommand; commandAction.Command = newCommand; commandAction.InvokeAction(null); Assert.IsTrue(newCommand.ExecuteCalled); Assert.IsFalse(oldCommand.ExecuteCalled); }
public void WhenCommandAndCommandParameterAreSetPriorToBehaviorBeingAttached_ThenCommandIsExecutedCorrectlyOnInvoke() { var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Command = command; commandAction.CommandParameter = parameter; commandAction.Attach(someControl); commandAction.InvokeAction(null); Assert.IsTrue(command.ExecuteCalled); }
public void WhenChangingProperty_ThenUpdatesCommand() { var someControl = new TextBox(); var oldCommand = new MockCommand(); var newCommand = new MockCommand(); var commandAction = new InvokeCommandAction(); commandAction.Attach(someControl); commandAction.Command = oldCommand; commandAction.Command = newCommand; commandAction.InvokeAction(null); Assert.True(newCommand.ExecuteCalled); Assert.False(oldCommand.ExecuteCalled); }
public void WhenCommandParameterNotSet_ThenEventArgsPassed() { var eventArgs = new TestEventArgs(null); var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Command = command; commandAction.Attach(someControl); commandAction.InvokeAction(eventArgs); Assert.IsType <TestEventArgs>(command.ExecuteParameter); }
public void WhenCommandAndCommandParameterAreSetPriorToBehaviorBeingAttached_ThenCommandIsExecutedCorrectlyOnInvoke() { var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Command = command; commandAction.CommandParameter = parameter; commandAction.Attach(someControl); commandAction.InvokeAction(null); Assert.True(command.ExecuteCalled); }
public void WhenAttachedAfterCommandPropertyIsSetAndInvoked_ThenInvokesCommand() { var someControl = new TextBox(); var commandAction = new InvokeCommandAction(); var command = new MockCommand(); commandAction.Command = command; commandAction.Attach(someControl); Assert.IsFalse(command.ExecuteCalled); commandAction.InvokeAction(null); Assert.IsTrue(command.ExecuteCalled); Assert.AreSame(command, commandAction.GetValue(InvokeCommandAction.CommandProperty)); }
public void WhenCommandPropertyIsSet_ThenHooksUpCommandBehavior() { var someControl = new TextBox(); var commandAction = new InvokeCommandAction(); var command = new MockCommand(); commandAction.Attach(someControl); commandAction.Command = command; Assert.IsFalse(command.ExecuteCalled); commandAction.InvokeAction(null); Assert.IsTrue(command.ExecuteCalled); Assert.AreSame(command, commandAction.GetValue(InvokeCommandAction.CommandProperty)); }
public void WhenAttachedAfterCommandPropertyIsSetAndInvoked_ThenInvokesCommand() { var someControl = new TextBox(); var commandAction = new InvokeCommandAction(); var command = new MockCommand(); commandAction.Command = command; commandAction.Attach(someControl); Assert.False(command.ExecuteCalled); commandAction.InvokeAction(null); Assert.True(command.ExecuteCalled); Assert.Same(command, commandAction.GetValue(InvokeCommandAction.CommandProperty)); }
public void WhenCommandParameterNotSetAndEventArgsParameterPathSet_ThenPathedValuePassed() { var eventArgs = new TestEventArgs("testname"); var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Command = command; commandAction.TriggerParameterPath = "Thing1.Thing2.Name"; commandAction.Attach(someControl); commandAction.InvokeAction(eventArgs); Assert.Equal("testname", command.ExecuteParameter); }
public void WhenCommandPropertyIsSet_ThenHooksUpCommandBehavior() { var someControl = new TextBox(); var commandAction = new InvokeCommandAction(); var command = new MockCommand(); commandAction.Attach(someControl); commandAction.Command = command; Assert.False(command.ExecuteCalled); commandAction.InvokeAction(null); Assert.True(command.ExecuteCalled); Assert.Same(command, commandAction.GetValue(InvokeCommandAction.CommandProperty)); }
public void WhenInvokedWithCommandParameter_ThenPassesCommandParaeterToExecute() { var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Attach(someControl); commandAction.Command = command; commandAction.CommandParameter = parameter; Assert.IsNull(command.ExecuteParameter); commandAction.InvokeAction(null); Assert.IsTrue(command.ExecuteCalled); Assert.IsNotNull(command.ExecuteParameter); Assert.AreSame(parameter, command.ExecuteParameter); }
public void WhenInvokedWithCommandParameter_ThenPassesCommandParaeterToExecute() { var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Attach(someControl); commandAction.Command = command; commandAction.CommandParameter = parameter; Assert.Null(command.ExecuteParameter); commandAction.InvokeAction(null); Assert.True(command.ExecuteCalled); Assert.NotNull(command.ExecuteParameter); Assert.Same(parameter, command.ExecuteParameter); }
public void WhenCommandParameterNotSet_ThenEventArgsPassed() { var eventArgs = new TestEventArgs(null); var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Command = command; commandAction.Attach(someControl); commandAction.InvokeAction(eventArgs); Assert.IsInstanceOfType(command.ExecuteParameter, typeof(TestEventArgs)); }
public void WhenCommandParameterNotSetAndEventArgsParameterPathSet_ThenPathedValuePassed() { var eventArgs = new TestEventArgs("testname"); var someControl = new TextBox(); var command = new MockCommand(); var parameter = new object(); var commandAction = new InvokeCommandAction(); commandAction.Command = command; commandAction.TriggerParameterPath = "Thing1.Thing2.Name"; commandAction.Attach(someControl); commandAction.InvokeAction(eventArgs); Assert.AreEqual("testname", command.ExecuteParameter); }