diff --git a/src/core/Akka.Tests/Actor/InboxSpec.cs b/src/core/Akka.Tests/Actor/InboxSpec.cs index aadf1e6217e..99c2d6f73c8 100644 --- a/src/core/Akka.Tests/Actor/InboxSpec.cs +++ b/src/core/Akka.Tests/Actor/InboxSpec.cs @@ -51,13 +51,13 @@ public void Inbox_support_queueing_multiple_queries() Task.Factory.StartNew(() => { Thread.Sleep(100); - return _inbox.ReceiveWhere(x => x.ToString() == "world"); - }), + return _inbox.ReceiveWhere(x => x.ToString() == "world"); + }), Task.Factory.StartNew(() => { Thread.Sleep(200); - return _inbox.ReceiveWhere(x => x.ToString() == "hello"); - }) + return _inbox.ReceiveWhere(x => x.ToString() == "hello"); + }) }; _inbox.Receiver.Tell(42); @@ -77,7 +77,7 @@ public void Inbox_support_selective_receives() _inbox.Receiver.Tell("hello"); _inbox.Receiver.Tell("world"); - var selection = _inbox.ReceiveWhere(x => x.ToString() == "world"); + var selection = _inbox.ReceiveWhere(x => x.ToString() == "world"); selection.ShouldBe("world"); _inbox.Receive().ShouldBe("hello"); } @@ -94,7 +94,7 @@ public async Task Inbox_have_maximum_queue_size() await ExpectNoMsgAsync(TimeSpan.FromSeconds(1)); //The inbox is full. Sending another message should result in a Warning message - await EventFilter.Warning(start:"Dropping message").ExpectOneAsync(() => _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); @@ -138,7 +138,7 @@ await WithinAsync(TimeSpan.FromSeconds(1), () => [Fact] public void Select_WithClient_should_update_Client_and_copy_the_rest_of_the_properties_BUG_427() { - var deadline = new TimeSpan(Sys.Scheduler.MonotonicClock.Ticks/2); //Some point in the past + var deadline = new TimeSpan(Sys.Scheduler.MonotonicClock.Ticks / 2); //Some point in the past Predicate predicate = o => true; var actorRef = new EmptyLocalActorRef(((ActorSystemImpl)Sys).Provider, new RootActorPath(new Address("akka", "test")), Sys.EventStream); var select = new Select(deadline, predicate, actorRef); diff --git a/src/core/Akka.Tests/Dispatch/MailboxesSpec.cs b/src/core/Akka.Tests/Dispatch/MailboxesSpec.cs index bc99a466883..2cea88eb009 100644 --- a/src/core/Akka.Tests/Dispatch/MailboxesSpec.cs +++ b/src/core/Akka.Tests/Dispatch/MailboxesSpec.cs @@ -196,7 +196,7 @@ public Property UnboundedPriorityQueue_should_sort_items_in_expected_order(int[] #endif [Fact] - public void Can_use_unbounded_priority_mailbox() + public async Task Can_use_unbounded_priority_mailbox() { var actor = (IInternalActorRef)Sys.ActorOf(EchoActor.Props(this).WithMailbox("string-prio-mailbox"), "echo"); @@ -204,7 +204,7 @@ public void Can_use_unbounded_priority_mailbox() actor.SendSystemMessage(new Suspend()); // wait until we can confirm that the mailbox is suspended before we begin sending messages - AwaitCondition(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); + await AwaitConditionAsync(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); actor.Tell(true); for (var i = 0; i < 30; i++) @@ -222,19 +222,19 @@ public void Can_use_unbounded_priority_mailbox() //resume mailbox, this prevents the mailbox from running to early //priority mailbox is best effort only - ExpectMsg("a"); - ExpectMsg(true); + await ExpectMsgAsync("a"); + await ExpectMsgAsync(true); for (var i = 0; i < 60; i++) { - ExpectMsg(1); + await ExpectMsgAsync(1); } - ExpectMsg(2.0); + await ExpectMsgAsync(2.0); - ExpectNoMsg(TimeSpan.FromSeconds(0.3)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(0.3)); } [Fact] - public void Can_use_unbounded_stable_priority_mailbox() + public async Task Can_use_unbounded_stable_priority_mailbox() { var actor = (IInternalActorRef)Sys.ActorOf(EchoActor.Props(this).WithMailbox("stable-prio-mailbox"), "echo"); @@ -242,7 +242,7 @@ public void Can_use_unbounded_stable_priority_mailbox() actor.SendSystemMessage(new Suspend()); // wait until we can confirm that the mailbox is suspended before we begin sending messages - AwaitCondition(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); + await AwaitConditionAsync(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); actor.Tell(true); for (var i = 0; i < 30; i++) @@ -260,26 +260,26 @@ public void Can_use_unbounded_stable_priority_mailbox() //resume mailbox, this prevents the mailbox from running to early //priority mailbox is best effort only - ExpectMsg("a"); - ExpectMsg(true); + await ExpectMsgAsync("a"); + await ExpectMsgAsync(true); for (var i = 0; i < 60; i++) { - ExpectMsg(i); + await ExpectMsgAsync(i); } - ExpectMsg(2.0); + await ExpectMsgAsync(2.0); - ExpectNoMsg(TimeSpan.FromSeconds(0.3)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(0.3)); } [Fact] - public void Priority_mailbox_keeps_ordering_with_many_priority_values() + public async Task Priority_mailbox_keeps_ordering_with_many_priority_values() { var actor = (IInternalActorRef)Sys.ActorOf(EchoActor.Props(this).WithMailbox("int-prio-mailbox"), "echo"); //pause mailbox until all messages have been told actor.SendSystemMessage(new Suspend()); - AwaitCondition(()=> (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); + await AwaitConditionAsync(()=> (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); // creates 50 messages with values spanning from Int32.MinValue to Int32.MaxValue var values = new int[50]; var increment = (int)(UInt32.MaxValue / values.Length); @@ -301,23 +301,23 @@ public void Priority_mailbox_keeps_ordering_with_many_priority_values() // expect the messages in the correct order foreach (var value in values) { - ExpectMsg(value); - ExpectMsg(value); - ExpectMsg(value); + await ExpectMsgAsync(value); + await ExpectMsgAsync(value); + await ExpectMsgAsync(value); } - ExpectNoMsg(TimeSpan.FromSeconds(0.3)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(0.3)); } [Fact] - public void Unbounded_Priority_Mailbox_Supports_Unbounded_Stashing() + public async Task Unbounded_Priority_Mailbox_Supports_Unbounded_Stashing() { var actor = (IInternalActorRef)Sys.ActorOf(StashingActor.Props(this).WithMailbox("int-prio-mailbox"), "echo"); //pause mailbox until all messages have been told actor.SendSystemMessage(new Suspend()); - AwaitCondition(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); + await AwaitConditionAsync(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); var values = new int[10]; var increment = (int)(UInt32.MaxValue / values.Length); @@ -338,29 +338,29 @@ public void Unbounded_Priority_Mailbox_Supports_Unbounded_Stashing() //resume mailbox, this prevents the mailbox from running to early actor.SendSystemMessage(new Resume(null)); - this.Within(5.Seconds(), () => + await WithinAsync(5.Seconds(), async() => { // expect the messages in the correct order foreach (var value in values) { - ExpectMsg(value); - ExpectMsg(value); - ExpectMsg(value); + await ExpectMsgAsync(value); + await ExpectMsgAsync(value); + await ExpectMsgAsync(value); } }); - ExpectNoMsg(TimeSpan.FromSeconds(0.3)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(0.3)); } [Fact] - public void Unbounded_Stable_Priority_Mailbox_Supports_Unbounded_Stashing() + public async Task Unbounded_Stable_Priority_Mailbox_Supports_Unbounded_Stashing() { var actor = (IInternalActorRef)Sys.ActorOf(StashingActor.Props(this).WithMailbox("stable-prio-mailbox"), "echo"); //pause mailbox until all messages have been told actor.SendSystemMessage(new Suspend()); - AwaitCondition(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); + await AwaitConditionAsync(() => (((ActorRefWithCell)actor).Underlying is ActorCell) && ((ActorRefWithCell)actor).Underlying.AsInstanceOf().Mailbox.IsSuspended()); var values = new int[10]; var increment = (int)(UInt32.MaxValue / values.Length); @@ -381,18 +381,18 @@ public void Unbounded_Stable_Priority_Mailbox_Supports_Unbounded_Stashing() //resume mailbox, this prevents the mailbox from running to early actor.SendSystemMessage(new Resume(null)); - this.Within(5.Seconds(), () => + await WithinAsync(5.Seconds(), async() => { // expect the messages in the original order foreach (var value in values) { - ExpectMsg(value); - ExpectMsg(value); - ExpectMsg(value); + await ExpectMsgAsync(value); + await ExpectMsgAsync(value); + await ExpectMsgAsync(value); } }); - ExpectNoMsg(TimeSpan.FromSeconds(0.3)); + await ExpectNoMsgAsync(TimeSpan.FromSeconds(0.3)); } } }