Mocking Task.Delay
<p>I have a method with the following line: <code>await Task.Delay(waitTime).ConfigureAwait(false);</code></p>

<p>I there a good strategy to avoid actually waiting the few seconds when unit testing and instead verify that we tried to wait a specific number of seconds. </p>

<p>For instance, is there a way to inject an additional parameter into my method like in this (contrived) example where I inject a mocked object of a fictitious <code>ITaskWaiter</code> interface:</p>

<pre><code>// Arrange
var mockWait = new Mock&lt;ITaskWaiter&gt;(MockBehavior.Strict);
mockWait.Setup(w =&gt; w.Delay(It.Is&lt;TimeSpan&gt;(t =&gt; t.TotalSeconds == 2)));

// Act
myObject.MyMethod(mockWait.Object);

// Assert
mockWait.Verify();
</code></pre>