-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated new XAMLTest library Added DeciamlUpDown tests
- Loading branch information
Showing
7 changed files
with
133 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
tests/MaterialDesignThemes.UITests/WPF/UpDownControls/DecimalUpDownTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
namespace MaterialDesignThemes.UITests.WPF.UpDownControls; | ||
|
||
public class DecimalUpDownTests(ITestOutputHelper output) : TestBase(output) | ||
{ | ||
[Fact] | ||
public async Task NumericButtons_IncreaseAndDecreaseValue() | ||
{ | ||
await using var recorder = new TestRecorder(App); | ||
|
||
var numericUpDown = await LoadXaml<DecimalUpDown>(""" | ||
<materialDesign:DecimalUpDown Value="1" /> | ||
"""); | ||
var plusButton = await numericUpDown.GetElement<RepeatButton>("PART_IncreaseButton"); | ||
var minusButton = await numericUpDown.GetElement<RepeatButton>("PART_DecreaseButton"); | ||
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBox"); | ||
|
||
Assert.Equal("1", await textBox.GetText()); | ||
Assert.Equal(1, await numericUpDown.GetValue()); | ||
|
||
await plusButton.LeftClick(); | ||
await Wait.For(async () => | ||
{ | ||
Assert.Equal("2", await textBox.GetText()); | ||
Assert.Equal(2, await numericUpDown.GetValue()); | ||
}); | ||
|
||
await minusButton.LeftClick(); | ||
await Wait.For(async () => | ||
{ | ||
Assert.Equal("1", await textBox.GetText()); | ||
Assert.Equal(1, await numericUpDown.GetValue()); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task NumericButtons_WithMaximum_DisablesPlusButton() | ||
{ | ||
await using var recorder = new TestRecorder(App); | ||
|
||
var numericUpDown = await LoadXaml<DecimalUpDown>(""" | ||
<materialDesign:DecimalUpDown Value="1" Maximum="2" /> | ||
"""); | ||
var plusButton = await numericUpDown.GetElement<RepeatButton>("PART_IncreaseButton"); | ||
var minusButton = await numericUpDown.GetElement<RepeatButton>("PART_DecreaseButton"); | ||
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBox"); | ||
|
||
await plusButton.LeftClick(); | ||
await Wait.For(async () => | ||
{ | ||
Assert.Equal("2", await textBox.GetText()); | ||
Assert.Equal(2, await numericUpDown.GetValue()); | ||
}); | ||
|
||
Assert.False(await plusButton.GetIsEnabled()); | ||
|
||
await minusButton.LeftClick(); | ||
await Wait.For(async () => | ||
{ | ||
Assert.Equal("1", await textBox.GetText()); | ||
Assert.Equal(1, await numericUpDown.GetValue()); | ||
}); | ||
|
||
Assert.True(await plusButton.GetIsEnabled()); | ||
} | ||
|
||
[Fact] | ||
public async Task NumericButtons_WithMinimum_DisablesMinusButton() | ||
{ | ||
await using var recorder = new TestRecorder(App); | ||
|
||
var numericUpDown = await LoadXaml<DecimalUpDown>(""" | ||
<materialDesign:DecimalUpDown Value="2" Minimum="1" /> | ||
"""); | ||
var plusButton = await numericUpDown.GetElement<RepeatButton>("PART_IncreaseButton"); | ||
var minusButton = await numericUpDown.GetElement<RepeatButton>("PART_DecreaseButton"); | ||
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBox"); | ||
|
||
await minusButton.LeftClick(); | ||
await Wait.For(async () => | ||
{ | ||
Assert.Equal("1", await textBox.GetText()); | ||
Assert.Equal(1, await numericUpDown.GetValue()); | ||
}); | ||
|
||
Assert.False(await minusButton.GetIsEnabled()); | ||
|
||
await plusButton.LeftClick(); | ||
await Wait.For(async () => | ||
{ | ||
Assert.Equal("2", await textBox.GetText()); | ||
Assert.Equal(2, await numericUpDown.GetValue()); | ||
}); | ||
|
||
Assert.True(await minusButton.GetIsEnabled()); | ||
} | ||
|
||
[Fact] | ||
public async Task MaxAndMinAssignments_CoerceValueToBeInRange() | ||
{ | ||
await using var recorder = new TestRecorder(App); | ||
|
||
var numericUpDown = await LoadXaml<DecimalUpDown>(""" | ||
<materialDesign:DecimalUpDown Value="2" /> | ||
"""); | ||
|
||
await numericUpDown.SetMaximum(1); | ||
Assert.Equal(1, await numericUpDown.GetValue()); | ||
|
||
await numericUpDown.SetMinimum(3); | ||
Assert.Equal(3, await numericUpDown.GetValue()); | ||
Assert.Equal(3, await numericUpDown.GetMaximum()); | ||
|
||
await numericUpDown.SetMaximum(2); | ||
Assert.Equal(3, await numericUpDown.GetValue()); | ||
Assert.Equal(3, await numericUpDown.GetMinimum()); | ||
Assert.Equal(3, await numericUpDown.GetMaximum()); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
.../WPF/NumericUpDowns/NumericUpDownTests.cs → .../WPF/UpDownControls/NumericUpDownTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters