-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Akka.TestKit] TestKitBase should take arbitrary ActorSystem without …
- Loading branch information
Showing
2 changed files
with
63 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,59 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="TestKitSpec.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using Akka.Actor; | ||
using Akka.Actor.Dsl; | ||
using Akka.Configuration; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using FluentAssertions; | ||
using static FluentAssertions.FluentActions; | ||
|
||
namespace Akka.TestKit.Tests | ||
{ | ||
public class TestKitSpec | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
|
||
public TestKitSpec(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
[Fact(DisplayName = "TestKit should accept arbitrary ActorSystem")] | ||
public void TestKitBaseTest() | ||
{ | ||
using (var sys = ActorSystem.Create(nameof(TestKitSpec))) | ||
{ | ||
var testkit = new TestKit.Xunit2.TestKit(sys, _output); | ||
var echoActor = testkit.Sys.ActorOf(c => c.ReceiveAny((m, ctx) => testkit.TestActor.Tell(m))); | ||
Invoking(() => | ||
{ | ||
echoActor.Tell("message"); | ||
var message = testkit.ExpectMsg<string>(); | ||
message.Should().Be("message"); | ||
}).Should().NotThrow<ConfigurationException>(); | ||
} | ||
} | ||
|
||
[Fact(DisplayName = "TestKit should accept ActorSystem with TestKit.DefaultConfig")] | ||
public void TestKitConfigTest() | ||
{ | ||
using (var sys = ActorSystem.Create(nameof(TestKitSpec), TestKit.Xunit2.TestKit.DefaultConfig)) | ||
{ | ||
var testkit = new TestKit.Xunit2.TestKit(sys, _output); | ||
var echoActor = testkit.Sys.ActorOf(c => c.ReceiveAny((m, ctx) => testkit.TestActor.Tell(m))); | ||
Invoking(() => | ||
{ | ||
echoActor.Tell("message"); | ||
var message = testkit.ExpectMsg<string>(); | ||
message.Should().Be("message"); | ||
}).Should().NotThrow<ConfigurationException>(); | ||
} | ||
} | ||
} | ||
} |
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