public ProjectNode(InventorySettingsRepository settingsRepository, string projectId)
     : base(
         projectId,
         IconIndex,
         settingsRepository.GetProjectSettings(projectId),
         settings => settingsRepository.SetProjectSettings((ProjectSettings)settings),
         null)
 {
     this.settingsRepository = settingsRepository;
 }
Exemplo n.º 2
0
        public void WhenIdDoesNotExist_GetProjectSettingsReturnsDefaults()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

            Assert.Throws <KeyNotFoundException>(() =>
            {
                repository.GetProjectSettings("some-project");
            });
        }
Exemplo n.º 3
0
        public void WhenProjectSettingsSaved_GetProjectSettingsReturnsData()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

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

            repository.SetProjectSettings(originalSettings);

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

            Assert.AreEqual(originalSettings.ProjectId, settings.ProjectId);
            Assert.AreEqual(originalSettings.Username, settings.Username);
        }
Exemplo n.º 4
0
        public void WhenProjectSettingsDeleted_GetProjectSettingsThrowsKeyNotFoundException()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

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

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

            Assert.Throws <KeyNotFoundException>(() =>
            {
                repository.GetProjectSettings(originalSettings.ProjectId);
            });
        }