From 06f2d7e48f58f60932ec9d9530f485c438823eac Mon Sep 17 00:00:00 2001 From: Ebere Abanonu Date: Fri, 1 Apr 2022 18:54:36 +0100 Subject: [PATCH] Port `Akka.Tests.Routing` tests to `async/await` - `ConfiguredLocalRoutingSpec` (#5806) * Port `Akka.Tests.Pattern` tests to `async/await` - `ConfiguredLocalRoutingSpec` * Let `.ToListAsync()` be called after `.Cast()` Co-authored-by: Gregorius Soedharmo --- .../IO/UdpConnectedIntegrationSpec.cs | 4 ++-- .../Routing/ConfiguredLocalRoutingSpec.cs | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/Akka.Tests/IO/UdpConnectedIntegrationSpec.cs b/src/core/Akka.Tests/IO/UdpConnectedIntegrationSpec.cs index 65a7b22f815..896b41ed3cf 100644 --- a/src/core/Akka.Tests/IO/UdpConnectedIntegrationSpec.cs +++ b/src/core/Akka.Tests/IO/UdpConnectedIntegrationSpec.cs @@ -192,8 +192,8 @@ public async Task The_UDP_connection_oriented_implementation_must_not_leak_memor for (var j = 0; j < batchSize; ++j) client.Tell(UdpConnected.Send.Create(data)); - var msgs = await serverProbe.ReceiveNAsync(batchSize, TimeSpan.FromSeconds(10)).ToListAsync(); - var cast = msgs.Cast(); + var msgs = serverProbe.ReceiveNAsync(batchSize, TimeSpan.FromSeconds(10)); + var cast = await msgs.Cast().ToListAsync(); cast.Sum(m => m.Data.Count).Should().Be(data.Count * batchSize); } diff --git a/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs b/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs index 66423ba61d4..923731852ae 100644 --- a/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs +++ b/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs @@ -273,48 +273,48 @@ public async Task RouterConfig_must_be_overridable_in_config_even_with_explicit_ [Fact] public void RouterConfig_must_be_fail_with_exception_if_not_correct() { - Intercept(() => + Assert.Throws(() => { Sys.ActorOf(FromConfig.Instance.Props()); }); } [Fact] - public void RouterConfig_must_not_get_confused_when_trying_to_wildcard_configure_children() + public async Task RouterConfig_must_not_get_confused_when_trying_to_wildcard_configure_children() { var router = Sys.ActorOf(FromConfig.Instance.Props(Props.Create(TestActor)), "weird"); var received = Enumerable.Range(1, 3).Select(_ => ExpectMsg()).ToList(); // TODO: wrong actor names - var expected = new List { "a", "b", "c" }.Select(i => Sys.ActorSelection("/user/weird/$" + i).ResolveOne(RemainingOrDefault).Result).ToList(); + var expected = new List { "a", "b", "c" }.Select( i => Sys.ActorSelection("/user/weird/$" + i).ResolveOne(RemainingOrDefault).Result).ToList(); received.Should().BeEquivalentTo(expected); - ExpectNoMsg(1.Seconds()); + await ExpectNoMsgAsync(1.Seconds()); } [Fact] - public void RouterConfig_must_support_custom_router() + public async Task RouterConfig_must_support_custom_router() { var myRouter = Sys.ActorOf(FromConfig.Instance.Props(), "myrouter"); myRouter.Tell("foo"); - ExpectMsg("bar"); + await ExpectMsgAsync("bar"); } [Fact(Skip = "SystemActors DSN has not implemented yet")] - public void RouterConfig_must_load_settings_from_config_for_local_child_router_of_system_actor() + public async Task RouterConfig_must_load_settings_from_config_for_local_child_router_of_system_actor() { var probe = CreateTestProbe(); var parent = Sys.AsInstanceOf().SystemActorOf(Props.Create(), "sys-parent"); parent.Tell(new PropsName(Props.Create(), "round"), probe.Ref); - var router = probe.ExpectMsg(); + var router = await probe.ExpectMsgAsync(); var replies = new List(); for (int i = 0; i < 10; i++) { var msg = i.ToString(); router.Tell(msg, probe.Ref); - probe.ExpectMsg(msg); + await probe.ExpectMsgAsync(msg); replies.Add(probe.LastSender.Path); }