-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing actor context on test start (#346)
- Loading branch information
Showing
3 changed files
with
61 additions
and
86 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,46 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="DiPropsFailTest.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Actor; | ||
using Akka.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Hosting.TestKit.Tests; | ||
|
||
// Regression test for https://github.com/akkadotnet/Akka.Hosting/issues/343 | ||
public class DiPropsFailTest: TestKit | ||
{ | ||
public DiPropsFailTest(ITestOutputHelper output) : base(nameof(DiPropsFailTest), output) | ||
{} | ||
|
||
protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IServiceProvider provider) | ||
{ } | ||
|
||
[Fact] | ||
public void DiTest() | ||
{ | ||
var actor = Sys.ActorOf(NonRootActorWithDi.Props()); | ||
actor.Tell("test"); | ||
ExpectMsg<string>("test"); | ||
} | ||
|
||
private class NonRootActorWithDi: ReceiveActor | ||
{ | ||
public static Props Props() => DependencyResolver.For(Context.System).Props<NonRootActorWithDi>(); | ||
|
||
public NonRootActorWithDi(ILogger<NonRootActorWithDi> log) | ||
{ | ||
ReceiveAny(msg => | ||
{ | ||
log.LogInformation("Received {Msg}", msg); | ||
Sender.Tell(msg); | ||
}); | ||
} | ||
} | ||
} |
83 changes: 0 additions & 83 deletions
83
src/Akka.Hosting.TestKit/ActorCellKeepingSynchronizationContext.cs
This file was deleted.
Oops, something went wrong.
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