public void WhenSetValidVmInstanceSettings_GetVmInstanceSettingsReturnSameValues() { var baseKey = hkcu.CreateSubKey(TestKeyPath); var repository = new InventorySettingsRepository(baseKey); repository.SetProjectSettings(new ProjectSettings() { ProjectId = "pro-1" }); repository.SetVmInstanceSettings("pro-1", new VmInstanceSettings() { InstanceName = "vm-1", Username = "******", ConnectionBar = RdpConnectionBarState.Pinned, DesktopSize = RdpDesktopSize.ScreenSize, AuthenticationLevel = RdpAuthenticationLevel.RequireServerAuthentication, ColorDepth = RdpColorDepth.DeepColor, AudioMode = RdpAudioMode.DoNotPlay, RedirectClipboard = RdpRedirectClipboard.Enabled }); var settings = repository.GetVmInstanceSettings("pro-1", "vm-1"); Assert.AreEqual("user-1", settings.Username); Assert.AreEqual(RdpConnectionBarState.Pinned, settings.ConnectionBar); Assert.AreEqual(RdpDesktopSize.ScreenSize, settings.DesktopSize); Assert.AreEqual(RdpAuthenticationLevel.RequireServerAuthentication, settings.AuthenticationLevel); Assert.AreEqual(RdpColorDepth.DeepColor, settings.ColorDepth); Assert.AreEqual(RdpAudioMode.DoNotPlay, settings.AudioMode); Assert.AreEqual(RdpRedirectClipboard.Enabled, settings.RedirectClipboard); }
public void WhenProjectIdDoesNotExist_GetVmInstanceSettingsThrowsKeyNotFoundException() { var baseKey = hkcu.CreateSubKey(TestKeyPath); var repository = new InventorySettingsRepository(baseKey); Assert.Throws <KeyNotFoundException>(() => { repository.GetVmInstanceSettings("nonexisting-project", "vm-id"); }); }
public void WhenVmInstanceIdDoesNotExist_GetVmInstanceSettingsReturnsDefaults() { var baseKey = hkcu.CreateSubKey(TestKeyPath); var repository = new InventorySettingsRepository(baseKey); repository.SetProjectSettings(new ProjectSettings() { ProjectId = "pro-1" }); var settings = repository.GetVmInstanceSettings("pro-1", "some-vm"); Assert.AreEqual("some-vm", settings.InstanceName); Assert.IsNull(settings.Username); }
public void WhenProjectSettingsDeleted_VmInstanceSettingsAreDeletedToo() { var baseKey = hkcu.CreateSubKey(TestKeyPath); var repository = new InventorySettingsRepository(baseKey); repository.SetProjectSettings(new ProjectSettings() { ProjectId = "pro-1" }); repository.SetVmInstanceSettings("pro-1", new VmInstanceSettings() { InstanceName = "vm-1", Username = "******" }); repository.DeleteProjectSettings("pro-1"); Assert.Throws <KeyNotFoundException>(() => { repository.GetVmInstanceSettings("pro-1", "vm-1"); }); }