Beispiel #1
0
        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);
        }
Beispiel #3
0
        public void subscribes_to_both_sources()
        {
            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);

            Assert.AreEqual(1, subjectA.SubscriptionCount);
            Assert.AreEqual(1, subjectB.SubscriptionCount);
            Assert.IsFalse(stats.CompletedCalled);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        public void emits_combinations_of_the_latest_values()
        {
            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.OnNext(1);
            subjectB.OnNext(2);

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.IsFalse(stats.CompletedCalled);
        }
        public void emits_combinations_of_the_latest_values()
        {
            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.OnNext(1);
            subjectB.OnNext(2);

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.IsFalse(stats.CompletedCalled);
        }
Beispiel #7
0
        public void complete_is_fired_when_both_sequences_complete()
        {
            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.OnNext(1);
            subjectA.OnCompleted();

            subjectB.OnNext(2);
            subjectB.OnCompleted();

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.IsTrue(stats.CompletedCalled);
        }
        public void complete_is_fired_when_both_sequences_complete()
        {
            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.OnNext(1);
            subjectA.OnCompleted();

            subjectB.OnNext(2);
            subjectB.OnCompleted();

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.IsTrue(stats.CompletedCalled);
        }
Beispiel #9
0
        public void last_value_is_still_used_after_complete()
        {
            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.OnNext(1);
            subjectA.OnCompleted();

            subjectB.OnNext(2);
            subjectB.OnNext(3);

            Assert.AreEqual(2, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.AreEqual("1,3", stats.NextValues[1]);
            Assert.IsFalse(stats.CompletedCalled);
        }
Beispiel #10
0
        public void reuses_values()
        {
            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.OnNext(1);
            subjectB.OnNext(2);
            subjectA.OnNext(3);
            subjectB.OnNext(4);

            Assert.AreEqual(3, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.AreEqual("3,2", stats.NextValues[1]);
            Assert.AreEqual("3,4", stats.NextValues[2]);
            Assert.IsFalse(stats.CompletedCalled);
        }
        public void last_value_is_still_used_after_complete()
        {
            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.OnNext(1);
            subjectA.OnCompleted();

            subjectB.OnNext(2);
            subjectB.OnNext(3);

            Assert.AreEqual(2, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.AreEqual("1,3", stats.NextValues[1]);
            Assert.IsFalse(stats.CompletedCalled);
        }
        public void unsubscribes_from_both_sequences_when_complete()
        {
            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.OnCompleted();
            subjectB.OnCompleted();

            Assert.AreEqual(0, subjectA.SubscriptionCount);
            Assert.AreEqual(0, subjectB.SubscriptionCount);
        }
        public void subscribes_to_both_sources()
        {
            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);

            Assert.AreEqual(1, subjectA.SubscriptionCount);
            Assert.AreEqual(1, subjectB.SubscriptionCount);
            Assert.IsFalse(stats.CompletedCalled);
        }
        public void reuses_values()
        {
            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.OnNext(1);
            subjectB.OnNext(2);
            subjectA.OnNext(3);
            subjectB.OnNext(4);

            Assert.AreEqual(3, stats.NextCount);
            Assert.AreEqual("1,2", stats.NextValues[0]);
            Assert.AreEqual("3,2", stats.NextValues[1]);
            Assert.AreEqual("3,4", stats.NextValues[2]);
            Assert.IsFalse(stats.CompletedCalled);
        }