Skip to content

Commit 50003e0

Browse files
committed
Relaxed more constraints.
1 parent 0444c78 commit 50003e0

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/MrKWatkins.Assertions.Tests/ObjectAssertionsTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ public async Task BeNull_ValueType()
2020
await Assert.That(() => notNullValue.Should().BeNull()).Throws<AssertionException>().WithMessage("Value should be null but was 123.");
2121
}
2222

23+
[Test]
24+
public async Task BeNull_NullableValueType()
25+
{
26+
int? nullValue = null;
27+
int? notNullValue = 123;
28+
29+
await Assert.That(() => nullValue.Should().BeNull()).ThrowsNothing();
30+
await Assert.That(() => notNullValue.Should().BeNull()).Throws<AssertionException>().WithMessage("Value should be null but was 123.");
31+
}
32+
2333
[Test]
2434
public async Task NotBeNull_ReferenceType()
2535
{
@@ -38,6 +48,16 @@ public async Task NotBeNull_ValueType()
3848
await Assert.That(() => notNullValue.Should().NotBeNull()).ThrowsNothing();
3949
}
4050

51+
[Test]
52+
public async Task NotBeNull_NullableValueType()
53+
{
54+
int? nullValue = null;
55+
int? notNullValue = 123;
56+
57+
await Assert.That(() => nullValue.Should().NotBeNull()).Throws<AssertionException>().WithMessage("Value should not be null.");
58+
await Assert.That(() => notNullValue.Should().NotBeNull()).ThrowsNothing();
59+
}
60+
4161
[Test]
4262
public async Task NotBeNull_Chain()
4363
{

src/MrKWatkins.Assertions/ShouldExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ namespace MrKWatkins.Assertions;
33
public static class ShouldExtensions
44
{
55
[Pure]
6-
public static ObjectAssertions<T> Should<T>(this T? value)
7-
where T : notnull => new(value);
6+
public static ObjectAssertions<T> Should<T>(this T? value) => new(value);
87

98
[Pure]
109
public static EnumerableAssertions<IEnumerable<T>, T> Should<T>([NoEnumeration] this IEnumerable<T> value) => new(value);

0 commit comments

Comments
 (0)