Created
November 25, 2025 08:02
-
-
Save puschie286/5cd4483c04ffb628adb0a480d19cb977 to your computer and use it in GitHub Desktop.
Shouldly Task Extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| namespace Shouldly; | |
| [DebuggerStepThrough] | |
| [ShouldlyMethods] | |
| public static class ShouldBeAsyncExtensions | |
| { | |
| public static async Task ShouldBeNull<T>( this Task<T?> actualAsync, string? customMessage = null ) | |
| where T : class | |
| { | |
| var actual = await actualAsync; | |
| actual.ShouldBeNull( customMessage ); | |
| } | |
| public static async Task ShouldBeNull<T>( this Task<T?> actualAsync, string? customMessage = null ) | |
| where T : struct | |
| { | |
| var actual = await actualAsync; | |
| actual.ShouldBeNull( customMessage ); | |
| } | |
| public static async Task<T> ShouldNotBeNull<T>( this Task<T?> actualAsync, string? customMessage = null ) | |
| where T : class | |
| { | |
| var actual = await actualAsync; | |
| return actual.ShouldNotBeNull( customMessage ); | |
| } | |
| public static async Task<T> ShouldNotBeNull<T>( this Task<T?> actualAsync, string? customMessage = null ) | |
| where T : struct | |
| { | |
| var actual = await actualAsync; | |
| return actual.ShouldNotBeNull( customMessage ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment