diff --git a/src/core/Akka.Tests/Actor/InboxSpec.cs b/src/core/Akka.Tests/Actor/InboxSpec.cs index ca606fb022a..aadf1e6217e 100644 --- a/src/core/Akka.Tests/Actor/InboxSpec.cs +++ b/src/core/Akka.Tests/Actor/InboxSpec.cs @@ -13,6 +13,7 @@ using Akka.Actor.Internal; using Akka.Event; using Akka.TestKit; +using Akka.Tests.Util; using Xunit; namespace Akka.Tests.Actor @@ -28,13 +29,13 @@ public InboxSpec() } [Fact] - public void Inbox_support_watch() + public async Task Inbox_support_watch() { _inbox.Watch(TestActor); // check watch TestActor.Tell(PoisonPill.Instance); - var received = _inbox.Receive(TimeSpan.FromSeconds(1)); + var received = await _inbox.ReceiveAsync(TimeSpan.FromSeconds(1)); received.GetType().ShouldBe(typeof(Terminated)); var terminated = (Terminated)received; @@ -82,7 +83,7 @@ public void Inbox_support_selective_receives() } [Fact] - public void Inbox_have_maximum_queue_size() + public async Task Inbox_have_maximum_queue_size() { try { @@ -90,14 +91,14 @@ public void Inbox_have_maximum_queue_size() foreach (var zero in Enumerable.Repeat(0, 1000)) _inbox.Receiver.Tell(zero); - ExpectNoMsg(TimeSpan.FromSeconds(1)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(1)); //The inbox is full. Sending another message should result in a Warning message - EventFilter.Warning(start:"Dropping message").ExpectOne(() => _inbox.Receiver.Tell(42)); + await EventFilter.Warning(start:"Dropping message").ExpectOneAsync(() => _inbox.Receiver.Tell(42)); //The inbox is still full. But since the warning message has already been sent, no more warnings should be sent _inbox.Receiver.Tell(42); - ExpectNoMsg(TimeSpan.FromSeconds(1)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(1)); //Receive all messages from the inbox var gotit = Enumerable.Repeat(0, 1000).Select(_ => _inbox.Receive()); @@ -107,7 +108,7 @@ public void Inbox_have_maximum_queue_size() } //The inbox should be empty now, so receiving should result in a timeout - Intercept(() => + Assert.Throws(() => { var received = _inbox.Receive(TimeSpan.FromSeconds(1)); Log.Error("Received " + received); @@ -120,18 +121,17 @@ public void Inbox_have_maximum_queue_size() } [Fact] - public void Inbox_have_a_default_and_custom_timeouts() + public async Task Inbox_have_a_default_and_custom_timeouts() { - Within(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(6), () => + await WithinAsync(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(6), () => { - Intercept(() => _inbox.Receive()); + Assert.Throws(() => _inbox.Receive()); return true; }); - Within(TimeSpan.FromSeconds(1), () => + await WithinAsync(TimeSpan.FromSeconds(1), () => { - Intercept(() => _inbox.Receive(TimeSpan.FromMilliseconds(100))); - return true; + Assert.Throws(() => _inbox.Receive(TimeSpan.FromMilliseconds(100))); }); } @@ -152,11 +152,10 @@ public void Select_WithClient_should_update_Client_and_copy_the_rest_of_the_prop } [Fact] - public void Inbox_Receive_will_timeout_gracefully_if_timeout_is_already_expired() + public async Task Inbox_Receive_will_timeout_gracefully_if_timeout_is_already_expired() { var task = _inbox.ReceiveAsync(TimeSpan.FromSeconds(-1)); - - Assert.True(task.Wait(1000), "Receive did not complete in time."); + Assert.True(await task.AwaitWithTimeout(TimeSpan.FromMilliseconds(1000)), "Receive did not complete in time."); Assert.IsType(task.Result); } }