File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
MrKWatkins.Assertions.Tests Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ namespace MrKWatkins.Assertions;
33public 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 ) ;
You can’t perform that action at this time.
0 commit comments