Skip to content

Commit 880211b

Browse files
Port Akka.Tests.Dispatch tests to async/await - ActorMailboxSpec (#5828)
Co-authored-by: Aaron Stannard <[email protected]>
1 parent 0655628 commit 880211b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/core/Akka.Tests/Dispatch/ActorMailboxSpec.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public class BoundedQueueReportingActor : MailboxReportingActor, IRequiresMessag
105105

106106
}
107107

108-
private IMessageQueue CheckMailBoxType(Props props, string name, IEnumerable<Type> expectedMailboxTypes)
108+
private async Task<IMessageQueue> CheckMailBoxType(Props props, string name, IEnumerable<Type> expectedMailboxTypes)
109109
{
110110
var actor = Sys.ActorOf(props, name);
111111
actor.Tell("ping");
112112

113-
var mailbox = ExpectMsg<IMessageQueue>(msg =>
113+
var mailbox = await ExpectMsgAsync<IMessageQueue>(msg =>
114114
{
115115
expectedMailboxTypes.ForEach(type => Assert.True(type.IsAssignableFrom(msg.GetType()),
116-
String.Format(CultureInfo.InvariantCulture, "Type [{0}] is not assignable to [{1}]", msg.GetType(), type)));
116+
string.Format(CultureInfo.InvariantCulture, "Type [{0}] is not assignable to [{1}]", msg.GetType(), type)));
117117
});
118118

119119
return mailbox;
@@ -124,52 +124,52 @@ private IMessageQueue CheckMailBoxType(Props props, string name, IEnumerable<Typ
124124
#region Test cases
125125

126126
[Fact(DisplayName = @"Actors get an unbounded mailbox by default")]
127-
public void Actors_get_unbounded_mailbox_by_default()
127+
public async Task Actors_get_unbounded_mailbox_by_default()
128128
{
129-
CheckMailBoxType(Props.Create<MailboxReportingActor>(), "default-default", new[] { typeof(UnboundedMessageQueue) });
129+
await CheckMailBoxType(Props.Create<MailboxReportingActor>(), "default-default", new[] { typeof(UnboundedMessageQueue) });
130130
}
131131

132132
[Fact(DisplayName = @"Actors get an unbounded deque message queue when it is only configured on the props")]
133-
public void Actors_get_unbounded_dequeue_mailbox_when_configured_in_properties()
133+
public async Task Actors_get_unbounded_dequeue_mailbox_when_configured_in_properties()
134134
{
135-
CheckMailBoxType(Props.Create<MailboxReportingActor>().WithMailbox("unbounded-mailbox"),
135+
await CheckMailBoxType(Props.Create<MailboxReportingActor>().WithMailbox("unbounded-mailbox"),
136136
"default-override-from-props", new[] { typeof(UnboundedDequeMessageQueue) });
137137
}
138138

139139
[Fact(DisplayName = @"Actors get an unbounded deque message queue when it's only mixed with Stash")]
140-
public void Actors_get_unbounded_mailbox_when_configured_with_stash_only()
140+
public async Task Actors_get_unbounded_mailbox_when_configured_with_stash_only()
141141
{
142-
CheckMailBoxType(Props.Create<StashMailboxReportingActor>(),
142+
await CheckMailBoxType(Props.Create<StashMailboxReportingActor>(),
143143
"default-override-from-stash", new[] { typeof(UnboundedDequeMessageQueue) });
144144

145-
CheckMailBoxType(Props.Create(() => new StashMailboxReportingActor()),
145+
await CheckMailBoxType(Props.Create(() => new StashMailboxReportingActor()),
146146
"default-override-from-stash2", new[] { typeof(UnboundedDequeMessageQueue) });
147147

148-
CheckMailBoxType(Props.Create<StashMailboxWithParamsReportingActor>(10, "foo"),
148+
await CheckMailBoxType(Props.Create<StashMailboxWithParamsReportingActor>(10, "foo"),
149149
"default-override-from-stash3", new[] { typeof(UnboundedDequeMessageQueue) });
150150

151-
CheckMailBoxType(Props.Create(() => new StashMailboxWithParamsReportingActor(10, "foo")),
151+
await CheckMailBoxType(Props.Create(() => new StashMailboxWithParamsReportingActor(10, "foo")),
152152
"default-override-from-stash4", new[] { typeof(UnboundedDequeMessageQueue) });
153153
}
154154

155155
[Fact(DisplayName = "Actors get an unbounded deque message queue when it's configured as mailbox")]
156-
public void Actors_get_unbounded_dequeue_message_queue_when_configured_as_mailbox()
156+
public async Task Actors_get_unbounded_dequeue_message_queue_when_configured_as_mailbox()
157157
{
158-
CheckMailBoxType(Props.Create<MailboxReportingActor>(), "default-unboundeded-deque",
158+
await CheckMailBoxType(Props.Create<MailboxReportingActor>(), "default-unboundeded-deque",
159159
new[] { typeof(UnboundedDequeMessageQueue) });
160160
}
161161

162162
[Fact(DisplayName = "Actor get an unbounded message queue when defined in dispatcher")]
163-
public void Actor_gets_configured_mailbox_from_dispatcher()
163+
public async Task Actor_gets_configured_mailbox_from_dispatcher()
164164
{
165-
CheckMailBoxType(Props.Create<MailboxReportingActor>(), "unbounded-default",
165+
await CheckMailBoxType(Props.Create<MailboxReportingActor>(), "unbounded-default",
166166
new[] { typeof(UnboundedDequeMessageQueue) });
167167
}
168168

169169
[Fact(DisplayName = "get an unbounded message queue with a task dispatcher")]
170-
public void Actors_gets_unbounded_mailbox_with_task_dispatcher()
170+
public async Task Actors_gets_unbounded_mailbox_with_task_dispatcher()
171171
{
172-
CheckMailBoxType(Props.Create<MailboxReportingActor>().WithDispatcher("task-dispatcher"),
172+
await CheckMailBoxType(Props.Create<MailboxReportingActor>().WithDispatcher("task-dispatcher"),
173173
"unbounded-tasks", new[] { typeof(UnboundedMessageQueue) });
174174
}
175175

0 commit comments

Comments
 (0)