public void GetDevices() { var ftdi = new FtdiI2cCore(0, _logger); if (!ftdi.GetDeviceByIndex(0, out var device)) { Assert.Fail("Failed searching for devices"); } //Assert.IsTrue(listOfDevices.Count > 0, "Device List had no elements and expected one. Is it plugged in?"); }
public async Task TestReconnect() { var ftdi = new FtdiI2cCore(0, _logger); // First have it connected in this test. if (!ftdi.GetDeviceByIndex(0, out var device)) { Assert.Fail("Failed searching for devices"); } Assert.IsNotNull(device, "Please plugin device for this test"); var checkCount = 0; while (true) { if (!ftdi.GetDeviceByIndex(0, out device)) { Assert.Fail("Failed searching for devices"); } // Wait for it have no devices if (device == null) { break; } await Task.Delay(500); checkCount++; if (checkCount == 20) { Assert.Fail("Never detected device disconnection"); } } checkCount = 0; while (true) { if (!ftdi.GetDeviceByIndex(0, out device)) { Assert.Fail("Failed searching for devices"); } // Wait for it have no devices if (device != null) { break; } await Task.Delay(500); checkCount++; if (checkCount == 20) { Assert.Fail("Never detected device reconnection"); } } }