@@ -32,6 +32,8 @@ await Wait.For(async () =>
3232 Assert . Equal ( "1" , await textBox . GetText ( ) ) ;
3333 Assert . Equal ( 1 , await numericUpDown . GetValue ( ) ) ;
3434 } ) ;
35+
36+ recorder . Success ( ) ;
3537 }
3638
3739 [ Fact ]
@@ -63,6 +65,8 @@ await Wait.For(async () =>
6365 } ) ;
6466
6567 Assert . True ( await plusButton . GetIsEnabled ( ) ) ;
68+
69+ recorder . Success ( ) ;
6670 }
6771
6872 [ Fact ]
@@ -94,6 +98,8 @@ await Wait.For(async () =>
9498 } ) ;
9599
96100 Assert . True ( await minusButton . GetIsEnabled ( ) ) ;
101+
102+ recorder . Success ( ) ;
97103 }
98104
99105 [ Fact ]
@@ -116,6 +122,8 @@ public async Task MaxAndMinAssignments_CoerceValueToBeInRange()
116122 Assert . Equal ( 3 , await numericUpDown . GetValue ( ) ) ;
117123 Assert . Equal ( 3 , await numericUpDown . GetMinimum ( ) ) ;
118124 Assert . Equal ( 3 , await numericUpDown . GetMaximum ( ) ) ;
125+
126+ recorder . Success ( ) ;
119127 }
120128
121129 [ Fact ]
@@ -147,4 +155,63 @@ public async Task InternalTextBoxIsFocused_WhenGettingKeyboardFocus()
147155
148156 recorder . Success ( ) ;
149157 }
158+
159+ [ Fact ]
160+ [ Description ( "Issue 3781" ) ]
161+ public async Task IncreaseButtonClickWhenTextIsAboveMaximum_DoesNotIncreaseValue ( )
162+ {
163+ await using var recorder = new TestRecorder ( App ) ;
164+
165+ var stackPanel = await LoadXaml < StackPanel > ( """
166+ <StackPanel>
167+ <materialDesign:DecimalUpDown Minimum="-2.5" Maximum="2.5" Value="2.5" />
168+ <Button Content="AlternateFocusElement" />
169+ </StackPanel>
170+ """ ) ;
171+ var decimalUpDown = await stackPanel . GetElement < DecimalUpDown > ( ) ;
172+ var textBox = await decimalUpDown . GetElement < TextBox > ( "PART_TextBox" ) ;
173+ var plusButton = await decimalUpDown . GetElement < RepeatButton > ( "PART_IncreaseButton" ) ;
174+
175+ var button = await stackPanel . GetElement < Button > ( ) ;
176+
177+ await textBox . MoveKeyboardFocus ( ) ;
178+ await textBox . SendKeyboardInput ( $ "{ ModifierKeys . Control } { Key . A } { ModifierKeys . None } 30") ;
179+ await plusButton . LeftClick ( ) ;
180+
181+ //NB: Because the focus has not left the up down control, we don't expect the text to change
182+ Assert . Equal ( "30" , await textBox . GetText ( ) ) ;
183+ Assert . Equal ( 2.5m , await decimalUpDown . GetValue ( ) ) ;
184+
185+ recorder . Success ( ) ;
186+ }
187+
188+ [ Theory ]
189+ [ Description ( "Issue 3781" ) ]
190+ [ InlineData ( "30" ) ]
191+ [ InlineData ( "abc" ) ]
192+ [ InlineData ( "2a" ) ]
193+ public async Task LostFocusWhenTextIsInvalid_RevertsToOriginalValue ( string inputText )
194+ {
195+ await using var recorder = new TestRecorder ( App ) ;
196+
197+ var stackPanel = await LoadXaml < StackPanel > ( """
198+ <StackPanel>
199+ <materialDesign:DecimalUpDown Minimum="-2.5" Maximum="2.5" Value="2.5" />
200+ <Button Content="AlternateFocusElement" />
201+ </StackPanel>
202+ """ ) ;
203+ var decimalUpDown = await stackPanel . GetElement < DecimalUpDown > ( ) ;
204+ var textBox = await decimalUpDown . GetElement < TextBox > ( "PART_TextBox" ) ;
205+
206+ var button = await stackPanel . GetElement < Button > ( ) ;
207+
208+ await textBox . MoveKeyboardFocus ( ) ;
209+ await textBox . SendKeyboardInput ( $ "{ ModifierKeys . Control } { Key . A } { ModifierKeys . None } { inputText } ") ;
210+ await button . MoveKeyboardFocus ( ) ;
211+
212+ Assert . Equal ( "2.5" , await textBox . GetText ( ) ) ;
213+ Assert . Equal ( 2.5m , await decimalUpDown . GetValue ( ) ) ;
214+
215+ recorder . Success ( ) ;
216+ }
150217}
0 commit comments