Skip to content

Commit

Permalink
Port Akka.Tests.Actor tests to async/await - RefIgnoreSpec (#5763)
Browse files Browse the repository at this point in the history
* Port `Akka.Tests.Actor` tests to `async/await` - RefIgnoreSpec

* Fix missing cancellationToken default value

Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
  • Loading branch information
eaba and Arkatufus authored Mar 28, 2022
1 parent 94c8af2 commit a364879
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/Akka.Tests/Actor/ActorRefIgnoreSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,30 @@
using Xunit;
using Akka.Util.Internal;
using FluentAssertions;
using System.Threading.Tasks;

namespace Akka.Tests.Actor
{
public class ActorRefIgnoreSpec : AkkaSpec, INoImplicitSender
{
[Fact]
public void IgnoreActorRef_should_ignore_all_incoming_messages()
public async Task IgnoreActorRef_should_ignore_all_incoming_messages()
{
var askMeRef = Sys.ActorOf(Props.Create(() => new AskMeActor()));

var probe = CreateTestProbe("response-probe");
askMeRef.Tell(new Request(probe.Ref));
probe.ExpectMsg(1);
await probe.ExpectMsgAsync(1);

// this is more a compile-time proof
// since the reply is ignored, we can't check that a message was sent to it
askMeRef.Tell(new Request(Sys.IgnoreRef));

probe.ExpectNoMsg();
await probe.ExpectNoMsgAsync(default);

// but we do check that the counter has increased when we used the ActorRef.ignore
askMeRef.Tell(new Request(probe.Ref));
probe.ExpectMsg(3);
await probe.ExpectMsgAsync(3);
}

[Fact]
Expand All @@ -55,14 +56,14 @@ public void IgnoreActorRef_should_make_a_Future_timeout_when_used_in_a_ask()
}

[Fact]
public void IgnoreActorRef_should_be_watchable_from_another_actor_without_throwing_an_exception()
public async Task IgnoreActorRef_should_be_watchable_from_another_actor_without_throwing_an_exception()
{
var probe = CreateTestProbe("probe-response");
var forwardMessageRef = Sys.ActorOf(Props.Create(() => new ForwardMessageWatchActor(probe)));

// this proves that the actor started and is operational and 'watch' didn't impact it
forwardMessageRef.Tell("abc");
probe.ExpectMsg("abc");
await probe.ExpectMsgAsync("abc");
}

[Fact]
Expand Down

0 comments on commit a364879

Please sign in to comment.