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

Port Akka.Tests.Dispatch tests to async/await - ActorAsyncAwaitSpec #5788

Merged
merged 3 commits into from
Mar 30, 2022
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
30 changes: 15 additions & 15 deletions src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ public async Task Actors_should_be_able_to_block_ask_self_message_loop()
}

[Fact]
public void Actors_should_be_able_to_supervise_async_exceptions()
public async Task Actors_should_be_able_to_supervise_async_exceptions()
{
var asker = Sys.ActorOf(Props.Create(() => new AsyncExceptionActor(TestActor)));
asker.Tell("start");
ExpectMsg("done", TimeSpan.FromSeconds(5));
await ExpectMsgAsync("done", TimeSpan.FromSeconds(5));
}

[Fact]
Expand All @@ -347,11 +347,11 @@ public async Task Actors_should_be_able_to_use_ContinueWith()
}

[Fact]
public void Actors_should_be_able_to_supervise_exception_ContinueWith()
public async Task Actors_should_be_able_to_supervise_exception_ContinueWith()
{
var asker = Sys.ActorOf(Props.Create(() => new AsyncTplExceptionActor(TestActor)));
asker.Tell("start");
ExpectMsg("done", TimeSpan.FromSeconds(5));
await ExpectMsgAsync("done", TimeSpan.FromSeconds(5));
}


Expand All @@ -378,12 +378,12 @@ public async Task Actor_should_be_able_to_resume_suspend()
}

[Fact]
public void Actor_should_be_able_to_ReceiveTimeout_after_async_operation()
public async Task Actor_should_be_able_to_ReceiveTimeout_after_async_operation()
{
var actor = Sys.ActorOf<ReceiveTimeoutAsyncActor>();

actor.Tell("hello");
ExpectMsg<string>(m => m == "GotIt");
await ExpectMsgAsync<string>(m => m == "GotIt");
}

public class AsyncExceptionCatcherActor : ReceiveActor
Expand Down Expand Up @@ -448,13 +448,13 @@ private static void ThrowException()
}

[Fact]
public void Actor_PreRestart_should_give_the_failing_message()
public async Task Actor_PreRestart_should_give_the_failing_message()
{
var actor = Sys.ActorOf<AsyncFailingActor>();

actor.Tell("hello");

ExpectMsg<RestartMessage>(m => "hello".Equals(m.Message));
await ExpectMsgAsync<RestartMessage>(m => "hello".Equals(m.Message));
}

public class AsyncPipeToDelayActor : ReceiveActor
Expand Down Expand Up @@ -494,21 +494,21 @@ public AsyncReentrantActor()
}

[Fact]
public void ActorTaskScheduler_reentrancy_should_not_be_possible()
public async Task ActorTaskScheduler_reentrancy_should_not_be_possible()
{
var actor = Sys.ActorOf<AsyncReentrantActor>();
actor.Tell("hello");

ExpectNoMsg(1000);
await ExpectNoMsgAsync(1000);
}

[Fact]
public void Actor_PipeTo_should_not_be_delayed_by_async_receive()
public async Task Actor_PipeTo_should_not_be_delayed_by_async_receive()
{
var actor = Sys.ActorOf<AsyncPipeToDelayActor>();

actor.Tell("hello");
ExpectMsg<string>(m => "hello".Equals(m), TimeSpan.FromMilliseconds(1000));
await ExpectMsgAsync<string>(m => "hello".Equals(m), TimeSpan.FromMilliseconds(1000));
}

[Fact]
Expand All @@ -517,13 +517,13 @@ public async Task Actor_receiveasync_overloads_should_work()
var actor = Sys.ActorOf<AsyncAwaitActor>();

actor.Tell(11);
ExpectMsg<string>(m => "handled".Equals(m), TimeSpan.FromMilliseconds(1000));
await ExpectMsgAsync<string>(m => "handled".Equals(m), TimeSpan.FromMilliseconds(1000));

actor.Tell(9);
ExpectMsg<string>(m => "receiveany".Equals(m), TimeSpan.FromMilliseconds(1000));
await ExpectMsgAsync<string>(m => "receiveany".Equals(m), TimeSpan.FromMilliseconds(1000));

actor.Tell(1.0);
ExpectMsg<string>(m => "handled".Equals(m), TimeSpan.FromMilliseconds(1000));
await ExpectMsgAsync<string>(m => "handled".Equals(m), TimeSpan.FromMilliseconds(1000));


}
Expand Down