コード例 #1
0
        public void LastVariableAddedWhenMultipleEnvironmentVariablesWithSameNameButDifferentCaseExist()
        {
            var tempEnvFile = CreateAndLoadToEnvFile(new Dictionary <string, string>()
            {
                { "CommonEnv", "CommonEnvValue1" },
                { "commonenv", "commonenvValue2" },
                { "cOMMonEnv", "commonenvValue3" },
            });
            var envConfigSrc = new AspNetDotEnvConfigurationProvider(new FileInfo(tempEnvFile), true);

            envConfigSrc.Load();

            Assert.True(!string.IsNullOrEmpty(envConfigSrc.Get("cOMMonEnv")));
            Assert.True(!string.IsNullOrEmpty(envConfigSrc.Get("CommonEnv")));
        }
コード例 #2
0
        public void ReplaceDoubleUnderscoreInEnvironmentVariables()
        {
            var tempEnvFile = CreateAndLoadToEnvFile(new Dictionary <string, string>()
            {
                { "data__ConnectionString", "connection" },
                { "Data___db1__ProviderName", "System.Data.SqlClient" }
            });

            var envConfigSrc = new AspNetDotEnvConfigurationProvider(new FileInfo(tempEnvFile), true);

            envConfigSrc.Load();

            Assert.Equal("connection", envConfigSrc.Get("data:ConnectionString"));
            Assert.Equal("System.Data.SqlClient", envConfigSrc.Get("Data:_db1:ProviderName"));
        }
コード例 #3
0
        public void LoadKeyValuePairsFromFile()
        {
            var dict = new Dictionary <string, string>()
            {
                { "DefaultConnection:ConnectionString", "TestConnectionString" },
                { "DefaultConnection:Provider", "SqlClient" },
                { "Inventory:ConnectionString", "AnotherTestConnectionString" },
                { "Inventory:Provider", "MySql" }
            };

            var envConfigSrc = new AspNetDotEnvConfigurationProvider(new FileInfo("test.env"));

            envConfigSrc.Load();

            Assert.Equal("TestConnectionString", envConfigSrc.Get("defaultconnection:ConnectionString"));
            Assert.Equal("SqlClient", envConfigSrc.Get("DEFAULTCONNECTION:PROVIDER"));
            Assert.Equal("AnotherTestConnectionString", envConfigSrc.Get("Inventory:CONNECTIONSTRING"));
            Assert.Equal("MySql", envConfigSrc.Get("Inventory:Provider"));
        }