public void DeleteByIdentifier_shouldDeleteDeviceWithMatchingIdentifier() { DeviceCollection collection = new DeviceCollection(); Device testDevice = new Device(); testDevice.Identifier = "usb:54321"; testDevice.Name = "Test device"; collection.Devices.Add(testDevice); collection.DeleteByIdentifier("usb:54321"); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:54321")); }
private void btnDeleteDevice_Click(object sender, EventArgs e) { DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices"); foreach (ListViewItem listItem in lvDevices.SelectedItems) { string identifier = listItem.Name; deviceCollection.DeleteByIdentifier(identifier); } FlushDeviceConfigurationToFile(); RefreshDevicesList(); }