-
Notifications
You must be signed in to change notification settings - Fork 12
/
DiPropsFailTest.cs
46 lines (39 loc) · 1.41 KB
/
DiPropsFailTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
});
}
}
}