public void AddingNullSensorThrowsException()
        {
            var hardwareController = new HardwareController();
            hardwareController.AddSensor(null);

            Assert.Fail("Exception expected.");
        }
        public void ControllerDisabledByDefault()
        {
            var hardwareController = new HardwareController();
            var dynamicSensorController = new DynamicSensorController(
                hardwareController, Assembly.GetAssembly(this.GetType()));

            Assert.AreEqual(false, dynamicSensorController.Enabled);
        }
        public void EnableController()
        {
            var hardwareController = new HardwareController();
            var dynamicSensorController = new DynamicSensorController(
                hardwareController, Assembly.GetAssembly(this.GetType()));

            dynamicSensorController.Enable();

            Assert.AreEqual(true, dynamicSensorController.Enabled);
        }
Beispiel #4
0
        public SensorPoller(HardwareController hardwareController, int delay, int maxBuffer)
        {
            if (delay < 0 || maxBuffer < 1)
            {
                throw new ArgumentException();
            }

            this.hardwareController = hardwareController;
            this.delayTime = delay;
            this.maxBufferSize = maxBuffer;
        }
Beispiel #5
0
 protected NodeController(int id, HardwareController hardwareController, NetworkController networkController)
 {
     this.ID = id;
     this.hardwareController = hardwareController;
     this.networkController = networkController;
 }
 public void GetAllSensorsWithNoSensorsReturnsEmpty()
 {
     var hardwareController = new HardwareController();
     Assert.AreEqual(0, hardwareController.GetAllSensors().Count);
 }
        public void PollSensorReadingsRemovesSensorData()
        {
            var hardwareController = new HardwareController();
            var random = new Random();

            SensorData[] sensorDatas = new SensorData[random.Next(1, 5)];
            for (int i = 0; i < sensorDatas.Length; i++)
            {
                var sensorData = new SensorData
                                     {
                                         Humidity = random.Next(0, 100) / 100,
                                         Pressure = random.Next(0, 100) / 100
                                     };

                sensorDatas[i] = sensorData;
            }

            hardwareController.AddSensorReadings(sensorDatas);
            hardwareController.PollSensorReadings(0);

            Assert.AreEqual(0, hardwareController.GetSensorDataBufferCount());
        }
        public void GetSensorDataBufferCount()
        {
            var hardwareController = new HardwareController();
            var random = new Random();

            int dataCount = random.Next(1, 5);
            for (int i = 0; i < dataCount; i++)
            {
                SensorData[] sensorDatas = new SensorData[random.Next(1, 5)];
                for (int j = 0; j < sensorDatas.Length; j++)
                {
                    var sensorData = new SensorData
                                         {
                                             Humidity = random.Next(0, 100) / 100,
                                             Pressure = random.Next(0, 100) / 100
                                         };

                    sensorDatas[j] = sensorData;
                }

                hardwareController.AddSensorReadings(sensorDatas);
            }

            Assert.AreEqual(dataCount, hardwareController.GetSensorDataBufferCount());
        }
 public DynamicSensorController(HardwareController hardwareController, Assembly assembly)
 {
     this.Enabled = false;
     this.hardwareController = hardwareController;
     this.assembly = assembly;
 }
 public FullNodeController(int ID, HardwareController hardwareController, NetworkController networkController)
     : base(ID, hardwareController, networkController)
 {
 }