File tree Expand file tree Collapse file tree
Neomaster.JsonToLinq.UnitTests/Application Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ public class JsonLinqUnitTests(ITestOutputHelper output)
2525 """ ;
2626
2727 private static readonly IReadOnlyList < User > _users ;
28+ private static readonly IReadOnlyList < User > _usersNull = null ;
29+ private static readonly IReadOnlyList < User > _usersEmpty = [ ] ;
2830 private static readonly Func < User , bool > _filterFunc ;
2931 private static readonly JsonDocument _filterJsonDocument ;
3032
@@ -59,4 +61,21 @@ public void Where()
5961 output . WriteLine ( $ "{ a . Balance } ") ;
6062 }
6163 }
64+
65+ [ Fact ]
66+ public void Where_ArgumentExceptions ( )
67+ {
68+ TestArgumentNullException ( "elements" , ( ) => _usersNull . Where ( _filterJson ) ) ;
69+ TestArgumentNullException ( "elements" , ( ) => _usersNull . Where ( _filterJsonDocument ) ) ;
70+ TestArgumentNullException ( "filter" , ( ) => _users . Where ( ( JsonDocument ) null ) ) ;
71+ TestArgumentNullException ( "filterJson" , ( ) => _users . Where ( ( string ) null ) ) ;
72+ TestArgumentNullException ( "filterJson" , ( ) => _users . Where ( string . Empty ) ) ;
73+ TestArgumentNullException ( "filterJson" , ( ) => _users . Where ( " " ) ) ;
74+ }
75+
76+ private static void TestArgumentNullException ( string expectedParamName , Action action )
77+ {
78+ var ex = Assert . Throws < ArgumentNullException > ( ( ) => action ( ) ) ;
79+ Assert . Equal ( expectedParamName , ex . ParamName ) ;
80+ }
6281}
You can’t perform that action at this time.
0 commit comments