diff --git a/src/core/Akka.TestKit.Tests/Akka.TestKit.Tests.csproj b/src/core/Akka.TestKit.Tests/Akka.TestKit.Tests.csproj
index 220b17aef65..670f9c73307 100644
--- a/src/core/Akka.TestKit.Tests/Akka.TestKit.Tests.csproj
+++ b/src/core/Akka.TestKit.Tests/Akka.TestKit.Tests.csproj
@@ -4,6 +4,7 @@
Akka.TestKit.Tests
$(NetFrameworkTestVersion);$(NetTestVersion);$(NetCoreTestVersion)
+ 8.0
diff --git a/src/core/Akka.TestKit.Tests/TestKitBaseTests/ReceiveTests.cs b/src/core/Akka.TestKit.Tests/TestKitBaseTests/ReceiveTests.cs
index 6963f5c7e90..208fad462f5 100644
--- a/src/core/Akka.TestKit.Tests/TestKitBaseTests/ReceiveTests.cs
+++ b/src/core/Akka.TestKit.Tests/TestKitBaseTests/ReceiveTests.cs
@@ -7,98 +7,95 @@
using System;
using System.Collections;
-using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using Akka.Actor;
-using Akka.TestKit;
using FluentAssertions;
using Xunit;
using Xunit.Sdk;
+using static FluentAssertions.FluentActions;
-namespace Akka.Testkit.Tests.TestKitBaseTests
+namespace Akka.TestKit.Tests.TestKitBaseTests
{
public class ReceiveTests : AkkaSpec
{
[Fact]
- public void ReceiveN_should_receive_correct_number_of_messages()
+ public async Task ReceiveNAsync_should_receive_correct_number_of_messages()
{
TestActor.Tell("1");
TestActor.Tell("2");
TestActor.Tell("3");
TestActor.Tell("4");
- ReceiveN(3).ShouldOnlyContainInOrder("1", "2", "3");
- ReceiveN(1).ShouldOnlyContainInOrder("4");
+ await ReceiveNAsync(3).ShouldOnlyContainInOrderAsync("1", "2", "3");
+ await ReceiveNAsync(1).ShouldOnlyContainInOrderAsync("4");
}
[Fact]
- public void ReceiveN_should_timeout_if_no_messages()
+ public async Task ReceiveNAsync_should_timeout_if_no_messages()
{
- Intercept(() => ReceiveN(3, TimeSpan.FromMilliseconds(10)));
+ await Awaiting(async () => await ReceiveNAsync(3, TimeSpan.FromMilliseconds(10)).ToListAsync())
+ .Should().ThrowAsync();
}
[Fact]
- public void ReceiveN_should_timeout_if_to_few_messages()
+ public async Task ReceiveNAsync_should_timeout_if_to_few_messages()
{
TestActor.Tell("1");
TestActor.Tell("2");
- Intercept(() => ReceiveN(3, TimeSpan.FromMilliseconds(100)));
+ await Awaiting(async () => await ReceiveNAsync(3, TimeSpan.FromMilliseconds(100)).ToListAsync())
+ .Should().ThrowAsync();
}
-
[Fact]
- public void FishForMessage_should_return_matched_message()
+ public async Task FishForMessageAsync_should_return_matched_message()
{
TestActor.Tell(1);
TestActor.Tell(2);
TestActor.Tell(10);
TestActor.Tell(20);
- FishForMessage(i => i >= 10).ShouldBe(10);
+ await FishForMessageAsync(i => i >= 10).ShouldBeAsync(10);
}
[Fact]
- public void FishForMessage_should_timeout_if_no_messages()
+ public async Task FishForMessageAsync_should_timeout_if_no_messages()
{
- Intercept(() => FishForMessage(_ => false, TimeSpan.FromMilliseconds(10)));
+ await Awaiting(async () => await FishForMessageAsync(_ => false, TimeSpan.FromMilliseconds(10)))
+ .Should().ThrowAsync();
}
[Fact]
- public void FishForMessage_should_timeout_if_to_few_messages()
+ public async Task FishForMessageAsync_should_timeout_if_too_few_messages()
{
TestActor.Tell("1");
TestActor.Tell("2");
- Intercept(() => FishForMessage(_ => false, TimeSpan.FromMilliseconds(100)));
+ await Awaiting(async () => await FishForMessageAsync(_ => false, TimeSpan.FromMilliseconds(100)))
+ .Should().ThrowAsync();
}
[Fact]
- public async Task FishForMessage_should_fill_the_all_messages_param_if_not_null()
+ public async Task FishForMessageAsync_should_fill_the_all_messages_param_if_not_null()
{
- await Task.Run(delegate
- {
- var probe = base.CreateTestProbe("probe");
- probe.Tell("1");
- probe.Tell(2);
- probe.Tell("3");
- probe.Tell(4);
- var allMessages = new ArrayList();
- probe.FishForMessage(isMessage: s => s == "3", allMessages: allMessages);
- allMessages.Should().BeEquivalentTo(new ArrayList { "1", 2 });
- });
+ var probe = CreateTestProbe("probe");
+ probe.Tell("1");
+ probe.Tell(2);
+ probe.Tell("3");
+ probe.Tell(4);
+ var allMessages = new ArrayList();
+ await probe.FishForMessageAsync(isMessage: s => s == "3", allMessages: allMessages);
+ allMessages.Should().BeEquivalentTo(new ArrayList { "1", 2 });
}
[Fact]
- public async Task FishForMessage_should_clear_the_all_messages_param_if_not_null_before_filling_it()
+ public async Task FishForMessageAsync_should_clear_the_all_messages_param_if_not_null_before_filling_it()
{
- await Task.Run(delegate
- {
- var probe = base.CreateTestProbe("probe");
- probe.Tell("1");
- probe.Tell(2);
- probe.Tell("3");
- probe.Tell(4);
- var allMessages = new ArrayList() { "pre filled data" };
- probe.FishForMessage(isMessage: x => x == "3", allMessages: allMessages);
- allMessages.Should().BeEquivalentTo(new ArrayList { "1", 2 });
- });
+ var probe = CreateTestProbe("probe");
+ probe.Tell("1");
+ probe.Tell(2);
+ probe.Tell("3");
+ probe.Tell(4);
+ var allMessages = new ArrayList { "pre filled data" };
+ await probe.FishForMessageAsync(isMessage: x => x == "3", allMessages: allMessages);
+ allMessages.Should().BeEquivalentTo(new ArrayList { "1", 2 });
}
[Fact]
@@ -106,17 +103,17 @@ public async Task FishUntilMessageAsync_should_succeed_with_good_input()
{
var probe = CreateTestProbe("probe");
probe.Ref.Tell(1d, TestActor);
- await probe.FishUntilMessageAsync(max: TimeSpan.FromMilliseconds(10));
+ await Awaiting(() => probe.FishUntilMessageAsync(max: TimeSpan.FromMilliseconds(10)))
+ .Should().NotThrowAsync();
}
-
[Fact]
public async Task FishUntilMessageAsync_should_fail_with_bad_input()
{
var probe = CreateTestProbe("probe");
probe.Ref.Tell(3, TestActor);
- Func func = () => probe.FishUntilMessageAsync(max: TimeSpan.FromMilliseconds(10));
- await func.Should().ThrowAsync();
+ await Awaiting(() => probe.FishUntilMessageAsync(max: TimeSpan.FromMilliseconds(10)))
+ .Should().ThrowAsync();
}
[Fact]
@@ -169,86 +166,82 @@ public async Task WaitForRadioSilenceAsync_should_fail_immediately_with_bad_inpu
{
var probe = CreateTestProbe("probe");
probe.Ref.Tell(3, TestActor);
- try
- {
- await probe.WaitForRadioSilenceAsync(max: TimeSpan.FromMilliseconds(0), maxMessages: 0);
- Assert.True(false, "we should never get here");
- }
- catch (XunitException) { }
+ await Awaiting(() => probe.WaitForRadioSilenceAsync(max: TimeSpan.FromMilliseconds(0), maxMessages: 0))
+ .Should().ThrowAsync().WithMessage("maxMessages violated*");
}
[Fact]
- public void ReceiveWhile_Filter_should_on_a_timeout_return_no_messages()
+ public async Task ReceiveWhileAsync_Filter_should_on_a_timeout_return_no_messages()
{
- ReceiveWhile