static void ReadSensorsData() { try { thermometerTemperature = thermometer.ReadTemperature(); dhtData = dhtSensor.GetData(); } catch (Exception) { } //reading from DHT sensor randomly throws exceptions... }
public void Read_Valid_Temperature() { Thermometer thermometer = new Thermometer(); thermometer.FreezingPoint = -20; thermometer.BoilingPoint = 20; Assert.IsNotNull(thermometer.ReadTemperature(random.Next(-10, 10))); }
static void Main(string[] args) { Thermometer thermometer = new Thermometer(); ThermometerDisplay display1 = new ThermometerDisplay(1, thermometer); ThermometerDisplay display2 = new ThermometerDisplay(2, thermometer); ThermometerDisplay display3 = new ThermometerDisplay(3, thermometer); thermometer.AddObserver(display1); thermometer.AddObserver(display2); thermometer.AddObserver(display3); thermometer.ReadTemperature(); thermometer.RemoveObserver(display1); thermometer.ReadTemperature(); thermometer.AddObserver(display1); thermometer.ReadTemperature(); thermometer.ReadTemperature(); thermometer.ReadTemperature(); }
public void Read_valid_Custom_ThresPoint() { Thermometer thermometer = new Thermometer(); thermometer.FreezingPoint = 20; thermometer.BoilingPoint = -20; thermometer.CustomThresholdPoint = 12; var temperature = thermometer.ReadTemperature(12, ThresholdPoint.CustomPoint); Assert.AreEqual(temperature.Status, ThresholdPoint.CustomPoint); }
public void Set_Null_Boiling_FreezingPoint() { Thermometer thermometer = new Thermometer(); Assert.ThrowsException <NullReferenceException>(() => thermometer.ReadTemperature(random.Next(-10, 10))); }