public void WhenSetValidVmInstanceSettings_GetVmInstanceSettingsReturnSameValues()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            repository.SetProjectSettings(new ProjectConnectionSettings()
            {
                ProjectId = "pro-1"
            });
            repository.SetVmInstanceSettings("pro-1", new VmInstanceConnectionSettings()
            {
                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);
        }
 internal ProjectNode(ConnectionSettingsRepository settingsRepository, string projectId)
     : base(
         projectId,
         IconIndex,
         settingsRepository.GetProjectSettings(projectId),
         settings => settingsRepository.SetProjectSettings((ProjectConnectionSettings)settings),
         null)
 {
     this.settingsRepository = settingsRepository;
 }
        public void WhenProjectSettingsSavedTwice_GetProjectSettingsReturnsLatestData()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            var originalSettings = new ProjectConnectionSettings()
            {
                ProjectId = "pro-1",
                Username  = "******"
            };

            repository.SetProjectSettings(originalSettings);

            originalSettings.Username = "******";
            repository.SetProjectSettings(originalSettings);

            var settings = repository.GetProjectSettings(originalSettings.ProjectId);

            Assert.AreEqual(originalSettings.ProjectId, settings.ProjectId);
            Assert.AreEqual(originalSettings.Username, settings.Username);
        }
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);

            var repository = new ConnectionSettingsRepository(hkcu.CreateSubKey(TestKeyPath));

            repository.SetProjectSettings(new ProjectConnectionSettings()
            {
                ProjectId = "project-1",
                Domain    = "project-domain"
            });

            this.service = new ConnectionSettingsService(repository);
        }
        public void WhenZoneIdDoesNotExist_GetZoneSettingsReturnsDefaults()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            repository.SetProjectSettings(new ProjectConnectionSettings()
            {
                ProjectId = "pro-1"
            });

            var settings = repository.GetZoneSettings("pro-1", "some-zone");

            Assert.AreEqual("some-zone", settings.ZoneId);
        }
        public void WhenVmInstanceIdDoesNotExist_GetVmInstanceSettingsReturnsDefaults()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            repository.SetProjectSettings(new ProjectConnectionSettings()
            {
                ProjectId = "pro-1"
            });

            var settings = repository.GetVmInstanceSettings("pro-1", "some-vm");

            Assert.AreEqual("some-vm", settings.InstanceName);
            Assert.IsNull(settings.Username);
        }
        public void WhenProjectSettingsSaved_ProjectReturnedInListProjects()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            var originalSettings = new ProjectConnectionSettings()
            {
                ProjectId = "pro-1",
                Username  = "******"
            };

            repository.SetProjectSettings(originalSettings);

            var projects = repository.ListProjectSettings();

            Assert.AreEqual(1, projects.Count());
        }
        public void WhenSetValidZoneSettings_GetZoneSettingsReturnSameValues()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            repository.SetProjectSettings(new ProjectConnectionSettings()
            {
                ProjectId = "pro-1"
            });
            repository.SetZoneSettings("pro-1", new ZoneConnectionSettings()
            {
                ZoneId   = "zone-1",
                Username = "******"
            });

            Assert.AreEqual("user-1", repository.GetZoneSettings("pro-1", "zone-1").Username);
        }
示例#9
0
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);

            var projectRepository  = new ProjectRepository(hkcu.CreateSubKey(TestKeyPath));
            var settingsRepository = new ConnectionSettingsRepository(projectRepository);

            this.service = new ConnectionSettingsService(settingsRepository);

            // Set some initial project settings.
            projectRepository.AddProject(new ProjectLocator(SampleProjectId));

            var projectSettings = settingsRepository.GetProjectSettings(SampleProjectId);

            projectSettings.RdpDomain.Value = "project-domain";
            settingsRepository.SetProjectSettings(projectSettings);
        }
        public void WhenProjectSettingsDeleted_GetProjectSettingsThrowsKeyNotFoundException()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            var originalSettings = new ProjectConnectionSettings()
            {
                ProjectId = "pro-1",
                Username  = "******"
            };

            repository.SetProjectSettings(originalSettings);
            repository.DeleteProjectSettings(originalSettings.ProjectId);

            Assert.Throws <KeyNotFoundException>(() =>
            {
                repository.GetProjectSettings(originalSettings.ProjectId);
            });
        }
示例#11
0
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);

            var projectRepository = new ProjectRepository(
                hkcu.CreateSubKey(TestKeyPath),
                new Mock <IEventService>().Object);
            var settingsRepository = new ConnectionSettingsRepository(projectRepository);

            this.service = new ConnectionSettingsService(settingsRepository);

            // Set some initial project settings.
            projectRepository.AddProjectAsync(SampleProjectId).Wait();

            var projectSettings = settingsRepository.GetProjectSettings(SampleProjectId);

            projectSettings.Domain.Value = "project-domain";
            settingsRepository.SetProjectSettings(projectSettings);
        }
        public void WhenProjectSettingsDeleted_VmInstanceSettingsAreDeletedToo()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ConnectionSettingsRepository(baseKey);

            repository.SetProjectSettings(new ProjectConnectionSettings()
            {
                ProjectId = "pro-1"
            });
            repository.SetVmInstanceSettings("pro-1", new VmInstanceConnectionSettings()
            {
                InstanceName = "vm-1",
                Username     = "******"
            });
            repository.DeleteProjectSettings("pro-1");

            Assert.Throws <KeyNotFoundException>(() =>
            {
                repository.GetVmInstanceSettings("pro-1", "vm-1");
            });
        }