コード例 #1
0
        private static void DomoShare_ThermostatCoolSetpointChanged(object sender, ThermostatCoolSetpointChangedEventArgs e)
        {
            var tenantId = Guid.Parse(Configuration.GetSection("AppSettings").GetSection("ControllerId").Value);
            CoolSetpointChangeCommand cmd = new CoolSetpointChangeCommand(e.TenantId, e.ThermostatId, e.ThermostatGuid, e.NewCoolSetpoint);
            ChangeCoolSetpoint        changeCoolSetpointCommand = new ChangeCoolSetpoint(EventStore, e.ThermostatId, e.ThermostatGuid,
                                                                                         e.TenantId, (double)e.NewCoolSetpoint);
            var handler = new ThermostatCommandHandlers();

            handler.Handle(changeCoolSetpointCommand);
        }
コード例 #2
0
        public void CoolSetpoint_Changed_No_Cool_Setpoint_Temperature_Should_Throw_ArgumentNullException()
        {
            ConnectToThermostatCommand cmd             = new ConnectToThermostatCommand(Guid.NewGuid(), "ThermostatId", Guid.NewGuid(), 40, 50, 80, "Cool", "Idel");
            CoolSetpointChangeCommand  coolSetpointCmd = new CoolSetpointChangeCommand(Guid.NewGuid(), "ThermostatId", Guid.NewGuid(), null);

            ChangeCoolSetpoint changeCoolSetpointCommand = new ChangeCoolSetpoint(moqEventStore.Object, cmd.ThermostatId,
                                                                                  cmd.ThermostatAggregateId, Guid.NewGuid(), coolSetpointCmd.NewCoolSetpoint);
            var handler = new ThermostatCommandHandlers();

            Assert.Throws <ArgumentNullException>(() => handler.Handle(changeCoolSetpointCommand));
        }
コード例 #3
0
        private static void DomoShare_ThermostatHumidityChanged(object sender, ThermostatHumidityChangedEventArgs e)
        {
            var tenantId = Guid.Parse(Configuration.GetSection("AppSettings").GetSection("ControllerId").Value);
            AmbientTemperatureChangeCommand cmd = new AmbientTemperatureChangeCommand(e.TenantId, e.ThermostatId,
                                                                                      e.ThermostatGuid, e.NewHumidity);
            ChangeHumidity changeHumidityCommand = new ChangeHumidity(EventStore, e.ThermostatId, e.ThermostatGuid,
                                                                      e.TenantId, (double)e.NewHumidity);
            var handler = new ThermostatCommandHandlers();

            handler.Handle(changeHumidityCommand);
        }
コード例 #4
0
        private static void DomoShare_ThermostatSystemModeChanged(object sender, ThermostatSystemModeChangedEventArgs e)
        {
            var tenantId = Guid.Parse(Configuration.GetSection("AppSettings").GetSection("ControllerId").Value);

            if (EventStore == null)
            {
                Trace.TraceInformation($"{DateTime.Now}: EventStore is null. Creating a new one");
                Console.WriteLine($"{DateTime.Now}: EventStore is null. Creating a new one");
                EventStore = EventStoreFactory.CreateEventStore();
            }
            SystemModeChangeCommand cmd = new SystemModeChangeCommand(e.TenantId, e.ThermostatId,
                                                                      e.ThermostatGuid, e.NewSystemMode);
            ChangeSystemMode changeSystemModeCommand = new ChangeSystemMode(EventStore, e.ThermostatId, e.ThermostatGuid,
                                                                            e.TenantId, e.NewSystemMode);
            var handler = new ThermostatCommandHandlers();

            handler.Handle(changeSystemModeCommand);
        }
コード例 #5
0
        public void Should_Change_AmbientTemperature_For_Thermostat()
        {
            var moqEventStore              = new Mock <IEventStore>();
            var eventMetadata              = new EventMetadata(Guid.NewGuid(), "TestCategory", "TestCorrelationId", Guid.NewGuid(), Guid.NewGuid(), DateTimeOffset.UtcNow);
            var thermostatId               = "termostatId";
            var thermostatGuid             = Guid.NewGuid();
            ConnectToThermostatCommand cmd = new ConnectToThermostatCommand(Guid.NewGuid(), thermostatId, thermostatGuid, 76, 60.9, 77.2, "Heat", "Heating", 77.4);
            List <IEvent> connected        = new List <IEvent>();

            connected.Add(new ESEvents.Common.Events.Thermostat.Connected(Guid.NewGuid(), DateTimeOffset.UtcNow, eventMetadata, 78, 56, 76, "Off", "Idel", 80));
            moqEventStore.Setup(storage => storage.GetAllEvents(It.IsAny <CompositeAggregateId>())).Returns(connected);

            var p = Domain.Thermostat.ConnectToThermostat(eventMetadata, moqEventStore.Object, cmd);
            ChangeAmbientTemperature changeAmbientTemperatureCommand = new ChangeAmbientTemperature(moqEventStore.Object, thermostatId, thermostatGuid,
                                                                                                    Guid.NewGuid(), (double)cmd.Temperature);
            var handler = new ThermostatCommandHandlers();

            handler.Handle(changeAmbientTemperatureCommand);

            Assert.IsNotNull(p.AggregateGuid);
            Assert.AreNotEqual(Guid.Empty, p.AggregateGuid);
        }