public void Observer_Dispose() { for (int i = 0; i < TestHelper.RACE_LOOPS; i++) { var cs = new MaybeSubject <int>(); var to = new TestObserver <int>(); var cdl = new CountdownEvent(1); Task.Factory.StartNew(() => { while (!cs.HasObserver()) { ; } to.Dispose(); cdl.Signal(); }); cs.BlockingSubscribe(to); cdl.Wait(); Assert.False(cs.HasObserver()); } }
public void Observer_Complete_Async() { for (int i = 0; i < TestHelper.RACE_LOOPS; i++) { var cs = new MaybeSubject <int>(); var to = new TestObserver <int>(); var cdl = new CountdownEvent(1); Task.Factory.StartNew(() => { while (!cs.HasObserver()) { ; } cs.OnCompleted(); }); cs.BlockingSubscribe(to); to.AssertResult(); } }
public void Action_Error_Async() { for (int i = 0; i < TestHelper.RACE_LOOPS; i++) { var cs = new MaybeSubject <int>(); var to = new TestObserver <int>(); var cdl = new CountdownEvent(1); Task.Factory.StartNew(() => { while (!cs.HasObserver()) { ; } cs.OnError(new InvalidOperationException()); }); cs.BlockingSubscribe(to.OnSuccess, to.OnError, to.OnCompleted); to.AssertFailure(typeof(InvalidOperationException)); } }