コード例 #1
0
        public void TestThatGetSensorTypeReturnsNull()
        {
            CO2Sensor sensor     = new CO2Sensor();
            string    sensorType = sensor.GetSensorType();

            Assert.AreNotEqual(string.Empty, sensorType);
        }
コード例 #2
0
        public void TestThatIsTriggeredReturnsTrue()
        {
            CO2Sensor sensor          = new CO2Sensor();
            bool      isTriggeredTrue = sensor.Trigger() == true ? true : true;

            Assert.AreEqual(true, isTriggeredTrue);
        }
コード例 #3
0
        public void TestThatGetLocationReturnsNull()
        {
            CO2Sensor sensor   = new CO2Sensor();
            string    location = sensor.GetLocation();

            Assert.AreEqual(string.Empty, location);
        }
コード例 #4
0
        public void TestThatIsTriggeredReturnsFalse()
        {
            CO2Sensor sensor           = new CO2Sensor();
            bool      isTriggeredFalse = sensor.Trigger() == true ? false : false;

            Assert.AreEqual(false, isTriggeredFalse);
        }
コード例 #5
0
        public void TestThatGetBatteryPercentageReturnsNegativeOne()
        {
            CO2Sensor sensor            = new CO2Sensor();
            double    batteryPercentage = sensor.GetBatteryPercentage();

            Assert.AreNotEqual(-1, batteryPercentage);
        }
コード例 #6
0
        public void TestThatGetSensorTypeReturnsType()
        {
            CO2Sensor sensor     = new CO2Sensor();
            string    sensorType = sensor.GetSensorType();

            Assert.AreEqual("CO2 sensor", sensorType);
        }
コード例 #7
0
        public void TestThatSetLocationReturnsLocation()
        {
            CO2Sensor sensor = new CO2Sensor();

            sensor.SetLocation("Main Door");
            Assert.AreEqual("Main Door", sensor.GetLocation());
            sensor.SetLocation("I have changed...change is inevitable");
            Assert.AreNotEqual("Main Door", sensor.GetLocation());
            Assert.AreEqual("I have changed...change is inevitable", sensor.GetLocation());
        }
コード例 #8
0
        public void TestThatGetLocationReturnsLocation()
        {
            CO2Sensor sensor   = new CO2Sensor("Entry");
            string    location = sensor.GetLocation();

            Assert.AreEqual("Entry", location);
            CO2Sensor sensor_2   = new CO2Sensor("Kitchen");
            string    location_2 = sensor_2.GetLocation();

            Assert.AreEqual("Kitchen", location_2);
        }
コード例 #9
0
        public void TestThatIsTriggeredCanReturnTrue()
        {
            CO2Sensor   sensor  = new CO2Sensor();
            List <bool> results = new List <bool>();

            for (var i = 0; i <= 1000; i++)
            {
                results.Add(sensor.Trigger());
            }

            Assert.AreEqual(true, results.Contains(true));
        }
コード例 #10
0
        private static void datalog()
        {
            while (true)
            {
                fileLog = new FileLogger("file.log");

                // Crea ed utilizza un ADC. Il codice del ADC utilizzerà un gestore del bus SPI
                adc = new DigitalConverterMCP3208();

                lux      = new LightSensor(adc, 0, 3.3);
                temp     = new TemperatureSensor(adc, 1, 3.3);
                moisture = new SoilMoistureSensor(adc, 2, 3.3);
                co2      = new CO2Sensor(adc, 3, 4.9);
                rh       = new RelativeHumiditySensor(adc, 4, 5.0);

                shift = new OutShiftRegister(16, 25, 24, 23);

                lcd = new LCD1602Shift(shift, 12, 11, 10, 9, 13, 14);

                irrigator = new Device_OnOffShift(shift, 8);
                ////////irrigator.WriteLog += WriteFileLog;
                humidifier = new Device_OnOffShift(shift, 2);
                ////////humidifier.WriteLog += WriteFileLog;

                lightDevice = new LightDevice(shift, 3, 4, 5, 6, 7, 21, 20);

                lightDevice.PercentualeApertura(50);
                //irrigator.TimeOn(3000);

                //_timer = new DispatcherTimer();
                //_timer.Interval = TimeSpan.FromMilliseconds(1000);
                //_timer.Tick += Timer_Tick;
                //if (_pin != null)
                //{
                //    _timer.Start();
                //}
            }
        }