public void Completes_async_and_runs_finally_after_one_step_completes_async() { OneAsyncStepWithFinallyOperation op = new OneAsyncStepWithFinallyOperation(1234); IAsyncResult result = op.Start(null, null); Assert.False(result.IsCompleted); op.Complete(null); Assert.True(result.IsCompleted); Assert.False(result.CompletedSynchronously); Assert.Equal(1234, OneAsyncStepWithFinallyOperation.End(result)); }
public void Completes_with_async_exception_and_runs_finally_after_one_step_completes_with_async_exception() { InvalidTimeZoneException expected = new InvalidTimeZoneException("Expected."); OneAsyncStepWithFinallyOperation op = new OneAsyncStepWithFinallyOperation(1234); IAsyncResult result = op.Start(null, null); Assert.False(result.IsCompleted); op.Complete(expected); Assert.True(result.IsCompleted); Assert.False(result.CompletedSynchronously); InvalidTimeZoneException actual = Assert.Throws <InvalidTimeZoneException>(() => OneAsyncStepWithFinallyOperation.End(result)); Assert.Same(expected, actual); Assert.Equal(1234, op.ResultAccessor); }