Skip to content

Commit 7d1387f

Browse files
Copilotthomhurst
andcommitted
Add missing IReadOnlySet<T>? nullability tests
Added 3 tests for IReadOnlySet<T>? to complete the test coverage for all nullable collection types supported by Assert.That(). Tests are conditionally compiled for .NET 5.0+ where IReadOnlySet<T> is available. Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
1 parent b820e3e commit 7d1387f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

TUnit.Assertions.Tests/CollectionNullabilityWarningTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,34 @@ public async Task NullableHashSet_WithNullValue_IsNull_Passes()
215215
await Assert.That(set).IsNull();
216216
}
217217

218+
#if NET5_0_OR_GREATER
219+
// ===================================
220+
// IReadOnlySet<T>? Tests
221+
// ===================================
222+
223+
[Test]
224+
public async Task NullableIReadOnlySet_AcceptsNullableValue_NoWarning()
225+
{
226+
IReadOnlySet<string>? set = new HashSet<string> { "a", "b", "c" };
227+
await Assert.That(set).IsNotNull();
228+
}
229+
230+
[Test]
231+
public async Task NullableIReadOnlySet_WithNullValue_IsNotNull_Fails()
232+
{
233+
IReadOnlySet<string>? set = null;
234+
var action = async () => await Assert.That(set).IsNotNull();
235+
await Assert.That(action).Throws<AssertionException>();
236+
}
237+
238+
[Test]
239+
public async Task NullableIReadOnlySet_WithNullValue_IsNull_Passes()
240+
{
241+
IReadOnlySet<string>? set = null;
242+
await Assert.That(set).IsNull();
243+
}
244+
#endif
245+
218246
// ===================================
219247
// IReadOnlyList<T>? Tests
220248
// ===================================

0 commit comments

Comments
 (0)