public void NoValue_Cancel_Wait() { var cs = new MaybeSubject <int>(); var cts = new CancellationTokenSource(); try { Task.Factory.StartNew(() => { while (!cs.HasObserver()) { ; } Thread.Sleep(100); cts.Cancel(); }); cs .Wait(cts: cts); Assert.Fail(); } catch (OperationCanceledException) { // expected } Assert.False(cs.HasObserver()); }
public void NoValue_Timeout() { var cs = new MaybeSubject <int>(); try { cs .Wait(100); Assert.Fail(); } catch (TimeoutException) { // expected } Assert.False(cs.HasObserver()); }