Skip to content

Commit 4f36a5b

Browse files
committed
#112 tests: Where_ArgumentNullException()
1 parent affa311 commit 4f36a5b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Neomaster.JsonToLinq.UnitTests/Application/JsonLinqUnitTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)