public void IAsyncAction_AsTask_Completed() { var action = new MockAsyncAction(); Task t = action.AsTask(); action.Status = AsyncStatus.Completed; action.Completed (action, action.Status); Assert.AreEqual (TaskStatus.RanToCompletion, t.Status); }
public void IAsyncAction_AsTask_Error() { var error = new Exception ("error"); var action = new MockAsyncAction(); Task t = action.AsTask(); action.ErrorCode = error; action.Status = AsyncStatus.Error; action.Completed (action, action.Status); Assert.IsTrue (t.IsFaulted); Assert.AreSame (error, t.Exception.InnerExceptions.First()); Assert.Throws<AggregateException>(t.Wait); }