public UDiskDevice GetUSBDevice() { // Just return the first USB device we find. Throw if there isn't one. var uDisks = new UDisks(); foreach (var device in uDisks.EnumerateDeviceOnInterface("usb")) { return new UDiskDevice(device); } throw new DriveNotFoundException("No USB drive available. Insert a USB drive for this test"); }
public void EnumerateUSB_HasOnlyPartitions() { var disks = new UDisks(); var devices = disks.EnumerateDeviceOnInterface("usb"); Assert.Greater(devices.Count(), 0); foreach (var device in devices) { var uDiskDevice = new UDiskDevice(device); Assert.AreEqual("True", uDiskDevice.GetProperty("DeviceIsPartition"), String.Format("Device {0} does not have a partition", device) ); } }
public void EnumerateUSB_HasOnlyUSBDevices() { var disks = new UDisks(); var devices = disks.EnumerateDeviceOnInterface("usb"); Assert.Greater(devices.Count(), 0); // Check that the devices don't exist on any interface other than usb foreach (var device in devices) { var uDiskDevice = new UDiskDevice(device); string iface = uDiskDevice.GetProperty("DriveConnectionInterface"); Assert.AreEqual("usb", iface); } }
public new static List<IUsbDriveInfo> GetDrives() { var drives = new List<IUsbDriveInfo>(); var uDisks = new UDisks(); // ReSharper disable LoopCanBeConvertedToQuery foreach (string device in uDisks.EnumerateDeviceOnInterface("usb")) // ReSharper restore LoopCanBeConvertedToQuery { var deviceInfo = new UsbDriveInfoUDisks(device); if (deviceInfo.IsReady) { drives.Add(deviceInfo); } } return drives; }
public new static List <IUsbDriveInfo> GetDrives() { var drives = new List <IUsbDriveInfo>(); var uDisks = new UDisks(); // ReSharper disable LoopCanBeConvertedToQuery foreach (string device in uDisks.EnumerateDeviceOnInterface("usb")) // ReSharper restore LoopCanBeConvertedToQuery { var deviceInfo = new UsbDriveInfoUDisks(device); if (deviceInfo.IsReady) { drives.Add(deviceInfo); } } return(drives); }
public void EnumerateDeviceFiles_HasSome() { var disks = new UDisks(); var deviceFiles = disks.Interface.EnumerateDeviceFiles(); Assert.Greater(deviceFiles.Count(), 0); }
public void EnumeratePorts_HasSome() { var disks = new UDisks(); var ports = disks.Interface.EnumeratePorts(); Assert.Greater(ports.Count(), 0); }
public void EnumerateExpanders_HasNone() { var disks = new UDisks(); var expanders = disks.Interface.EnumerateExpanders(); Assert.AreEqual(0, expanders.Count()); }
public void EnumerateAdapters_HasSome() { var disks = new UDisks(); var adapters = disks.Interface.EnumerateAdapters(); Assert.Greater(adapters.Count(), 0); }