Skip to content

[60-74] PublisherSinkSpec #6608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions src/core/Akka.Streams.Tests/Dsl/PublisherSinkSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using System;
using System.Linq;
using System.Threading.Tasks;
using Akka.Streams.Dsl;
using Akka.Streams.TestKit;
using Akka.TestKit;
Expand All @@ -28,25 +29,24 @@ public PublisherSinkSpec(ITestOutputHelper helper) : base(helper)
}

[Fact]
public void A_PublisherSink_must_be_unique_when_created_twice()
public async Task A_PublisherSink_must_be_unique_when_created_twice()
{
this.AssertAllStagesStopped(() =>
{
var t =
RunnableGraph.FromGraph(
GraphDsl.Create(Sink.AsPublisher<int>(false),
Sink.AsPublisher<int>(false), Keep.Both,
(b, p1, p2) =>
{
var broadcast = b.Add(new Broadcast<int>(2));
var source =
Source.From(Enumerable.Range(0, 6))
.MapMaterializedValue(_ => default((IPublisher<int>, IPublisher<int>)));
b.From(source).To(broadcast.In);
b.From(broadcast.Out(0)).Via(Flow.Create<int>().Select(i => i * 2)).To(p1.Inlet);
b.From(broadcast.Out(1)).To(p2.Inlet);
return ClosedShape.Instance;
})).Run(Materializer);
await this.AssertAllStagesStoppedAsync(() => {
var t =
RunnableGraph.FromGraph(
GraphDsl.Create(Sink.AsPublisher<int>(false),
Sink.AsPublisher<int>(false), Keep.Both,
(b, p1, p2) =>
{
var broadcast = b.Add(new Broadcast<int>(2));
var source =
Source.From(Enumerable.Range(0, 6))
.MapMaterializedValue(_ => default((IPublisher<int>, IPublisher<int>)));
b.From(source).To(broadcast.In);
b.From(broadcast.Out(0)).Via(Flow.Create<int>().Select(i => i * 2)).To(p1.Inlet);
b.From(broadcast.Out(1)).To(p2.Inlet);
return ClosedShape.Instance;
})).Run(Materializer);

var pub1 = t.Item1;
var pub2 = t.Item2;
Expand All @@ -59,6 +59,7 @@ public void A_PublisherSink_must_be_unique_when_created_twice()

f1.Result.Should().Be(30);
f2.Result.Should().Be(15);
return Task.CompletedTask;
}, Materializer);
}

Expand Down