Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public void CanSetAndGetCommonConfiguration()
        {
            string appName                     = $"{nameof(CanSetAndGetCommonConfiguration)}_TestAppName";
            string configurationName           = $"{nameof(CanSetAndGetCommonConfiguration)}_TestConfigName";
            CoreConfigurationService configSvc = GetTestCoreConfigurationService(nameof(CanSetAndGetCommonConfiguration));

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

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

            Expect.AreEqual(2, config.Keys.Count);
            Expect.AreEqual(2, config.Values.Count);
            Expect.AreEqual("value1", config["key1"]);
            Expect.AreEqual("value2", config["key2"]);
        }