Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixing UI tests
  • Loading branch information
Keboo committed Jun 27, 2024
commit 8f07dbf034aa32f3f2585d9305fd93a980a396b8
7 changes: 3 additions & 4 deletions src/MaterialDesignThemes.Wpf/NumericUpDown.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows.Automation.Peers;

namespace MaterialDesignThemes.Wpf;

[TemplatePart(Name = IncreaseButtonPartName, Type = typeof(RepeatButton))]
[TemplatePart(Name = DecreaseButtonPartName, Type = typeof(RepeatButton))]
[TemplatePart(Name = TextFieldBoxPartName, Type = typeof(TextBox))]
[TemplatePart(Name = TextBoxPartName, Type = typeof(TextBox))]
public class NumericUpDown : Control
{
public const string IncreaseButtonPartName = "PART_IncreaseButton";
public const string DecreaseButtonPartName = "PART_DecreaseButton";
public const string TextFieldBoxPartName = "PART_TextBox";
public const string TextBoxPartName = "PART_TextBox";

private TextBox? _textBoxField;
private RepeatButton? _decreaseButton;
Expand Down Expand Up @@ -180,7 +179,7 @@ public override void OnApplyTemplate()

_increaseButton = GetTemplateChild(IncreaseButtonPartName) as RepeatButton;
_decreaseButton = GetTemplateChild(DecreaseButtonPartName) as RepeatButton;
_textBoxField = GetTemplateChild(TextFieldBoxPartName) as TextBox;
_textBoxField = GetTemplateChild(TextBoxPartName) as TextBox;

if (_increaseButton != null)
_increaseButton.Click += IncreaseButtonOnClick;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async Task NumericButtons_IncreaseAndDecreaseValue()
""");
var plusButton = await numericUpDown.GetElement<RepeatButton>("PART_IncreaseButton");
var minusButton = await numericUpDown.GetElement<RepeatButton>("PART_DecreaseButton");
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBoxField");
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBox");

Assert.Equal("1", await textBox.GetText());
Assert.Equal(1, await numericUpDown.GetValue());
Expand Down Expand Up @@ -42,7 +42,7 @@ public async Task NumericButtons_WithMaximum_DisablesPlusButton()
""");
var plusButton = await numericUpDown.GetElement<RepeatButton>("PART_IncreaseButton");
var minusButton = await numericUpDown.GetElement<RepeatButton>("PART_DecreaseButton");
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBoxField");
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBox");

await plusButton.LeftClick();
await Wait.For(async () =>
Expand Down Expand Up @@ -73,7 +73,7 @@ public async Task NumericButtons_WithMinimum_DisablesMinusButton()
""");
var plusButton = await numericUpDown.GetElement<RepeatButton>("PART_IncreaseButton");
var minusButton = await numericUpDown.GetElement<RepeatButton>("PART_DecreaseButton");
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBoxField");
var textBox = await numericUpDown.GetElement<TextBox>("PART_TextBox");

await minusButton.LeftClick();
await Wait.For(async () =>
Expand Down