-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Milestone
Description
why does this pass:
/// <summary>
/// this test is a false positive
/// </summary>
/// <returns></returns>
[Fact]
public async Task ReplyingToProbeMessagesFunc()
{
await EventFilter.Error().ExpectAsync(0, actionAsync: async () =>
{
var probe = CreateTestProbe();
probe.Tell("hello");
probe.ExpectMsg("hello");
probe.Reply("world");
await Task.Run(() => { ExpectMsg("world2"); });
Assert.Equal(probe.Ref, LastSender);
});
}Looks to me like we forgot to.... you know, await the Task returned inside here:
akka.net/src/core/Akka.TestKit/EventFilter/Internal/EventFilterApplier.cs
Lines 454 to 460 in 38b7443
| /// <summary> | |
| /// Async version of <see cref="InternalExpect"/> | |
| /// </summary> | |
| private async Task InternalExpectAsync(Func<Task> actionAsync, ActorSystem actorSystem, int expectedCount, TimeSpan? timeout = null) | |
| { | |
| await InterceptAsync<object>(() => { actionAsync(); return Task.FromResult<object>(null); }, actorSystem, timeout, expectedCount); | |
| } |
So I suspect the await Task.Run(() => { ExpectMsg("world2"); }); is running as a detatched task, which is incredibly annoying. We just need to update the TestKit to await those tasks internally and then this should pass.
Originally posted by @Aaronontheweb in #5529 (comment)