public void No_Combinations_Complete_After_All() { var us1 = new UnicastSubject <int>(); var us2 = new UnicastSubject <int>(); var to = ReactiveExtensions.CombineLatest(a => { int v = 0; foreach (var e in a) { v += e; } return(v); }, us1, us2).Test(); to.AssertEmpty(); us1.OnCompleted(); Assert.True(us2.HasObserver(), "Other source disposed?"); us2.EmitAll(1, 2, 3, 4, 5); to.AssertResult(); }
public void Switch_Outer_Completes_First() { var source = new Subject <IObservable <int> >(); var to = source.SwitchMany().Test(); to.AssertEmpty(); var us1 = new UnicastSubject <int>(); source.OnNext(us1); Assert.True(us1.HasObserver()); var us2 = new UnicastSubject <int>(); source.OnNext(us2); Assert.True(us2.HasObserver()); Assert.False(us1.HasObserver()); source.OnCompleted(); Assert.True(us2.HasObserver()); to.AssertEmpty(); us2.EmitAll(1, 2, 3, 4, 5); to.AssertResult(1, 2, 3, 4, 5); }
public void Error_Delayed() { var us1 = new UnicastSubject <int>(); var us2 = new UnicastSubject <int>(); var to = ReactiveExtensions.CombineLatest(a => { int v = 0; foreach (var e in a) { v += e; } return(v); }, true, us1, us2).Test(); to.AssertEmpty(); us1.OnNext(1); us1.OnError(new InvalidOperationException()); Assert.True(us2.HasObserver()); us2.EmitAll(10, 20, 30, 40, 50); to.AssertFailure(typeof(InvalidOperationException), 11, 21, 31, 41, 51); }
public void Basic() { var us = new UnicastSubject <int>().ToSerialized(); var to = us.Test(); us.EmitAll(1, 2, 3, 4, 5); to.AssertResult(1, 2, 3, 4, 5); }
public void Basic() { var up = new UnicastSubject <int>(); var to = new TestObserver <int>(); up.Subscribe(ReactiveExtensions.ToSerialized(to)); up.EmitAll(1, 2, 3, 4, 5); to.AssertResult(1, 2, 3, 4, 5); }
public void Handler_Crash() { var up = new UnicastSubject <int>(); var ts = up .DoAfterNext(v => { throw new InvalidOperationException(); }) .Test(); up.EmitAll(1, 2, 3, 4, 5); ts.AssertFailure(typeof(InvalidOperationException), 1); Assert.False(up.HasObserver()); }
public void Basic_Complete() { var count = 0; var up = new UnicastSubject <int>(); var ts = up.DoFinally(() => count++).Test(); up.EmitAll(1, 2, 3, 4, 5); ts.AssertResult(1, 2, 3, 4, 5); ts.Dispose(); Assert.AreEqual(1, count); }
public void Basic_WithDelayError() { var us = new UnicastSubject <int>(); var ts = us.ObserveOn(ImmediateScheduler.INSTANCE, true).Test(); Assert.True(us.HasObserver()); ts.AssertEmpty(); us.EmitAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Assert.False(us.HasObserver()); ts.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); }
public void Basic() { var list = new List <int>(); var up = new UnicastSubject <int>(); var ts = up.Do(v => { list.Add(v); }) .DoAfterNext(v => { list.Add(-v); }) .Test(); up.EmitAll(1, 2, 3, 4, 5); ts.AssertResult(1, 2, 3, 4, 5); Assert.AreEqual(new List <int>() { 1, -1, 2, -2, 3, -3, 4, -4, 5, -5 }, list); }