Skip to content

Instantly share code, notes, and snippets.

@puschie286
Created November 25, 2025 08:02
Show Gist options
  • Select an option

  • Save puschie286/5cd4483c04ffb628adb0a480d19cb977 to your computer and use it in GitHub Desktop.

Select an option

Save puschie286/5cd4483c04ffb628adb0a480d19cb977 to your computer and use it in GitHub Desktop.
Shouldly Task Extension
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