public void GetDeviceByIdentifier_shouldReturnDeviceWithMatchingIdentifier() { DeviceCollection collection = new DeviceCollection(); Device testDevice = new Device(); testDevice.Identifier = "usb:54321"; testDevice.Name = "Test device"; collection.Devices.Add(testDevice); Assert.AreEqual(testDevice, collection.GetDeviceWithIdentifier("usb:54321")); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:12345")); }
public void GetDeviceByIdentifier_shouldReturnNullWhenNoDeviceWithProvidedIdentifier() { DeviceCollection collection = new DeviceCollection(); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:12345")); Device testDevice = new Device(); testDevice.Identifier = "usb:54321"; testDevice.Name = "Test device"; collection.Devices.Add(testDevice); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:12345")); }
private void AddNewDeviceFromWizardDataStore(Wizard wizard) { CompatibleDevice device = (CompatibleDevice)wizard.DataStore[WizardDataStoreKeys.DEVICE]; String name = (String)wizard.DataStore[WizardDataStoreKeys.NAME]; bool openDevicePanel = (bool)wizard.DataStore[WizardDataStoreKeys.OPEN_PLAYLIST_PANEL]; DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices"); if (deviceCollection.GetDeviceWithIdentifier(device.Identifier) != null) { MessageBox.Show(this, "The device you are adding has already been added. You can only " + "add a device once.\n\nIf you want several playlists synchronized to the same " + "device, use the Playlists view to assign more playlists to your device.", "Device already added", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Device newDevice = new Device(); newDevice.Identifier = device.Identifier; newDevice.Name = name; deviceCollection.Devices.Add(newDevice); FlushDeviceConfigurationToFile(); RefreshDevicesList(); if (openDevicePanel) { mainForm.SwithcToMyDevicesPanel(); } }
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")); }