Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    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);
    }