Ejemplo n.º 1
0
        public void SettingsFillerTest_NoChooser()
        {
            var rawSettingsProvider = new FromFuncProvider(key => key.ToString().Last().ToString());
            var settingsFiller      = new SettingsFiller(null, rawSettingsProvider);

            Assert.AreEqual(SettingsFillerStaticDefaults.DefaultSettingsConverterChooser, settingsFiller.SettingsConverterChooser);
        }
Ejemplo n.º 2
0
        private static SettingsFiller GetBasicSettingsFiller()
        {
            var converterChooser    = new SettingsConverterChooser(new[] { new StringToFrameworkTypesConverter() });
            var rawSettingsProvider = new FromFuncProvider(key => key.ToString().Last().ToString());
            var settingsFiller      = new SettingsFiller(converterChooser, rawSettingsProvider);

            return(settingsFiller);
        }
        public void NotInvariantCultureTest()
        {
            var converterChooser    = new SettingsConverterChooser(new[] { new StringToFrameworkTypesConverter() });
            var rawSettingsProvider = new FromFuncProvider(_ => "1 000,1");
            var settingsFiller      = new SettingsFiller(converterChooser, rawSettingsProvider);

            Assert.ThrowsException <RapidSettingsException>(() => settingsFiller.CreateWithSettings <NonInvariantDoubleSettings>());
        }
Ejemplo n.º 4
0
        public void FromFuncProviderTest_SimpleRetrieval()
        {
            var fromFuncProvider = new FromFuncProvider(key => key == "ExistingKey" ? "ExistingKeyValue" : null);

            var existingKeyValue = fromFuncProvider.GetRawSetting("ExistingKey");

            Assert.AreEqual("ExistingKeyValue", existingKeyValue);
        }
Ejemplo n.º 5
0
        public void FromFuncProviderTest_NonExistingRetrieval()
        {
            var fromFuncProvider = new FromFuncProvider(key => key == "ExistingKey" ? "ExistingKeyValue" : null);

            var notExistingKeyValue = fromFuncProvider.GetRawSetting("NotExistingKey");

            Assert.IsNull(notExistingKeyValue, "Not existing key value is not null!");
        }
Ejemplo n.º 6
0
        private static SettingsFiller GetAdvancedSettingsFiller()
        {
            var converterChooser     = new SettingsConverterChooser(new IRawSettingsConverter[] { new StringToFrameworkTypesConverter(), new SuperConverter() });
            var funcSettingsProvider = new FromFuncProvider(key => new C());
            var envSettingsProvider  = new FromEnvironmentProvider();
            var settingsFiller       = new SettingsFiller(converterChooser, new Dictionary <string, IRawSettingsProvider> {
                { "func", funcSettingsProvider }, { "env", envSettingsProvider }
            }, funcSettingsProvider);

            return(settingsFiller);
        }
Ejemplo n.º 7
0
        public void FromFuncProviderTest_NullRetrieval()
        {
            var fromFuncProvider = new FromFuncProvider(key => key == "ExistingKey" ? "ExistingKeyValue" : null);

            var nullKeyValue = fromFuncProvider.GetRawSetting(null);
        }