diff --git a/src/Arcus.Testing.Core/AsyncDisposable.cs b/src/Arcus.Testing.Core/AsyncDisposable.cs index fce5b99b..a7d6aa2a 100644 --- a/src/Arcus.Testing.Core/AsyncDisposable.cs +++ b/src/Arcus.Testing.Core/AsyncDisposable.cs @@ -18,6 +18,8 @@ private AsyncDisposable(Func disposeAsync) /// /// Creates an instance based on an existing synchronous . /// + /// The synchronous disposable to create as an instance. + /// Thrown when the is null. public static AsyncDisposable Create(IDisposable disposable) { if (disposable is null) @@ -31,6 +33,8 @@ public static AsyncDisposable Create(IDisposable disposable) /// /// Creates an instance based on an existing synchronous operation. /// + /// The synchronous operation to create as an instance. + /// Thrown when the is null. public static AsyncDisposable Create(Action dispose) { if (dispose is null) @@ -38,13 +42,28 @@ public static AsyncDisposable Create(Action dispose) throw new ArgumentNullException(nameof(dispose)); } - return new AsyncDisposable(() => + return Create(() => { dispose(); - return ValueTask.CompletedTask; + return Task.CompletedTask; }); } + /// + /// Creates an instance based on an existing asynchronous operation. + /// + /// The asynchronous operation to create as an instance. + /// Thrown when the is null. + public static AsyncDisposable Create(Func disposeAsync) + { + if (disposeAsync is null) + { + throw new ArgumentNullException(nameof(disposeAsync)); + } + + return new AsyncDisposable(async () => await disposeAsync()); + } + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously. ///