Skip to content

Commit

Permalink
Documentation fix #6342. (#6343)
Browse files Browse the repository at this point in the history
  • Loading branch information
F0b0s authored Jan 16, 2023
1 parent 459a160 commit 2c3b5db
Showing 1 changed file with 0 additions and 98 deletions.
98 changes: 0 additions & 98 deletions src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,104 +18,6 @@ public static partial class MainDeviceGroup
{
public class DeviceGroupSpec : TestKit
{
[Fact]
public void DeviceGroup_actor_must_be_able_to_register_a_device_actor()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));

groupActor.Tell(new RequestTrackDevice("group", "device1"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();
var deviceActor1 = probe.LastSender;

groupActor.Tell(new RequestTrackDevice("group", "device2"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();
var deviceActor2 = probe.LastSender;
deviceActor1.Should().NotBe(deviceActor2);

// Check that the device actors are working
deviceActor1.Tell(new RecordTemperature(requestId: 0, value: 1.0), probe.Ref);
probe.ExpectMsg<TemperatureRecorded>(s => s.RequestId == 0);
deviceActor2.Tell(new RecordTemperature(requestId: 1, value: 2.0), probe.Ref);
probe.ExpectMsg<TemperatureRecorded>(s => s.RequestId == 1);
}

[Fact]
public void DeviceGroup_actor_must_ignore_requests_for_wrong_groupId()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));

groupActor.Tell(new RequestTrackDevice("wrongGroup", "device1"), probe.Ref);
probe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}

[Fact]
public void DeviceGroup_actor_must_return_same_actor_for_same_deviceId()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));

groupActor.Tell(new RequestTrackDevice("group", "device1"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();
var deviceActor1 = probe.LastSender;

groupActor.Tell(new RequestTrackDevice("group", "device1"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();
var deviceActor2 = probe.LastSender;

deviceActor1.Should().Be(deviceActor2);
}

[Fact]
public void DeviceGroup_actor_must_be_able_to_list_active_devices()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));

groupActor.Tell(new RequestTrackDevice("group", "device1"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();

groupActor.Tell(new RequestTrackDevice("group", "device2"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();

groupActor.Tell(new RequestDeviceList(requestId: 0), probe.Ref);
probe.ExpectMsg<ReplyDeviceList>(s => s.RequestId == 0
&& s.Ids.Contains("device1")
&& s.Ids.Contains("device2"));
}

[Fact]
public void DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shuts_down()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));

groupActor.Tell(new RequestTrackDevice("group", "device1"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();
var toShutDown = probe.LastSender;

groupActor.Tell(new RequestTrackDevice("group", "device2"), probe.Ref);
probe.ExpectMsg<DeviceRegistered>();

groupActor.Tell(new RequestDeviceList(requestId: 0), probe.Ref);
probe.ExpectMsg<ReplyDeviceList>(s => s.RequestId == 0
&& s.Ids.Contains("device1")
&& s.Ids.Contains("device2"));

probe.Watch(toShutDown);
toShutDown.Tell(PoisonPill.Instance);
probe.ExpectTerminated(toShutDown);

// using awaitAssert to retry because it might take longer for the groupActor
// to see the Terminated, that order is undefined
probe.AwaitAssert(() =>
{
groupActor.Tell(new RequestDeviceList(requestId: 1), probe.Ref);
probe.ExpectMsg<ReplyDeviceList>(s => s.RequestId == 1 && s.Ids.Contains("device2"));
});
}

#region group-query-integration-test
[Fact]
public void DeviceGroup_actor_must_be_able_to_collect_temperatures_from_all_active_devices()
Expand Down

0 comments on commit 2c3b5db

Please sign in to comment.