Beispiel #1
0
        public void ShouldLoadConfigFromFile()
        {
            AppDomain.CurrentDomain.SetData("Key1", "AppDomain - Value1");
            AppDomain.CurrentDomain.SetData("TEST:Item2", "Value2");
            IConfigurationProvider appDomainProvider = new AppDomainDataConfigurationProvider(AppDomain.CurrentDomain);

            var type = typeof(PropertiesProviderFeature);
            IConfigurationProvider provider;
            var path = Path.GetTempFileName();

            using (var resx = type.Assembly.GetManifestResourceStream(type, "Fixtures.PropertiesFile.txt"))
            {
                File.WriteAllText(path, new StreamReader(resx).ReadToEnd());
            }

            var props = new PropertiesConfigurationProvider(path);

            provider = new AggregateConfigurationProvider(appDomainProvider, props);
            provider.GetValue("Key1").Should().Be("AppDomain - Value1");
            provider.GetValue("Key2").Should().Be("Value2");
            provider.GetValue("Key3").Should().Be("Value3");
            provider.GetValue(CommonSettings.SaltKey).Should().Be("SDFSDF@#$@#$SDVXFB@#$^%$^345345i423!(CVCBCVBXCVBCBCVBBVBXC$W#)$%:SF@#$");
            provider.GetValue("Key4").Should().BeNull();
            provider.GetValue("TEST:Item2").Should().Be("Value2");

            try
            {
                File.Delete(path);
                // disable once EmptyGeneralCatchClause
            } catch (Exception)
            {
            }
        }
        public void ShouldLoadConfig()
        {
            AppDomain.CurrentDomain.SetData("TEST:Item1", "Value1");
            AppDomain.CurrentDomain.SetData("TEST:Item2", "Value2");
            IConfigurationProvider appDomainProvider = new AppDomainDataConfigurationProvider(AppDomain.CurrentDomain);

            appDomainProvider.GetValue("TEST:Item1").Should().Be("Value1");
            appDomainProvider.GetValue("TEST:Item2").Should().Be("Value2");
            appDomainProvider.GetValue("TEST:Item3").Should().BeNull();
        }
Beispiel #3
0
        public void ShouldLoadConfigFromFileNonExist()
        {
            AppDomain.CurrentDomain.SetData("Key1", "AppDomain - Value1");
            AppDomain.CurrentDomain.SetData("TEST:Item2", "Value2");
            IConfigurationProvider appDomainProvider = new AppDomainDataConfigurationProvider(AppDomain.CurrentDomain);

            var type = typeof(PropertiesProviderFeature);
            IConfigurationProvider provider;
            var path = Path.Combine(Path.GetTempPath(), "NonExist.Something");

            var props = new PropertiesConfigurationProvider(path);

            provider = new AggregateConfigurationProvider(appDomainProvider, props);
            provider.GetValue("Key1").Should().Be("AppDomain - Value1");
            provider.GetValue("Key2").Should().BeNull();
            provider.GetValue("Key3").Should().BeNull();
//            provider.GetValue(CommonSettings.SaltKey).Should().Be("SDFSDF@#$@#$SDVXFB@#$^%$^345345i423!(CVCBCVBXCVBCBCVBBVBXC$W#)$%:SF@#$");
            provider.GetValue("Key4").Should().BeNull();
            provider.GetValue("TEST:Item2").Should().Be("Value2");
        }
Beispiel #4
0
        public void ShouldLoadConfig()
        {
            AppDomain.CurrentDomain.SetData("Key1", "AppDomain - Value1");
            AppDomain.CurrentDomain.SetData("TEST:Item2", "Value2");
            IConfigurationProvider appDomainProvider = new AppDomainDataConfigurationProvider(AppDomain.CurrentDomain);

            var type = typeof(PropertiesProviderFeature);
            IConfigurationProvider provider;

            using (var resx = type.Assembly.GetManifestResourceStream(type, "Fixtures.PropertiesFile.txt"))
            {
                var props = new PropertiesConfigurationProvider(resx);
                provider = new AggregateConfigurationProvider(appDomainProvider, props);
            }

            provider.GetValue("Key1").Should().Be("AppDomain - Value1");
            provider.GetValue("Key2").Should().Be("Value2");
            provider.GetValue("Key3").Should().Be("Value3");
            provider.GetValue(CommonSettings.SaltKey).Should().Be("SDFSDF@#$@#$SDVXFB@#$^%$^345345i423!(CVCBCVBXCVBCBCVBBVBXC$W#)$%:SF@#$");
            provider.GetValue("Key4").Should().BeNull();
            provider.GetValue("TEST:Item2").Should().Be("Value2");
        }