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.Actor tests to async/await - ActorDsl #5759

Merged
merged 4 commits into from
Mar 28, 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
38 changes: 19 additions & 19 deletions src/core/Akka.Tests/Actor/ActorDslSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ namespace Akka.Tests.Actor
public class ActorDslSpec : AkkaSpec
{
[Fact]
public void A_lightweight_creator_must_support_creating_regular_actors()
public async Task A_lightweight_creator_must_support_creating_regular_actors()
{
var a = Sys.ActorOf(Props.Create(() => new Act(c =>
c.Receive<string>(msg => msg == "hello", (msg, ctx) => TestActor.Tell("hi")))));

a.Tell("hello");
ExpectMsg("hi");
await ExpectMsgAsync("hi");
}

[Fact]
public void A_lightweight_creator_must_support_become_stacked()
public async Task A_lightweight_creator_must_support_become_stacked()
{
var a = Sys.ActorOf(c => c.Become((msg, ctx) =>
{
Expand All @@ -52,19 +52,19 @@ public void A_lightweight_creator_must_support_become_stacked()
}));

a.Tell("info");
ExpectMsg("A");
await ExpectMsgAsync("A");

a.Tell("switch");
a.Tell("info");
ExpectMsg("B");
await ExpectMsgAsync("B");

a.Tell("switch");
a.Tell("info");
ExpectMsg("A");
await ExpectMsgAsync("A");
}

[Fact]
public void A_lightweight_creator_must_support_actor_setup_and_teardown()
public async Task A_lightweight_creator_must_support_actor_setup_and_teardown()
{
const string started = "started";
const string stopped = "stopped";
Expand All @@ -76,8 +76,8 @@ public void A_lightweight_creator_must_support_actor_setup_and_teardown()
});

Sys.Stop(a);
ExpectMsg(started);
ExpectMsg(stopped);
await ExpectMsgAsync(started);
await ExpectMsgAsync(stopped);
}

[Fact(Skip = "TODO: requires event filters")]
Expand All @@ -93,7 +93,7 @@ public void A_lightweight_creator_must_support_supervising()
}

[Fact]
public void A_lightweight_creator_must_support_nested_declarations()
public async Task A_lightweight_creator_must_support_nested_declarations()
{
var a = Sys.ActorOf(act =>
{
Expand All @@ -104,7 +104,7 @@ public void A_lightweight_creator_must_support_nested_declarations()
act.ReceiveAny((x, _) => TestActor.Tell(x));
}, "fred");

ExpectMsg("hello from akka://" + Sys.Name + "/user/fred/barney");
await ExpectMsgAsync("hello from akka://" + Sys.Name + "/user/fred/barney");
LastSender.ShouldBe(a);
}

Expand All @@ -115,7 +115,7 @@ public void A_lightweight_creator_must_support_stash()
}

[Fact]
public void A_lightweight_creator_must_support_actor_base_method_calls()
public async Task A_lightweight_creator_must_support_actor_base_method_calls()
{
var parent = Sys.ActorOf(act =>
{
Expand All @@ -134,15 +134,15 @@ public void A_lightweight_creator_must_support_actor_base_method_calls()
}, "parent");

parent.Tell("ping");
ExpectMsg("pong");
await ExpectMsgAsync("pong");

parent.Tell("crash");
ExpectMsg("restarting parent");
ExpectMsg("stopping child");
await ExpectMsgAsync("restarting parent");
await ExpectMsgAsync("stopping child");
}

[Fact]
public void A_lightweight_creator_must_support_async_receives()
public async Task A_lightweight_creator_must_support_async_receives()
{
var parent = Sys.ActorOf(act =>
{
Expand Down Expand Up @@ -176,13 +176,13 @@ public void A_lightweight_creator_must_support_async_receives()
});

parent.Tell("ping");
ExpectMsg("pong");
await ExpectMsgAsync("pong");

parent.Tell("pong");
ExpectMsg("ping");
await ExpectMsgAsync("ping");

parent.Tell("hi");
ExpectMsg("hello");
await ExpectMsgAsync("hello");
}
}
}
Expand Down