当前位置: 首页>>代码示例>>C#>>正文


C# Subject.Prune方法代码示例

本文整理汇总了C#中Subject.Prune方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.Prune方法的具体用法?C# Subject.Prune怎么用?C# Subject.Prune使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subject的用法示例。


在下文中一共展示了Subject.Prune方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: last_value_is_received_after_completed_if_any_connection_is_disposed

        public void last_value_is_received_after_completed_if_any_connection_is_disposed()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune();
            var connectionA = obs.Connect();
            var connectionB = obs.Connect();

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);

            connectionA.Dispose();

            subject.OnCompleted();

            connectionB.Dispose();

            obs.Subscribe(stats);

            Assert.IsFalse(stats.NextCalled);
            Assert.IsFalse(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:25,代码来源:PruneFixture.cs

示例2: last_value_is_not_received_before_completed

        public void last_value_is_not_received_before_completed()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune();
            var connection = obs.Connect();

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);

            obs.Subscribe(stats);

            Assert.IsFalse(stats.NextCalled);
            Assert.IsFalse(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:18,代码来源:PruneFixture.cs

示例3: last_value_is_received_after_completed_if_connected_before_completed

        public void last_value_is_received_after_completed_if_connected_before_completed()
        {
            Subject<int> subject = new Subject<int>();

            var stats= new StatsObserver<int>();

            var obs = subject.Prune();
            var connection = obs.Connect();

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            subject.OnCompleted();

            obs.Subscribe(stats);

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual(3, stats.NextValues[0]);
            Assert.IsTrue(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:20,代码来源:PruneFixture.cs

示例4: values_are_skipped_when_not_connected

        public void values_are_skipped_when_not_connected()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune();
            var connectionA = obs.Connect();

            subject.OnNext(1);
            subject.OnNext(2); // last connected value

            connectionA.Dispose();

            subject.OnNext(3); // not connected here

            var connectionB = obs.Connect();

            subject.OnCompleted();

            connectionB.Dispose();

            obs.Subscribe(stats);

            Assert.IsTrue(stats.NextCalled);
            Assert.AreEqual(2, stats.NextValues[0]);
            Assert.IsTrue(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:28,代码来源:PruneFixture.cs

示例5: value_not_received_if_not_connected_for_oncomplete

        public void value_not_received_if_not_connected_for_oncomplete()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune();
            var connectionA = obs.Connect();

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);

            connectionA.Dispose();

            subject.OnCompleted();

            var connectionB = obs.Connect();

            obs.Subscribe(stats);

            Assert.IsFalse(stats.NextCalled);
            Assert.IsFalse(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:24,代码来源:PruneFixture.cs

示例6: selector_is_applied_to_last_value

        public void selector_is_applied_to_last_value()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune(x => x.Take(1));

            obs.Subscribe(stats);

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            subject.OnCompleted();

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual(3, stats.NextValues[0]);
            Assert.IsTrue(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:19,代码来源:PruneFixture.cs

示例7: selector_can_be_used_to_return_multiple_values

        public void selector_can_be_used_to_return_multiple_values()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune(x => Observable.Range(0, 2));

            obs.Subscribe(stats);

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            subject.OnCompleted();

            Assert.AreEqual(2, stats.NextCount);
            Assert.AreEqual(0, stats.NextValues[0]);
            Assert.AreEqual(1, stats.NextValues[1]);
            Assert.IsTrue(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:20,代码来源:PruneFixture.cs

示例8: scheduler_is_used_to_send_values

        public void scheduler_is_used_to_send_values()
        {
            Subject<int> subject = new Subject<int>();

            var scheduler = new ManualScheduler();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune(scheduler);
            var connection = obs.Connect();

            subject.OnNext(1);
            subject.OnCompleted();

            obs.Subscribe(stats);

            scheduler.RunAll();

            Assert.IsTrue(stats.NextCalled);
            Assert.IsTrue(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:21,代码来源:PruneFixture.cs

示例9: scheduler_is_not_used_to_sent_complete

        public void scheduler_is_not_used_to_sent_complete()
        {
            Subject<int> subject = new Subject<int>();

            var scheduler = new ManualScheduler();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune(scheduler);
            var connection = obs.Connect();

            subject.OnNext(1);
            subject.OnCompleted();

            obs.Subscribe(stats);

            scheduler.RunNext(); // only run one

            Assert.IsTrue(stats.NextCalled);

            scheduler.RunNext(); // only run one

            Assert.IsTrue(stats.CompletedCalled); // complete is called anyway
        }
开发者ID:richardszalay,项目名称:raix,代码行数:24,代码来源:PruneFixture.cs

示例10: output_of_selector_is_used

        public void output_of_selector_is_used()
        {
            Subject<int> subject = new Subject<int>();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune(x => x.Select(i => i+1));

            obs.Subscribe(stats);

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            subject.OnCompleted();

            Assert.AreEqual(1, stats.NextCount);
            Assert.AreEqual(4, stats.NextValues[0]);
            Assert.IsTrue(stats.CompletedCalled);
        }
开发者ID:richardszalay,项目名称:raix,代码行数:19,代码来源:PruneFixture.cs


注:本文中的Subject.Prune方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。