1
- using System ;
1
+ using System ;
2
2
using System . Collections . Generic ;
3
+ using System . ComponentModel ;
3
4
using System . Globalization ;
4
5
using System . Windows ;
5
6
using System . Windows . Controls ;
@@ -19,6 +20,17 @@ public TimePickerUnitTests()
19
20
_timePicker . ApplyDefaultStyle ( ) ;
20
21
}
21
22
23
+ [ StaFact ]
24
+ [ Description ( "Issue 1691" ) ]
25
+ public void DontOverwriteDate ( )
26
+ {
27
+ var expectedDate = new DateTime ( 2000 , 1 , 1 , 20 , 0 , 0 ) ;
28
+
29
+ _timePicker . SelectedTime = expectedDate ;
30
+
31
+ Assert . Equal ( _timePicker . SelectedTime , expectedDate ) ;
32
+ }
33
+
22
34
[ StaTheory ]
23
35
[ MemberData ( nameof ( GetDisplaysExpectedTextData ) ) ]
24
36
public void DisplaysExpectedText ( CultureInfo culture , DatePickerFormat format , bool is24Hour , bool withSeconds ,
@@ -30,9 +42,7 @@ public void DisplaysExpectedText(CultureInfo culture, DatePickerFormat format, b
30
42
_timePicker . WithSeconds = withSeconds ;
31
43
_timePicker . SelectedTime = selectedTime ;
32
44
33
-
34
- string currentTestString = $ "{ culture . ThreeLetterISOLanguageName } { ( is24Hour ? "24 Hour" : "12 Hour" ) } { format } format { ( withSeconds ? "with seconds" : "" ) } ";
35
- Assert . True ( expectedText == _timePicker . Text , $ "Expected '{ expectedText } ' but was '{ _timePicker . Text } ' - { currentTestString } ") ;
45
+ Assert . Equal ( expectedText , _timePicker . Text ) ;
36
46
}
37
47
38
48
[ StaTheory ]
@@ -49,8 +59,7 @@ public void CanParseLocalizedTimeString(CultureInfo culture, DatePickerFormat fo
49
59
textBox . Text = timeString ;
50
60
textBox . RaiseEvent ( new RoutedEventArgs ( UIElement . LostFocusEvent ) ) ;
51
61
52
- string currentTestString = $ "{ culture . ThreeLetterISOLanguageName } { ( is24Hour ? "24 Hour" : "12 Hour" ) } { format } format { ( withSeconds ? "with seconds" : "" ) } ";
53
- Assert . True ( expectedTime == _timePicker . SelectedTime , $ "Expected '{ expectedTime } ' but was '{ _timePicker . SelectedTime } ' - { currentTestString } ") ;
62
+ Assert . Equal ( expectedTime , _timePicker . SelectedTime ) ;
54
63
}
55
64
56
65
public static IEnumerable < object [ ] > GetParseLocalizedTimeStringData ( )
@@ -65,7 +74,7 @@ public static IEnumerable<object[]> GetParseLocalizedTimeStringData()
65
74
var timeString = ( string ) data [ 5 ] ;
66
75
67
76
//Convert the date to Today
68
- date = DateTime . Today . AddHours ( date . Hour ) . AddMinutes ( date . Minute ) . AddSeconds ( withSeconds ? date . Second : 0 ) ;
77
+ date = DateTime . MinValue . AddHours ( date . Hour ) . AddMinutes ( date . Minute ) . AddSeconds ( withSeconds ? date . Second : 0 ) ;
69
78
70
79
if ( ! is24Hour && date . Hour > 12 &&
71
80
( string . IsNullOrEmpty ( culture . DateTimeFormat . AMDesignator ) ||
0 commit comments