Skip to content
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

[Async TestKit] Convert Akka.Streams.Tests to async - BugSpec #5915

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
10 changes: 6 additions & 4 deletions src/core/Akka.Streams.Tests/BugSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
using System.Threading.Tasks;
using Akka.IO;
using Akka.Streams.Dsl;
using Akka.Streams.IO;
using Akka.TestKit;
using Akka.TestKit.Extensions;
using FluentAssertions;
using FluentAssertions.Extensions;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -36,7 +38,7 @@ public async Task Issue_4580_EmptyByteStringCausesPipeToBeClosed()
var serverPipeConnectionTask = serverPipe.WaitForConnectionAsync();

var clientPipe = new NamedPipeClientStream(".", "unique-pipe-name", PipeDirection.In, PipeOptions.Asynchronous);
clientPipe.Connect();
await clientPipe.ConnectAsync();

await serverPipeConnectionTask;
var cnt = 0;
Expand All @@ -51,11 +53,11 @@ public async Task Issue_4580_EmptyByteStringCausesPipeToBeClosed()
var readFromStreamTask = StreamConverters.FromInputStream(() => clientPipe, 1)
.RunForeach(bs => result.Add(bs.ToString(Encoding.ASCII)), Materializer);

await Task.WhenAll(writeToStreamTask, readFromStreamTask);
await Task.WhenAll(writeToStreamTask, readFromStreamTask).ShouldCompleteWithin(3.Seconds());

var expected = Enumerable.Range(0, 100)
.SelectMany(i => i == 10 ? Array.Empty<string>() : i.ToString().Select(c => c.ToString()));
expected.SequenceEqual(result).ShouldBeTrue();
expected.Should().BeEquivalentTo(result, options => options.WithStrictOrdering());
}
}
}