Skip to content

Commit

Permalink
test: Applying Width and Height of zero to TextBox
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Aug 19, 2024
1 parent 1f20ae9 commit e9a19ec
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1023,5 +1023,69 @@ public async Task When_VerticalContentAlignment_Is_Changed()
Assert.AreEqual(VerticalAlignment.Stretch, placeHolder.VerticalAlignment);
Assert.AreEqual(VerticalAlignment.Stretch, contentElement.VerticalAlignment);
}

[TestMethod]
public async Task When_Size_Zero_Fluent_Default()
{
var loaded = false;
using var styles = StyleHelper.UseFluentStyles();
var textBox = new TextBox
{
Text = "",
Width = 0,
Height = 0
};
textBox.Loaded += (s, e) => loaded = true;

WindowHelper.WindowContent = textBox;
await WindowHelper.WaitFor(() => loaded);

Assert.AreEqual(textBox.ActualWidth, textBox.MinWidth, 0.1);
Assert.AreEqual(textBox.ActualHeight, textBox.MinHeight, 0.1);
}

[TestMethod]
public async Task When_Size_Zero_Default()
{
var loaded = false;
var textBox = new TextBox
{
Text = "",
Width = 0,
Height = 0
};
textBox.Loaded += (s, e) => loaded = true;

WindowHelper.WindowContent = textBox;
await WindowHelper.WaitFor(() => loaded);

Assert.AreEqual(textBox.ActualWidth, 0);
Assert.AreEqual(textBox.ActualHeight, 0);
}

[TestMethod]
public async Task When_Size_Zero_Fluent_ComboBoxTextBoxStyle()
{
using var styles = StyleHelper.UseFluentStyles();
var loaded = false;
var style = Application.Current.Resources["ComboBoxTextBoxStyle"] as Style;

Assert.IsNotNull(style);

var textBox = new TextBox
{
Text = "",
Width = 0,
Height = 0,
Style = style
};
textBox.Loaded += (s, e) => loaded = true;

WindowHelper.WindowContent = textBox;
await WindowHelper.WaitFor(() => loaded);

Assert.AreEqual(textBox.ActualWidth, 0);
Assert.AreEqual(textBox.ActualHeight, 0);
}
}
}

0 comments on commit e9a19ec

Please sign in to comment.