TestKitBase - reyou/Ggg.AkkaNET GitHub Wiki

Project File

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Akka" Version="1.3.11" />
    <PackageReference Include="Akka.TestKit" Version="1.3.11" />
    <PackageReference Include="Akka.TestKit.Xunit2" Version="1.3.11" />
    <PackageReference Include="FluentAssertions" Version="5.6.0" />
  </ItemGroup>

</Project>

Program.cs

  class Program
    {
        static void Main(string[] args)
        {
            TestKit testKit = new TestKit();
            ActorSystem actorSystem = testKit.Sys;
            using (actorSystem)
            {
                // TestKit-based probe which allows sending, reception and reply.
                TestProbe probe = testKit.CreateTestProbe("test-probe");
                IActorRef deviceActor = actorSystem.ActorOf(Device.Props("group", "device"));
                IActorRef probeRef = probe.Ref;
                deviceActor.Tell(new MainDevice.ReadTemperature(requestId: 42), probeRef);
                RespondTemperature response = probe.ExpectMsg<RespondTemperature>();
                response.RequestId.Should().Be(42);
                response.Value.Should().BeNull();
                Console.WriteLine("UserMessage: App is finished.");
                // Exit the system after ENTER is pressed
                Console.ReadLine();
            }

        }
    }
⚠️ **GitHub.com Fallback** ⚠️