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

Convert Akka.TestKit.Tests.TestKitBaseTests.DilatedTests to async #5869

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
27 changes: 17 additions & 10 deletions src/core/Akka.TestKit.Tests/TestKitBaseTests/DilatedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<TrueException>(() => AwaitCondition(() => false, TimeSpan.FromMilliseconds(Timeout)));
await Awaiting(() => AwaitConditionAsync(() => Task.FromResult(false), TimeSpan.FromMilliseconds(Timeout)))
.Should().ThrowAsync<TrueException>();
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<TrueException>(() => ReceiveN(42, TimeSpan.FromMilliseconds(Timeout)));
await Awaiting(async () => await ReceiveNAsync(42, TimeSpan.FromMilliseconds(Timeout)).ToListAsync())
.Should().ThrowAsync<TrueException>();
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<TrueException>(() => ExpectMsgAllOf(TimeSpan.FromMilliseconds(Timeout), new []{ "1", "2" }));
await Awaiting(async () => await ExpectMsgAllOfAsync(TimeSpan.FromMilliseconds(Timeout), new []{ "1", "2" }).ToListAsync())
.Should().ThrowAsync<TrueException>();
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<TrueException>(() => FishForMessage(_=>false, TimeSpan.FromMilliseconds(Timeout)));
await Awaiting(async () => await FishForMessageAsync(_=>false, TimeSpan.FromMilliseconds(Timeout)))
.Should().ThrowAsync<TrueException>();
stopwatch.Stop();
AssertDilated(stopwatch.ElapsedMilliseconds, $"Expected the timeout to be {ExpectedTimeout} but in fact it was {stopwatch.ElapsedMilliseconds}.");
}
Expand Down