コード例 #1
0
        public void ConfigurationAggregatesCommonMachineAndApplication()
        {
            string appName     = $"{nameof(ConfigurationAggregatesCommonMachineAndApplication)}_TestAppName";
            string machineName = $"{nameof(ConfigurationAggregatesCommonMachineAndApplication)}_TestMachineName";
            CoreConfigurationService configSvc = GetTestCoreConfigurationService(nameof(ConfigurationAggregatesCommonMachineAndApplication));

            configSvc.SetCommonConfiguration(new Dictionary <string, string>
            {
                { "CommonKey1", "CommonValue1" },
                { "CommonKey2", "CommonValue2" },
                { "CommonOverride", "BAD-Comomon" },
                { "CommonOverride2", "BAD-Common" }
            });
            configSvc.SetMachineConfiguration(machineName, new Dictionary <string, string>
            {
                { "MachineKey1", "MachineValue1" },
                { "MachineKey2", "MachineValue2" },
                { "MachineOverride", "BAD-Machine" },
                { "CommonOverride2", "GOOD-Machine" }
            });
            configSvc.SetApplicationConfiguration(new Dictionary <string, string>
            {
                { "ApplicationKey1", "ApplicationValue1" },
                { "ApplicationKey2", "ApplicationValue2" },
                { "CommonOverride", "GOOD-AppOverrideCommon" },
                { "MachineOverride", "GOOD-AppOverrideMachine" }
            }, appName);
            ApplicationConfiguration appConfig = configSvc.GetConfiguration(appName, machineName);

            AssertExpectations(appConfig);
        }
コード例 #2
0
        public void CanSetAndGetCommonMachineConfig()
        {
            string machineName                 = $"{nameof(CanSetAndGetCommonMachineConfig)}_TestMachineName";
            string configurationName           = $"{nameof(CanSetAndGetCommonMachineConfig)}_TestConfigName";
            CoreConfigurationService configSvc = GetTestCoreConfigurationService(nameof(CanSetAndGetCommonMachineConfig));

            configSvc.SetMachineConfiguration(machineName, new Dictionary <string, string>
            {
                { "key1", "value1" }
            });

            configSvc.SetMachineConfiguration(machineName, new Dictionary <string, string>
            {
                { "key1", "value1" },
                { "key2", "value2" }
            });

            Dictionary <string, string> config = configSvc.GetMachineConfiguration(machineName);

            Expect.AreEqual(2, config.Keys.Count);
            Expect.AreEqual(2, config.Values.Count);
            Expect.AreEqual("value1", config["key1"]);
            Expect.AreEqual("value2", config["key2"]);
        }
コード例 #3
0
        public void ApplicationSettingOverridesMachine()
        {
            string appName                     = $"{nameof(ApplicationSettingOverridesMachine)}_TestAppName";
            string configurationName           = $"{nameof(ApplicationSettingOverridesMachine)}_TestConfigName";
            string expectedValue               = "ApplicationValue";
            string machineName                 = Machine.Current.Name;
            CoreConfigurationService configSvc = GetTestCoreConfigurationService(nameof(ApplicationSettingOverridesMachine));

            configSvc.SetMachineConfiguration(machineName, new Dictionary <string, string>
            {
                { "key1", "MachineValue" }
            }, configurationName);
            configSvc.SetApplicationConfiguration(new Dictionary <string, string>
            {
                { "key1", expectedValue },
                { "key2", "value2" }
            }, appName, configurationName);

            Dictionary <string, string> config = configSvc.GetConfiguration(appName, machineName, configurationName).ToDictionary();

            Expect.AreEqual(expectedValue, config["key1"]);
            Expect.AreEqual("value2", config["key2"]);
        }