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


C# TestLatch.Open方法代码示例

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


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

示例1: Router_in_general_must_use_specified_resizer_when_resizer_not_configured

        public void Router_in_general_must_use_specified_resizer_when_resizer_not_configured()
        {
            var latch = new TestLatch(1);
            var resizer = new TestResizer(latch);
            var router =
                Sys.ActorOf(
                    Props.Create<BlackHoleActor>()
                        .WithRouter(new RoundRobinPool(0, resizer, SupervisorStrategy.DefaultStrategy, null)));
            latch.Open();
            router.Tell(new GetRoutees(),TestActor);
            ExpectMsg<Routees>().Members.Count().ShouldBe(2);
            Sys.Stop(router);

        }             
开发者ID:rogeralsing,项目名称:akka.net,代码行数:14,代码来源:RoutingSpec.cs

示例2: Router_in_general_must_not_terminate_when_resizer_is_used

        public void Router_in_general_must_not_terminate_when_resizer_is_used()
        {
            var latch = new TestLatch(1);
            var resizer = new TestResizer(latch);
            var router =
                Sys.ActorOf(new RoundRobinPool( 0, resizer,SupervisorStrategy.DefaultStrategy,null).Props(Props.Create<BlackHoleActor>()));

            Watch(router);

            latch.Open();
            //Await.ready(latch, remainingOrDefault); //TODO: what is remainingOrDefault
            
            router.Tell(new GetRoutees(),TestActor);
            var routees = ExpectMsg<Routees>().Members.ToList();

            routees.Count().ShouldBe(2);
            routees.ForEach(r => r.Send(PoisonPill.Instance,TestActor));
            // expect no Terminated
            ExpectNoMsg(TimeSpan.FromSeconds(2));
        }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:20,代码来源:RoutingSpec.cs

示例3: SlaveActor

            public SlaveActor(TestLatch restartLatch, TestLatch hasMsgLatch, string expectedUnstashedMessage)
            {
                _restartLatch = restartLatch;
                Receive("crash", _ => { throw new Exception("Received \"crash\""); });

                // when restartLatch is not yet open, stash all messages != "crash"                
                Receive<object>(_ => !restartLatch.IsOpen, m => Stash.Stash());

                // when restartLatch is open, must receive the unstashed message
                Receive(expectedUnstashedMessage, _ => hasMsgLatch.Open());
            }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:11,代码来源:ActorWithStashSpec.cs

示例4: Conflate_must_restart_when_aggregate_throws_and_a_ResumingDecider_is_used

        public void Conflate_must_restart_when_aggregate_throws_and_a_ResumingDecider_is_used()
        {
            var sourceProbe = this.CreatePublisherProbe<int>();
            var sinkProbe = this.CreateManualSubscriberProbe<List<int>>();
            var saw4Latch = new TestLatch();

            var graph = Source.FromPublisher(sourceProbe).ConflateWithSeed(i => new List<int> { i },
                (state, elem) =>
                {
                    if (elem == 2)
                        throw new TestException("three is a four letter word");

                    if (elem == 4)
                        saw4Latch.Open();

                    state.Add(elem);
                    return state;
                })
                .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider))
                .To(Sink.FromSubscriber(sinkProbe))
                .WithAttributes(Attributes.CreateInputBuffer(1, 1));
            RunnableGraph.FromGraph(graph).Run(Materializer);

            var sub = sourceProbe.ExpectSubscription();
            var sinkSub = sinkProbe.ExpectSubscription();

            // push the first three values, the third will trigger
            // the exception
            sub.ExpectRequest(1);
            sub.SendNext(1);

            // causing the 1 to get thrown away
            sub.ExpectRequest(1);
            sub.SendNext(2);

            sub.ExpectRequest(1);
            sub.SendNext(3);

            sub.ExpectRequest(1);
            sub.SendNext(4);

            // and consume it, so that the next element
            // will trigger seed
            saw4Latch.Ready(TimeSpan.FromSeconds(3));
            sinkSub.Request(1);

            sinkProbe.ExpectNext().ShouldAllBeEquivalentTo(new [] {1, 3, 4});
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:48,代码来源:FlowConflateSpec.cs

示例5: Conflate_must_restart_when_aggregate_throws_and_a_RestartingDecider_is_used

        public void Conflate_must_restart_when_aggregate_throws_and_a_RestartingDecider_is_used()
        {
            var sourceProbe = this.CreatePublisherProbe<string>();
            var sinkProbe = this.CreateSubscriberProbe<string>();
            var latch = new TestLatch();

            var conflate = Flow.Create<string>().ConflateWithSeed(i => i, (state, elem) =>
            {
                if (elem == "two")
                {
                    latch.Open();
                    throw new TestException("two is a three letter word");
                }

                return state + elem;
            }).WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider));

            var graph = Source.FromPublisher(sourceProbe)
                .Via(conflate)
                .To(Sink.FromSubscriber(sinkProbe))
                .WithAttributes(Attributes.CreateInputBuffer(4, 4));
            RunnableGraph.FromGraph(graph).Run(Materializer);

            var sub = sourceProbe.ExpectSubscription();

            sub.ExpectRequest(4);
            sub.SendNext("one");
            sub.SendNext("two");
            sub.SendNext("three");
            sub.SendComplete();

            //"one" should be lost
            latch.Ready(TimeSpan.FromSeconds(3));
            sinkProbe.RequestNext("three");
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:35,代码来源:FlowConflateSpec.cs

示例6: Conflate_must_restart_when_seed_throws_and_a_RestartDescider_is_used

        public void Conflate_must_restart_when_seed_throws_and_a_RestartDescider_is_used()
        {
            var sourceProbe = this.CreatePublisherProbe<int>();
            var sinkProbe = this.CreateManualSubscriberProbe<int>();
            var exceptionlath = new TestLatch();

            var graph = Source.FromPublisher(sourceProbe).ConflateWithSeed(i =>
            {
                if (i%2 == 0)
                {
                    exceptionlath.Open();
                    throw new TestException("I hate even seed numbers");
                }
                return i;
            }, (sum, i) => sum + i)
                .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider))
                .To(Sink.FromSubscriber(sinkProbe))
                .WithAttributes(Attributes.CreateInputBuffer(1, 1));
            RunnableGraph.FromGraph(graph).Run(Materializer);

            var sub = sourceProbe.ExpectSubscription();
            var sinkSub = sinkProbe.ExpectSubscription();

            // push the first value
            sub.ExpectRequest(1);
            sub.SendNext(1);

            // and consume it, so that the next element
            // will trigger seed
            sinkSub.Request(1);
            sinkProbe.ExpectNext(1);

            sub.ExpectRequest(1);
            sub.SendNext(2);

            // make sure the seed exception happened
            // before going any further
            exceptionlath.Ready(TimeSpan.FromSeconds(3));

            sub.ExpectRequest(1);
            sub.SendNext(3);

            // now we should have lost the 2 and the accumulated state
            sinkSub.Request(1);
            sinkProbe.ExpectNext(3);
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:46,代码来源:FlowConflateSpec.cs


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