Skip to content

Commit

Permalink
Convert Akka.Remote.Tests to async - RemoteMetricsSpec (#5888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Apr 29, 2022
1 parent f93620a commit 008fbed
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/core/Akka.Remote.Tests/RemoteMetricsSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,40 @@ protected override async Task AfterTerminationAsync()


[Fact]
public void RemoteMetricsMustNotLogMessagesLargerThanFrameSizeExceeding()
public async Task RemoteMetricsMustNotLogMessagesLargerThanFrameSizeExceeding()
{
var sel = _client.ActorSelection(new RootActorPath(_address)/_subject.Path.Elements);
sel.Tell(new byte[200]);
ExpectMsg<PayloadSize>();
await ExpectMsgAsync<PayloadSize>();
}

[Fact]
public void RemoteMetricsMustLogNewMessageSizeForTheSameMessageTypeLargerThanThePreviousOneOnTheThreshold()
public async Task RemoteMetricsMustLogNewMessageSizeForTheSameMessageTypeLargerThanThePreviousOneOnTheThreshold()
{
var sel = _client.ActorSelection(new RootActorPath(_address)/_subject.Path.Elements);
sel.Tell(new byte[200]);
ExpectMsg<PayloadSize>();
await ExpectMsgAsync<PayloadSize>();
sel.Tell(new byte[300]);
ExpectMsg<NewMaximum>();
await ExpectMsgAsync<NewMaximum>();
}


[Fact]
public void RemoteMetricsMustNotLogMessagesLessThanFrameSizeExceeding()
public async Task RemoteMetricsMustNotLogMessagesLessThanFrameSizeExceeding()
{
var sel = _client.ActorSelection(new RootActorPath(_address)/_subject.Path.Elements);
sel.Tell(new byte[1]);
ExpectNoMsg();
await ExpectNoMsgAsync();
}

[Fact]
public void RemoteMetricsMustNotLogTheSameMessageSizeTwice()
public async Task RemoteMetricsMustNotLogTheSameMessageSizeTwice()
{
var sel = _client.ActorSelection(new RootActorPath(_address)/_subject.Path.Elements);
sel.Tell(new byte[200]);
ExpectMsg<PayloadSize>();
await ExpectMsgAsync<PayloadSize>();
sel.Tell(new byte[200]);
ExpectNoMsg();
await ExpectNoMsgAsync();
}

private class Subject : ActorBase
Expand All @@ -114,9 +114,8 @@ public InfoEventListener(IActorRef testActor)

protected override bool Receive(object message)
{
if (message is Info)
if (message is Info info)
{
var info = ((Info) message);
if (info.Message.ToString().Contains("New maximum payload size for"))
{
_testActor.Tell(new NewMaximum());
Expand Down

0 comments on commit 008fbed

Please sign in to comment.