示例#1
0
 static void ReadSensorsData()
 {
     try
     {
         thermometerTemperature = thermometer.ReadTemperature();
         dhtData = dhtSensor.GetData();
     }
     catch (Exception) { } //reading from DHT sensor randomly throws exceptions...
 }
示例#2
0
        public void Read_Valid_Temperature()
        {
            Thermometer thermometer = new Thermometer();

            thermometer.FreezingPoint = -20;
            thermometer.BoilingPoint  = 20;

            Assert.IsNotNull(thermometer.ReadTemperature(random.Next(-10, 10)));
        }
示例#3
0
        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();
        }
示例#4
0
        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);
        }
示例#5
0
        public void Set_Null_Boiling_FreezingPoint()
        {
            Thermometer thermometer = new Thermometer();

            Assert.ThrowsException <NullReferenceException>(() => thermometer.ReadTemperature(random.Next(-10, 10)));
        }