public void TestManualSequenceLightsDeviceBlink1Device()
        {
            LightsDeviceController controller = new LightsDeviceController(0x01ED, 0x27B8, 0x0001, 0xFF00, Config.GetWaitForDeviceRetryPeriod(), UsbControlTransferType.FeatureReport);
            controller.Start();
            Assert.IsTrue(controller.Running);
            int sleepTimeout = 1000;
            List<IRequest> requests = new List<IRequest>();

            // B-Y-R-Y-R-Y-G-B
            requests.Add(new StatusRequest(false));
            requests.Add(new BuildActiveRequest(true));
            requests.Add(new AttentionRequest(true));
            requests.Add(new BuildActiveRequest(true));
            requests.Add(new AttentionRequest(true, true));
            requests.Add(new BuildActiveRequest(true));
            requests.Add(new AttentionRequest(false));
            requests.Add(new StatusRequest(false));
            Thread.Sleep(sleepTimeout);
            foreach (IRequest request in requests)
            {
                if (request.GetType() == typeof(StatusRequest))
                {
                    controller.SendCommand(Parser.TranslateForBlink1((StatusRequest)request, controller.GetFeatureReportByteLength()));
                }
                else if (request.GetType() == typeof(AttentionRequest))
                {
                    controller.SendCommand(Parser.TranslateForBlink1((AttentionRequest)request, controller.GetFeatureReportByteLength()));
                }
                else if (request.GetType() == typeof(BuildActiveRequest))
                {
                    controller.SendCommand(Parser.TranslateForBlink1((BuildActiveRequest)request, controller.GetFeatureReportByteLength()));
                }

                Thread.Sleep(sleepTimeout);
            }

            controller.Stop();
        }
 public void TestGetFeatureReportByteLengthForNoDevice()
 {
     LightsDeviceController lightsDeviceController = new LightsDeviceController();
     Assert.That(lightsDeviceController.GetFeatureReportByteLength(), NUnit.Framework.Is.EqualTo(-1));
 }
        public void TestManualInsertRemoveBlink1()
        {
            object insertedLock = new object();
            object removedLock = new object();

            LightsDeviceController controller = new LightsDeviceController(0x01ED, 0x27B8, 0x0001, 0xFF00, Config.GetWaitForDeviceRetryPeriod(), UsbControlTransferType.FeatureReport);

            controller.OnDeviceInserted += (sender, args) =>
            {
                lock (insertedLock)
                {
                    Monitor.Pulse(insertedLock);
                }
            };

            controller.OnDeviceRemoved += (sender, args) =>
            {
                lock (removedLock)
                {
                    Monitor.Pulse(removedLock);
                }
            };

            controller.Start();
            Assert.IsTrue(controller.Running);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("Please insert the device");
                lock (insertedLock)
                {
                    Monitor.Wait(insertedLock);
                }

                Console.WriteLine("Device inserted");
                controller.SendCommand(Parser.TranslateForBlink1(new AttentionRequest(false), controller.GetFeatureReportByteLength()));
                Console.WriteLine("Please remove the device");
                lock (removedLock)
                {
                    Monitor.Wait(removedLock);
                }

                Console.WriteLine("Device removed");
            }

            controller.Stop();
        }