public void OnCompleteInnerFirst() { var src1 = new Subject <int>(); var src2 = new Subject <int>(); var src3 = new Subject <int>(); var src = new ListBehaviorSubject <IObservable <int> >(); var list = new List <int>(); bool completed = false; var sub = src.Switch().Subscribe(change => change.Apply(list), () => completed = true); src.OnAdd(src1); src.OnAdd(src2); src.OnAdd(src3); src1.OnCompleted(); Assert.IsFalse(completed); src3.OnCompleted(); Assert.IsFalse(completed); src2.OnCompleted(); Assert.IsFalse(completed); src.OnCompleted(); Assert.IsTrue(completed); sub.Dispose(); }
public void OnInnerError() { var src1 = new Subject <int>(); var src2 = new Subject <int>(); var src3 = new Subject <int>(); var src = new ListBehaviorSubject <IObservable <int> >(); var list = new List <int>(); Exception error = null; var sub = src.Switch().Subscribe(change => change.Apply(list), e => error = e); CollectionAssert.IsEmpty(list); src.OnAdd(src1); src.OnAdd(src2); src.OnAdd(src3); var ex = new Exception("AAAAAAAaa"); src2.OnError(ex); Assert.AreEqual(ex, error); sub.Dispose(); }
public void Basics() { var src1 = new Subject <int>(); var src2 = new Subject <int>(); var src3 = new Subject <int>(); var src = new ListBehaviorSubject <IObservable <int> >(); var list = new List <int>(); var sub = src.Switch().Subscribe(change => change.Apply(list)); CollectionAssert.IsEmpty(list); src.OnAdd(src1); src.OnAdd(src2); src.OnAdd(src3); CollectionAssert.IsEmpty(list); src1.OnNext(1); CollectionAssert.AreEqual(new[] { 1 }, list); src3.OnNext(3); CollectionAssert.AreEqual(new[] { 1, 3 }, list); src2.OnNext(2); CollectionAssert.AreEqual(new[] { 1, 2, 3 }, list); src1.OnNext(11); src2.OnNext(22); src3.OnNext(33); CollectionAssert.AreEqual(new[] { 11, 22, 33 }, list); src.OnRemove(1); CollectionAssert.AreEqual(new[] { 11, 33 }, list); src.OnReplace(1, src2); CollectionAssert.AreEqual(new[] { 11 }, list); src2.OnNext(22); CollectionAssert.AreEqual(new[] { 11, 22 }, list); src.OnClear(); CollectionAssert.IsEmpty(list); sub.Dispose(); }