@@ -87,6 +87,38 @@ public void OptionalOfShouldProduceExpectedResultForExplicitNonDefaultValues()
87
87
Assert . Equal ( "abc" , text ) ;
88
88
}
89
89
90
+ [ Fact ( DisplayName = "Optional.Of should produce the expected result for null nullable struct values." ) ]
91
+ public void OptionalOfShouldProduceExpectedResultForNullNullableStructValues ( )
92
+ {
93
+ // Given / When
94
+ Optional < int > number = Optional < int > . Of ( ( int ? ) null ) ;
95
+ Optional < Guid > identifier = Optional < Guid > . Of ( ( Guid ? ) default ) ;
96
+
97
+ // Then
98
+ Assert . False ( number . HasValue ) ;
99
+ Assert . IsType < None < int > > ( number ) ;
100
+
101
+ Assert . False ( identifier . HasValue ) ;
102
+ Assert . IsType < None < Guid > > ( identifier ) ;
103
+ }
104
+
105
+ [ Fact ( DisplayName = "Optional.Of should produce the expected result for non-null nullable struct values." ) ]
106
+ public void OptionalOfShouldProduceExpectedResultForNonNullNullableStructValues ( )
107
+ {
108
+ // Given / When
109
+ Optional < int > number = Optional < int > . Of ( ( int ? ) 123 ) ;
110
+ Optional < Guid > identifier = Optional < Guid > . Of ( ( Guid ? ) Guid . Empty ) ;
111
+
112
+ // Then
113
+ Assert . True ( number . HasValue ) ;
114
+ Assert . IsType < Some < int > > ( number ) ;
115
+ Assert . Equal ( 123 , number ) ;
116
+
117
+ Assert . True ( identifier . HasValue ) ;
118
+ Assert . IsType < Some < Guid > > ( identifier ) ;
119
+ Assert . Equal ( Guid . Empty , identifier ) ;
120
+ }
121
+
90
122
[ Fact ( DisplayName = "Optional.Some should produce the expected result." ) ]
91
123
public void OptionalSomeShouldProduceExpectedResult ( )
92
124
{
0 commit comments