Beispiel #1
0
        public void TestForSensorNodeDisconnectionWhileInUse()
        {
            Console.WriteLine("Please ensure that the sensor arduino ('sens') is connected for this test. Press ENTER when ready");
            Console.ReadLine();

            ArduinoCommsBase sensorArduino = new SensorNodeArduino(mLogger);
            TestDelegate     connectDel    = new TestDelegate(delegate() { sensorArduino.StartArduinoComms(); });

            Assert.DoesNotThrow(connectDel);
            Assert.IsTrue(sensorArduino.IsConnected);

            sensorArduino.ToggleHeartbeat(true, 500, 3);

            Console.WriteLine(string.Format("Arduino {0} has now been connected. The test will validate behaviour when it is unplugged. Uplug the arduino to continue", sensorArduino.ArduinoID));

            System.Threading.ManualResetEvent disconnectEvent = new System.Threading.ManualResetEvent(false);
            sensorArduino.Disconnected += delegate(ArduinoCommsBase ard)
            {
                disconnectEvent.Set();
            };

            disconnectEvent.WaitOne();
            Assert.IsFalse(sensorArduino.IsConnected);

            Assert.DoesNotThrow(delegate() { sensorArduino.StopArduinoComms(true); });
        }
Beispiel #2
0
        public void TestArduinoEnumeration()
        {
            ArduinoCommsBase motorArduino     = new MotorControllerArduino(mLogger);
            ArduinoCommsBase sensorArduino    = new SensorNodeArduino(mLogger);
            TestDelegate     sensorConnectDel = new TestDelegate(delegate() { sensorArduino.StartArduinoComms(); });
            TestDelegate     motorConnectDel  = new TestDelegate(delegate() { motorArduino.StartArduinoComms(); });

            Assert.DoesNotThrow(motorConnectDel);
            Assert.DoesNotThrow(sensorConnectDel);

            Assert.IsTrue(sensorArduino.IsConnected);
            Assert.IsTrue(motorArduino.IsConnected);

            Assert.DoesNotThrow(delegate() { motorArduino.StopArduinoComms(true); });
            Assert.DoesNotThrow(delegate() { sensorArduino.StopArduinoComms(true); });

            Assert.IsFalse(motorArduino.IsConnected);
            Assert.IsFalse(sensorArduino.IsConnected);
        }