public void The_task_should_be_able_to_run_asynchronously() { ContentLoader loader = new ContentLoader(); ManualResetEvent _completed = new ManualResetEvent(false); IAsyncResult asyncResult = AsyncExecutor.RunAsync(loader.Load, () => _completed.Set()); Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(10.Seconds(), true), "No response from the executor"); Assert.IsTrue(_completed.WaitOne(0, true), "Should have completed by now"); Trace.WriteLine("Content Length: " + loader.TotalBytesRead); }
public void The_task_should_run_synchronously() { ContentLoader loader = new ContentLoader(); AsyncExecutor.Run(loader.Load); Assert.IsTrue(loader.Completed); Trace.WriteLine("Content Length: " + loader.TotalBytesRead); }