Exemplo n.º 1
0
    public void UpdatesHidePropertyWhenWatermarkTextIsSet(string initialText, bool hide)
    {
        TextBox box;


        box = new TextBox {
            Text = initialText
        };

        Watermark.SetText(box, "foo");

        Assert.Equal(hide, Watermark.GetHide(box));
    }
Exemplo n.º 2
0
    public void SetsHideToTrueWhenTheTextBoxContainsWhitespace()
    {
        TextBox box;


        box = new TextBox();
        Watermark.SetText(box, "foo");

        Assert.False(Watermark.GetHide(box));

        box.Text = " ";

        Assert.True(Watermark.GetHide(box));
    }
Exemplo n.º 3
0
    public void SetsHideToFalseWhenTheTextBoxDoesNotContainText(string watermark)
    {
        TextBox box;


        box = new TextBox();
        Watermark.SetText(box, "foo");

        box.Text = "bar";

        Assert.True(Watermark.GetHide(box));

        box.Text = watermark;

        Assert.False(Watermark.GetHide(box));
    }
Exemplo n.º 4
0
    public void StopsUpdatingWhenWatermarkTextIsCleared()
    {
        TextBox box;


        box = new TextBox();
        Watermark.SetText(box, "foo");

        box.Text = "bar";
        Assert.True(Watermark.GetHide(box));

#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
        Watermark.SetText(box, null);
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.

        Assert.False(Watermark.GetHide(box));

        box.Text = "";
        Assert.False(Watermark.GetHide(box));

        box.Text = "bar";
        Assert.False(Watermark.GetHide(box));
    }