コード例 #1
0
        public void WhenProjectIdDoesNotExist_GetZoneSettingsThrowsKeyNotFoundException()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

            Assert.Throws <KeyNotFoundException>(() =>
            {
                repository.GetZoneSettings("nonexisting-project", "zone-id");
            });
        }
コード例 #2
0
        public void WhenZoneIdDoesNotExist_GetZoneSettingsReturnsDefaults()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

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

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

            Assert.AreEqual("some-zone", settings.ZoneId);
        }
コード例 #3
0
        public void WhenSetValidZoneSettings_GetZoneSettingsReturnSameValues()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

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

            Assert.AreEqual("user-1", repository.GetZoneSettings("pro-1", "zone-1").Username);
        }
コード例 #4
0
        public void WhenProjectSettingsDeleted_ZoneSettingsAreDeletedToo()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new InventorySettingsRepository(baseKey);

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

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