@@ -199,6 +199,32 @@ public static IEnumerable<object[]> TestValues()
199
199
yield return new object [ ] { "None" , Option < MyEnum > . None ( ) } ;
200
200
}
201
201
202
+ [ Theory ]
203
+ [ MemberData ( nameof ( WhereTestValues ) ) ]
204
+ public void WhereFiltersOptionCorrectly ( Option < string > expectedResult , Option < string > input , Func < string , bool > predicate )
205
+ {
206
+ Assert . Equal ( expectedResult , input . Where ( predicate ) ) ;
207
+ }
208
+
209
+ [ Theory ]
210
+ [ MemberData ( nameof ( WhereTestValues ) ) ]
211
+ public void OptionSupportsLinqWhereSyntax ( Option < string > expectedResult , Option < string > input , Func < string , bool > predicate )
212
+ {
213
+ var result = from x in input
214
+ where predicate ( x )
215
+ select x ;
216
+ Assert . Equal ( expectedResult , result ) ;
217
+ }
218
+
219
+ public static TheoryData < Option < string > , Option < string > , Func < string , bool > > WhereTestValues ( )
220
+ => new TheoryData < Option < string > , Option < string > , Func < string , bool > >
221
+ {
222
+ { Option . Some ( "foo" ) , Option . Some ( "foo" ) , True } ,
223
+ { Option < string > . None ( ) , Option . Some ( "foo" ) , False } ,
224
+ { Option < string > . None ( ) , Option < string > . None ( ) , True } ,
225
+ { Option < string > . None ( ) , Option < string > . None ( ) , False } ,
226
+ } ;
227
+
202
228
[ Theory ]
203
229
[ MemberData ( nameof ( TestValues ) ) ]
204
230
0 commit comments