public Thermostat ThermostatWithSerial(string serial) { var thermostat = thermostats.Find(t => t.Serial == serial); if (thermostat == null) { thermostat = new Thermostat(); thermostat.Serial = serial; thermostats.Add(thermostat); } return(thermostat); }
public void GivesExistingThermostatBySerialWhenExists() { var thermostat = new Thermostat { Serial = "Thermostat1" }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat); Assert.AreSame(thermostat, thermostats.ThermostatWithSerial("Thermostat1")); }
public void KnowsWhenWeHaveNoSecretAndUuidForThermostat() { var thermostat = new Thermostat { Serial = "Thermostat1" }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat); Assert.IsFalse(thermostats.HasSecretAndUuidFor("Thermostat1")); }
public void KnowsThatUuidIsNotEnoughForSecretAndUuid() { var thermostat = new Thermostat { Serial = "Thermostat1", Uuid = "5D7000A0-0D45-41FC-B6AD-08CB8BC149B9", }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat); Assert.IsFalse(thermostats.HasSecretAndUuidFor("Thermostat1")); }
public void KnowsThatSecretIsNotEnoughForSecretAndUuid() { var thermostat = new Thermostat { Serial = "Thermostat1", SecretKey = "ABC" }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat); Assert.IsFalse(thermostats.HasSecretAndUuidFor("Thermostat1")); }
public void KnowsWhenWeHaveSecretAndUuidForThermostat() { var thermostat = new Thermostat { Serial = "Thermostat1", Uuid = "5D7000A0-0D45-41FC-B6AD-08CB8BC149B9", SecretKey = "ABC" }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat); Assert.IsTrue(thermostats.HasSecretAndUuidFor("Thermostat1")); }
public void CanSaveToFile() { var from = DateTime.Now; var to = from.AddDays(2); var thermostat1 = new Thermostat { Name = "Thermostat1", SecretKey = "ABC", Uuid = "UUID123", Temperature = "encoded-temperature-1", UpdatedSetPointTemperature = Temperature.FromDegreesCelcius(22), HasUpdatedVacationPeriod = true, UpdatedVacationPeriod = new Period(from, to) }; var thermostat2 = new Thermostat { Name = "Thermostat2", SecretKey = "DEF", Temperature = "encoded-temperature-2" }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat1); thermostats.thermostats.Add(thermostat2); thermostats.Write(); var readThermostats = Thermostats.Read(); Assert.AreEqual(2, readThermostats.thermostats.Count); var firstReadThermostat = readThermostats.thermostats[0]; Assert.AreEqual("Thermostat1", firstReadThermostat.Name); Assert.AreEqual("ABC", firstReadThermostat.SecretKey); Assert.AreEqual("UUID123", firstReadThermostat.Uuid); Assert.AreEqual("encoded-temperature-1", firstReadThermostat.Temperature); Assert.AreEqual(22, firstReadThermostat.UpdatedSetPointTemperature.InDegreesCelcius); Assert.IsTrue(firstReadThermostat.HasUpdatedVacationPeriod); Assert.AreEqual(from, firstReadThermostat.UpdatedVacationPeriod.From); Assert.AreEqual(to, firstReadThermostat.UpdatedVacationPeriod.To); }
public void CanRemoveThermostatWithSerial() { var thermostat1 = new Thermostat { Serial = "Thermostat1" }; var thermostat2 = new Thermostat { Serial = "Thermostat2" }; var thermostats = new Thermostats(); thermostats.thermostats.Add(thermostat1); thermostats.thermostats.Add(thermostat2); thermostats.RemoveThermostatWithSerial("Thermostat1"); Assert.AreEqual(1, thermostats.thermostats.Count); Assert.AreEqual("Thermostat2", thermostats.thermostats[0].Serial); }