public void errors_cause_all_subscriptions_to_be_removed() { var subjectA = new StatsSubject <int>(); var subjectB = new StatsSubject <int>(); var subjectC = new StatsSubject <int>(); var subjectD = new StatsSubject <int>(); var stats = new StatsSubject <string>(); Observable.Join( subjectA.And(subjectB).Then((x, y) => String.Concat(x.ToString(), ",", y.ToString())), subjectC.And(subjectD).Then((x, y) => String.Concat(x.ToString(), ",", y.ToString())) ) .Subscribe(stats); Assert.AreEqual(1, subjectA.SubscriptionCount); Assert.AreEqual(1, subjectB.SubscriptionCount); Assert.AreEqual(1, subjectC.SubscriptionCount); Assert.AreEqual(1, subjectD.SubscriptionCount); subjectA.OnError(new Exception()); Assert.AreEqual(0, subjectA.SubscriptionCount); Assert.AreEqual(0, subjectB.SubscriptionCount); Assert.AreEqual(0, subjectC.SubscriptionCount); Assert.AreEqual(0, subjectD.SubscriptionCount); }
public void error_is_fired_on_error_from_either_source() { StatsSubject <int> subjectA = new StatsSubject <int>(); StatsSubject <int> subjectB = new StatsSubject <int>(); var stats = new StatsObserver <string>(); subjectA.CombineLatest(subjectB, (a, b) => String.Concat(a.ToString(), ",", b.ToString())) .Subscribe(stats); subjectA.OnError(new Exception()); Assert.IsTrue(stats.ErrorCalled); }
public void error_is_fired_on_error_from_either_source() { StatsSubject<int> subjectA = new StatsSubject<int>(); StatsSubject<int> subjectB = new StatsSubject<int>(); var stats = new StatsObserver<string>(); subjectA.CombineLatest(subjectB, (a, b) => String.Concat(a.ToString(), ",", b.ToString())) .Subscribe(stats); subjectA.OnError(new Exception()); Assert.IsTrue(stats.ErrorCalled); }
public void unsubscribes_from_both_sequences_on_error() { StatsSubject <int> subjectA = new StatsSubject <int>(); StatsSubject <int> subjectB = new StatsSubject <int>(); var stats = new StatsObserver <string>(); subjectA.CombineLatest(subjectB, (a, b) => String.Concat(a.ToString(), ",", b.ToString())) .Subscribe(stats); subjectA.OnError(new Exception()); Assert.AreEqual(0, subjectA.SubscriptionCount); Assert.AreEqual(0, subjectB.SubscriptionCount); }
public void errors_cause_unsubscription_of_everything() { var subject = new StatsSubject<int>(); var statsA = new StatsObserver<int>(); var statsB = new StatsObserver<int>(); var refCount = subject.Publish().RefCount(); var subscriptionA = refCount.Subscribe(statsA); var subscriptionB = refCount.Subscribe(statsB); subject.OnError(new Exception()); Assert.AreEqual(1, statsA.ErrorCount); Assert.AreEqual(1, statsB.ErrorCount); Assert.AreEqual(0, subject.SubscriptionCount); }
public void errors_cause_unsubscription_of_everything() { var subject = new StatsSubject <int>(); var statsA = new StatsObserver <int>(); var statsB = new StatsObserver <int>(); var refCount = subject.Publish().RefCount(); var subscriptionA = refCount.Subscribe(statsA); var subscriptionB = refCount.Subscribe(statsB); subject.OnError(new Exception()); Assert.AreEqual(1, statsA.ErrorCount); Assert.AreEqual(1, statsB.ErrorCount); Assert.AreEqual(0, subject.SubscriptionCount); }
public void values_send_before_completion_are_ignored() { StatsObserver <int> stats = new StatsObserver <int>(); StatsSubject <int> source = new StatsSubject <int>(); StatsSubject <int> subject = new StatsSubject <int>(); ConnectableObservable <int> connectable = new ConnectableObservable <int>(source, subject); var sub = connectable.Subscribe(stats); source.OnNext(0); source.OnCompleted(); source.OnError(new Exception()); Assert.IsFalse(stats.NextCalled); Assert.IsFalse(stats.CompletedCalled); Assert.IsFalse(stats.ErrorCalled); }
public void errors_cause_all_subscriptions_to_be_removed() { var subjectA = new StatsSubject<int>(); var subjectB = new StatsSubject<int>(); var subjectC = new StatsSubject<int>(); var subjectD = new StatsSubject<int>(); var stats = new StatsSubject<string>(); Observable.Join( subjectA.And(subjectB).Then((x, y) => String.Concat(x.ToString(), ",", y.ToString())), subjectC.And(subjectD).Then((x, y) => String.Concat(x.ToString(), ",", y.ToString())) ) .Subscribe(stats); Assert.AreEqual(1, subjectA.SubscriptionCount); Assert.AreEqual(1, subjectB.SubscriptionCount); Assert.AreEqual(1, subjectC.SubscriptionCount); Assert.AreEqual(1, subjectD.SubscriptionCount); subjectA.OnError(new Exception()); Assert.AreEqual(0, subjectA.SubscriptionCount); Assert.AreEqual(0, subjectB.SubscriptionCount); Assert.AreEqual(0, subjectC.SubscriptionCount); Assert.AreEqual(0, subjectD.SubscriptionCount); }
public void values_send_before_completion_are_ignored() { StatsObserver<int> stats = new StatsObserver<int>(); StatsSubject<int> source = new StatsSubject<int>(); StatsSubject<int> subject = new StatsSubject<int>(); ConnectableObservable<int> connectable = new ConnectableObservable<int>(source, subject); var sub = connectable.Subscribe(stats); source.OnNext(0); source.OnCompleted(); source.OnError(new Exception()); Assert.IsFalse(stats.NextCalled); Assert.IsFalse(stats.CompletedCalled); Assert.IsFalse(stats.ErrorCalled); }
public void unsubscribes_from_both_sequences_on_error() { StatsSubject<int> subjectA = new StatsSubject<int>(); StatsSubject<int> subjectB = new StatsSubject<int>(); var stats = new StatsObserver<string>(); subjectA.CombineLatest(subjectB, (a, b) => String.Concat(a.ToString(), ",", b.ToString())) .Subscribe(stats); subjectA.OnError(new Exception()); Assert.AreEqual(0, subjectA.SubscriptionCount); Assert.AreEqual(0, subjectB.SubscriptionCount); }