public void WaitForAsyncResultCompletion_DoesNothingIfResultAlreadyCompleted() { // Arrange MockAsyncResult asyncResult = new MockAsyncResult() { IsCompleted = true }; // Act AsyncUtil.WaitForAsyncResultCompletion(asyncResult, null /* app */); // Assert // If we reached this point of execution, the operation completed }
public void WaitForAsyncResultCompletion_WaitsOnWaitHandleIfAvailable() { // Arrange MockAsyncResult asyncResult = new MockAsyncResult() { IsCompleted = false }; HttpApplication app = new HttpApplication(); Timer timer = new Timer(_ => { lock (app) { asyncResult.IsCompleted = true; asyncResult.AsyncWaitHandle.Set(); } }, null, 1000, Timeout.Infinite); // Act lock (app) { AsyncUtil.WaitForAsyncResultCompletion(asyncResult, app); } }