private IActorRef CreateTestSensor(SensorIdentifier sensorIdentifier = null) { if (sensorIdentifier is null) { sensorIdentifier = new SensorIdentifier(1); } return(Sys.ActorOf(TemperatureSensorActor.Props(sensorIdentifier))); }
public void ConfirmTemperatureUpdatd() { var probe = CreateTestProbe(); var sensor = Sys.ActorOf(TemperatureSensorActor.Props("a", "1")); sensor.Tell(new RequestUpdateTemperature(42, 100), probe.Ref); probe.ExpectMsg <RespondTemperatureUpdated>(m => Assert.Equal(42, m.RequestId)); }
public void StartWithNotemperature() { var probe = CreateTestProbe(); var sensor = Sys.ActorOf(TemperatureSensorActor.Props("a", "1")); sensor.Tell(new RequestTemperature(1), probe.Ref); var recieve = probe.ExpectMsg <RespondTemperature>(); Assert.Null(recieve.Temperature); }
public void RegisterNewSensor() { var probe = CreateTestProbe(); var sensor = Sys.ActorOf(TemperatureSensorActor.Props("a", "1")); sensor.Tell(new RequestRegisterTemperatureSensor(1, "a", "1"), probe.Ref); var recieve = probe.ExpectMsg <RespondRegisterTemperatureSensor>(); Assert.Equal(1, recieve.RequestId); Assert.Equal(sensor, recieve.SensorRef); }
public void UpdateNewTemperature() { var probe = CreateTestProbe(); var sensor = Sys.ActorOf(TemperatureSensorActor.Props("a", "1")); sensor.Tell(new RequestUpdateTemperature(42, 50)); sensor.Tell(new RequestTemperature(1), probe.Ref); var recieved = probe.ExpectMsg <RespondTemperature>(); Assert.Equal(1, recieved.RequestId); Assert.Equal(50, recieved.Temperature); }
public void InitSensorMetaData() { var probe = CreateTestProbe(); var sensor = Sys.ActorOf(TemperatureSensorActor.Props("a", "1")); sensor.Tell(new RequestMetadata(1), probe.Ref); var recieve = probe.ExpectMsg <RespondMetadata>(); Assert.Equal(1, recieve.RequestId); Assert.Equal("a", recieve.FloorId); Assert.Equal("1", recieve.SensorId); }
public void NotRegisterSensorWhenFloorIsWring() { var probe = CreateTestProbe(); var eventStreamProbe = CreateTestProbe(); Sys.EventStream.Subscribe(eventStreamProbe, typeof(Akka.Event.UnhandledMessage)); var sensor = Sys.ActorOf(TemperatureSensorActor.Props("a", "1")); sensor.Tell(new RequestRegisterTemperatureSensor(1, "b", "1"), probe.Ref); probe.ExpectNoMsg(); var unhandled = eventStreamProbe.ExpectMsg <Akka.Event.UnhandledMessage>(); Assert.IsType <RequestRegisterTemperatureSensor>(unhandled.Message); }