File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
src/Controls/tests/Core.UnitTests Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ #if NET6_0_OR_GREATER
2+
3+ namespace Microsoft . Maui . Controls . Core . UnitTests ;
4+
5+ using System ;
6+ using System . Globalization ;
7+ using Xunit ;
8+
9+ public class DateOnlyTypeConverterTests : BaseTestFixture
10+ {
11+ [ Fact ]
12+ public void TestSucceeds ( )
13+ {
14+ var converter = new DateOnlyToDateTimeConverter ( ) ;
15+
16+ var dateOnlyValue = new DateOnly ( 2025 , 2 , 21 ) ;
17+
18+ var actualDateTime = converter . ConvertFromInvariantString ( dateOnlyValue . ToString ( CultureInfo . InvariantCulture ) ) ;
19+ var expectedDateTime = new DateTime ( 2025 , 2 , 21 ) ;
20+
21+ Assert . Equal ( expectedDateTime , actualDateTime ) ;
22+ }
23+
24+ [ Fact ]
25+ public void TestConvertToInvariantStringThrowsNotSupportedException ( )
26+ {
27+ var converter = new DateOnlyToDateTimeConverter ( ) ;
28+
29+ var stringValue = "Not a DateOnly string" ;
30+
31+ Assert . Throws < NotSupportedException > ( ( ) => converter . ConvertToInvariantString ( stringValue ) ) ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ #if NET6_0_OR_GREATER
2+
3+ namespace Microsoft . Maui . Controls . Core . UnitTests ;
4+
5+ using System ;
6+ using System . Globalization ;
7+ using Xunit ;
8+
9+ public class TimeOnlyTypeConverterTests : BaseTestFixture
10+ {
11+ [ Fact ]
12+ public void TestSucceeds ( )
13+ {
14+ var converter = new TimeOnlyToTimeSpanConverter ( ) ;
15+
16+ var timeOnlyValue = new TimeOnly ( 8 , 30 , 0 ) ;
17+
18+ var actualTimeSpan = converter . ConvertFromInvariantString ( timeOnlyValue . ToString ( CultureInfo . InvariantCulture ) ) ;
19+ var expectedTimeSpan = new TimeSpan ( 8 , 30 , 0 ) ;
20+
21+ Assert . Equal ( expectedTimeSpan , actualTimeSpan ) ;
22+ }
23+
24+ [ Fact ]
25+ public void TestConvertToInvariantStringThrowsNotSupportedException ( )
26+ {
27+ var converter = new TimeOnlyToTimeSpanConverter ( ) ;
28+
29+ var stringValue = "Not a DateOnly string" ;
30+
31+ Assert . Throws < NotSupportedException > ( ( ) => converter . ConvertToInvariantString ( stringValue ) ) ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments