private IActorRef CreateTestSensor(SensorIdentifier sensorIdentifier = null)
        {
            if (sensorIdentifier is null)
            {
                sensorIdentifier = new SensorIdentifier(1);
            }

            return(Sys.ActorOf(TemperatureSensorActor.Props(sensorIdentifier)));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }