Exemplo n.º 1
0
        public void ActorGraphInterpreter_should_be_able_to_interpret_a_simple_bidi_stage()
        {
            this.AssertAllStagesStopped(() =>
            {
                var identityBidi = new IdentityBidiGraphStage();
                var identity     = BidiFlow.FromGraph(identityBidi).Join(Flow.Identity <int>().Select(x => x));

                var task = Source.From(Enumerable.Range(1, 10))
                           .Via(identity)
                           .Grouped(100)
                           .RunWith(Sink.First <IEnumerable <int> >(), Materializer);

                task.AwaitResult().Should().Equal(Enumerable.Range(1, 10));
            }, Materializer);
        }
        public void ActorGraphInterpreter_should_be_able_to_interpret_and_reuse_a_simple_bidi_stage()
        {
            this.AssertAllStagesStopped(() =>
            {
                var identityBidi     = new IdentityBidiGraphStage();
                var identityBidiFlow = BidiFlow.FromGraph(identityBidi);
                var identity         = identityBidiFlow.Atop(identityBidiFlow).Atop(identityBidiFlow).Join(Flow.Identity <int>().Select(x => x));

                var task = Source.From(Enumerable.Range(1, 10))
                           .Via(identity)
                           .Grouped(100)
                           .RunWith(Sink.First <IEnumerable <int> >(), _materializer);

                task.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
                task.Result.Should().Equal(Enumerable.Range(1, 10));
            }, _materializer);
        }