public void IAsyncAction_AsTask_StartStatus() { var action = new MockAsyncAction(); Task t = action.AsTask(); Assert.AreEqual (TaskStatus.WaitingForActivation, t.Status); Assert.AreEqual (AsyncStatus.Started, action.Status); }
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_Canceled() { var action = new MockAsyncAction(); Task t = action.AsTask(); action.Cancel(); Assert.Throws<AggregateException>(t.Wait); Assert.AreEqual (TaskStatus.Canceled, 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); }