forked from akkadotnet/akka.net
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added initial reproduction for akkadotnet#7247
- Loading branch information
1 parent
260aee9
commit b025b9e
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="7247BugFixSpec.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2024 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2024 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.TestKit; | ||
using Xunit; | ||
|
||
namespace Akka.Tests.Actor.Scheduler; | ||
|
||
public class BugFix7247Spec : AkkaSpec { | ||
public sealed class NoCellActorRef : MinimalActorRef | ||
{ | ||
public NoCellActorRef(ActorPath path, TaskCompletionSource<object> firstMessage) | ||
{ | ||
Path = path; | ||
FirstMessage = firstMessage; | ||
} | ||
|
||
protected override void TellInternal(object message, IActorRef sender) | ||
{ | ||
FirstMessage.TrySetResult(message); | ||
} | ||
|
||
public TaskCompletionSource<object> FirstMessage { get; } | ||
|
||
public override ActorPath Path { get; } | ||
public override IActorRefProvider Provider => throw new NotImplementedException(); | ||
} | ||
|
||
[Fact(DisplayName = "Should not send ScheduledTellMsg envelopes to IActorRefs with no cell")] | ||
public async Task ShouldNotSendScheduledTellMsgToNoCellActorRefs() | ||
{ | ||
// arrange | ||
var noCellPath = new RootActorPath(Address.AllSystems); | ||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously); | ||
var noCellRef = new NoCellActorRef(noCellPath, tcs); | ||
|
||
// act | ||
var msg = "hit"; | ||
Sys.Scheduler.ScheduleTellOnce(TimeSpan.FromMicroseconds(1), noCellRef, msg, ActorRefs.NoSender); | ||
var respMsg = await tcs.Task; | ||
|
||
// assert | ||
Assert.Equal(msg, respMsg); | ||
} | ||
} |