public void CancelationTokenNullValueCannotBeGottenAsString1() { CancelationSource cancelationSource = CancelationSource.New(); CancelationToken cancelationToken = cancelationSource.Token; cancelationSource.Cancel(default(string)); string val; Assert.IsFalse(cancelationToken.TryGetCancelationValueAs(out val)); cancelationSource.Dispose(); TestHelper.Cleanup(); }
public void CancelationTokenStringValueCanBeGottenAsString() { CancelationSource cancelationSource = CancelationSource.New(); CancelationToken cancelationToken = cancelationSource.Token; cancelationSource.Cancel("Cancel"); string val; Assert.IsTrue(cancelationToken.TryGetCancelationValueAs(out val)); cancelationSource.Dispose(); TestHelper.Cleanup(); }
public void CancelationTokenInvalidOperations() { CancelationToken cancelationToken = new CancelationToken(); Assert.Throws <InvalidOperationException>(() => { var _ = cancelationToken.CancelationValue; }); Assert.Throws <InvalidOperationException>(() => { var _ = cancelationToken.CancelationValueType; }); Assert.Throws <InvalidOperationException>(() => { cancelationToken.Register(_ => { }); }); Assert.Throws <InvalidOperationException>(() => { cancelationToken.Register(1, (i, _) => { }); }); Assert.Throws <InvalidOperationException>(() => { string _; cancelationToken.TryGetCancelationValueAs(out _); }); Assert.Throws <InvalidOperationException>(cancelationToken.Retain); Assert.Throws <InvalidOperationException>(cancelationToken.Release); TestHelper.Cleanup(); }