public void ServiceCallCanceled() { var continueWith = 0; _serviceCall.ContinueWith(serviceCall => { Assert.AreEqual(_serviceCall, serviceCall); Assert.IsTrue(serviceCall.IsCanceled); continueWith++; }); Assert.AreEqual(0, continueWith); _serviceCall.Cancel(); Assert.AreEqual(1, continueWith); Assert.IsFalse(_serviceCall.IsCompleted); Assert.IsTrue(_serviceCall.IsCanceled); Assert.IsFalse(_serviceCall.IsFaulted); Assert.IsNull(_serviceCall.Result); Assert.IsNull(_serviceCall.Exception); // Check copy state. var copy = new ServiceCall(); copy.CopyState(_serviceCall); Assert.IsFalse(copy.IsCompleted); Assert.IsTrue(copy.IsCanceled); Assert.IsFalse(copy.IsFaulted); Assert.IsNull(copy.Result); Assert.IsNull(copy.Exception); }
public void ServiceCallDisposed() { _serviceCall.Dispose(); Assert.ThrowsException <ObjectDisposedException>(() => _serviceCall.SetResult("")); Assert.ThrowsException <ObjectDisposedException>(() => _serviceCall.SetException(new AppCenterException(""))); Assert.ThrowsException <ObjectDisposedException>(() => _serviceCall.ContinueWith(_ => {})); Assert.ThrowsException <ObjectDisposedException>(() => _serviceCall.CopyState(new ServiceCall())); Assert.ThrowsException <ObjectDisposedException>(() => _serviceCall.Cancel()); }