public void ShouldNotExecuteCommandOnKeyDifferentThanEnter() { var textBox = new TextBox(); textBox.Text = "MyParameter"; TestableReturnCommandBehavior behavior = new TestableReturnCommandBehavior(textBox); var command = new MockCommand(); behavior.Command = command; behavior.InvokeKeyPressed(Key.Space); Assert.IsFalse(command.ExecuteCalled); }
public void ShouldSetEmptyTextAfterCommandExecution() { var textBox = new TextBox(); var command = new MockCommand(); TestableReturnCommandBehavior behavior = new TestableReturnCommandBehavior(textBox); behavior.Command = command; behavior.DefaultTextAfterCommandExecution = "MyDefaultText"; behavior.InvokeKeyPressed(Key.Enter); Assert.AreEqual(string.Empty, textBox.Text); }
public void ShouldExecuteCommandOnEnter() { var textBox = new TextBox(); textBox.Text = "MyParameter"; textBox.AcceptsReturn = true; var command = new MockCommand(); Assert.IsTrue(textBox.AcceptsReturn); TestableReturnCommandBehavior behavior = new TestableReturnCommandBehavior(textBox); Assert.IsFalse(textBox.AcceptsReturn); behavior.Command = command; behavior.InvokeKeyPressed(Key.Enter); Assert.IsTrue(command.ExecuteCalled); Assert.AreEqual("MyParameter", command.ExecuteParameter); }