private Domain.Entities.Thermostat Given_AThermostat()
 {
     _thermostatToMock = new Domain.Entities.Thermostat(
         id: _faker.Random.AlphaNumeric(5),
         name: _faker.Random.Word(),
         brand: _faker.Random.Word(),
         model: _faker.Random.Word())
     {
         Settings = new ThermostatSettings(
             hvacMode: _faker.Random.Word(),
             desiredHeat: 500,
             desiredCool: 800,
             heatRangeHigh: 510,
             heatRangeLow: 490,
             coolRangeHigh: 810,
             coolRangeLow: 790,
             heatCoolMinDelta: 0),
         Reading = new ThermostatReading(
             dateTime: DateTime.UtcNow,
             temperatureInF: 750,
             humidity: 50),
         Scenes = new ThermostatScene[]
         {
             new ThermostatScene(
                 type: "template",
                 name: "_Default_",
                 running: true,
                 coolHoldTemp: 870,
                 heatHoldTemp: 450)
         }
     };
     return(_thermostatToMock);
 }
        private ThermostatModel Transform(Domain.Entities.Thermostat thermostat)
        {
            var model = new ThermostatModel
            {
                CorrelationId = _message.CorrelationId,
                Name          = thermostat.Name
            };

            if (_message.IncludeReadings)
            {
                model.Reading = _mapper.Map <ThermostatReadingModel>(thermostat.Reading);
            }

            if (_message.IncludeSettings)
            {
                model.Settings = _mapper.Map <ThermostatSettingsModel>(thermostat.Settings);
            }

            if (_message.IncludeScenes)
            {
                model.Scenes = _mapper.Map <IEnumerable <ThermostatSceneModel> >(thermostat.Scenes);
            }

            return(model);
        }
Пример #3
0
        public static IEnumerable <Domain.Entities.Thermostat> Parse(dynamic json)
        {
            var thermostats         = new List <Domain.Entities.Thermostat>();
            var numberOfThermostats = json.thermostatList.Count;

            foreach (int index in Enumerable.Range(0, numberOfThermostats))
            {
                var thermostatJson = json.thermostatList[index];
                Domain.Entities.Thermostat thermostat = CreateThermostat(thermostatJson);

                thermostat.Reading  = CreateReading(thermostatJson);
                thermostat.Settings = CreateSettings(thermostatJson);
                thermostat.Scenes   = CreateScenes(thermostatJson);
                thermostats.Add(thermostat);
            }
            return(thermostats);
        }