public void OnlyHandlesEscape() { TextBox box; KeyEventArgs args; box = new TextBox { Text = "test" }; ClearOnEscape.SetEnabled(box, true); args = SendKeyDown(box, Key.Return); Assert.False(args.Handled); Assert.Equal("test", box.Text); }
public void DoesNotHandleEventWhenTextIsEmpty() { TextBox box; KeyEventArgs args; box = new TextBox { Text = "" }; ClearOnEscape.SetEnabled(box, true); args = SendKeyDown(box, Key.Return); Assert.False(args.Handled); Assert.Equal("", box.Text); }
public void ClearsTextAndHandledEventWhenTextIsNotEmpty() { TextBox box; KeyEventArgs args; box = new TextBox { Text = "test" }; ClearOnEscape.SetEnabled(box, true); args = SendKeyDown(box, Key.Escape); Assert.True(args.Handled); Assert.Equal("", box.Text); }
public void DoesNotHandleEventWhenPropertyIsDisabled() { TextBox box; KeyEventArgs args; box = new TextBox { Text = "test" }; // Enable the property first. ClearOnEscape.SetEnabled(box, true); // Now disable the property and send the key press. ClearOnEscape.SetEnabled(box, false); args = SendKeyDown(box, Key.Return); Assert.False(args.Handled); Assert.Equal("test", box.Text); }