From 105765fa1905d8f14f92db61d15d10e3058615cf Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Sat, 23 Apr 2022 01:11:40 +0700 Subject: [PATCH] Convert Akka.TestKit.Tests.TestKitBaseTests.DilatedTests to async --- .../TestKitBaseTests/DilatedTests.cs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/core/Akka.TestKit.Tests/TestKitBaseTests/DilatedTests.cs b/src/core/Akka.TestKit.Tests/TestKitBaseTests/DilatedTests.cs index c790eab741b..3505533c43b 100644 --- a/src/core/Akka.TestKit.Tests/TestKitBaseTests/DilatedTests.cs +++ b/src/core/Akka.TestKit.Tests/TestKitBaseTests/DilatedTests.cs @@ -7,11 +7,14 @@ using System; using System.Diagnostics; -using Akka.TestKit; +using System.Linq; +using System.Threading.Tasks; using Xunit; using Xunit.Sdk; +using FluentAssertions; +using static FluentAssertions.FluentActions; -namespace Akka.Testkit.Tests.TestKitBaseTests +namespace Akka.TestKit.Tests.TestKitBaseTests { public class DilatedTests : AkkaSpec { @@ -33,37 +36,41 @@ public void Dilates_correctly_using_timeFactor() } [Fact] - public void AwaitCondition_should_dilate_timeout() + public async Task AwaitConditionAsync_should_dilate_timeout() { var stopwatch = Stopwatch.StartNew(); - AssertThrows(() => AwaitCondition(() => false, TimeSpan.FromMilliseconds(Timeout))); + await Awaiting(() => AwaitConditionAsync(() => Task.FromResult(false), TimeSpan.FromMilliseconds(Timeout))) + .Should().ThrowAsync(); stopwatch.Stop(); AssertDilated(stopwatch.ElapsedMilliseconds, $"Expected the timeout to be {ExpectedTimeout} but in fact it was {stopwatch.ElapsedMilliseconds}."); } [Fact] - public void ReceiveN_should_dilate_timeout() + public async Task ReceiveNAsync_should_dilate_timeout() { var stopwatch = Stopwatch.StartNew(); - AssertThrows(() => ReceiveN(42, TimeSpan.FromMilliseconds(Timeout))); + await Awaiting(async () => await ReceiveNAsync(42, TimeSpan.FromMilliseconds(Timeout)).ToListAsync()) + .Should().ThrowAsync(); stopwatch.Stop(); AssertDilated(stopwatch.ElapsedMilliseconds, $"Expected the timeout to be {ExpectedTimeout} but in fact it was {stopwatch.ElapsedMilliseconds}."); } [Fact] - public void ExpectMsgAllOf_should_dilate_timeout() + public async Task ExpectMsgAllOfAsync_should_dilate_timeout() { var stopwatch = Stopwatch.StartNew(); - AssertThrows(() => ExpectMsgAllOf(TimeSpan.FromMilliseconds(Timeout), new []{ "1", "2" })); + await Awaiting(async () => await ExpectMsgAllOfAsync(TimeSpan.FromMilliseconds(Timeout), new []{ "1", "2" }).ToListAsync()) + .Should().ThrowAsync(); stopwatch.Stop(); AssertDilated(stopwatch.ElapsedMilliseconds, $"Expected the timeout to be {ExpectedTimeout} but in fact it was {stopwatch.ElapsedMilliseconds}."); } [Fact] - public void FishForMessage_should_dilate_timeout() + public async Task FishForMessageAsync_should_dilate_timeout() { var stopwatch = Stopwatch.StartNew(); - AssertThrows(() => FishForMessage(_=>false, TimeSpan.FromMilliseconds(Timeout))); + await Awaiting(async () => await FishForMessageAsync(_=>false, TimeSpan.FromMilliseconds(Timeout))) + .Should().ThrowAsync(); stopwatch.Stop(); AssertDilated(stopwatch.ElapsedMilliseconds, $"Expected the timeout to be {ExpectedTimeout} but in fact it was {stopwatch.ElapsedMilliseconds}."); }