From e53f747f293f1639c21926c5b4906fa137923f8f Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Wed, 4 May 2022 23:10:05 +0700 Subject: [PATCH] Convert Akka.Streams.Tests to async - BugSpec --- src/core/Akka.Streams.Tests/BugSpec.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/Akka.Streams.Tests/BugSpec.cs b/src/core/Akka.Streams.Tests/BugSpec.cs index e8f4970b84a..6297a6330fd 100644 --- a/src/core/Akka.Streams.Tests/BugSpec.cs +++ b/src/core/Akka.Streams.Tests/BugSpec.cs @@ -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; @@ -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; @@ -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() : i.ToString().Select(c => c.ToString())); - expected.SequenceEqual(result).ShouldBeTrue(); + expected.Should().BeEquivalentTo(result, options => options.WithStrictOrdering()); } } }