Exemplo n.º 1
0
        public void Check_For_Nullable()
        {
            var dict = new Dictionary <string, string>
            {
                { "Test", "20" },
                { "TestBool", "true" }
            };

            EnvironmentVariableSource.SetEnvironment(dict);
            EnvironmentVariableRepository.SetConfigurationType(ConfigurationTypeEnum.PreferEnvironment);
            var output = ConfigurationParser.Parse <NullableClass>(EnvironmentVariableRepository);

            Assert.Equal(20, output.Test);
            Assert.True(output.TestBool);
            Assert.Null(output.NotRequired);
        }
Exemplo n.º 2
0
        public void Environment_Only()
        {
            var values = new[]
            {
                "Test=fromFile",
            };

            var dict = new Dictionary <string, string>
            {
                { "Test", "fromEnv" }
            };

            EnvironmentVariableSource.SetEnvironment(dict);
            FileSource.SetEnvironment(values);
            EnvironmentVariableRepository.SetConfigurationType(ConfigurationTypeEnum.EnvironmentOnly);
            var output = ConfigurationParser.Parse <ConfigurationClass>(EnvironmentVariableRepository);

            Assert.Equal("fromEnv", output.Test);
        }
Exemplo n.º 3
0
        public void Prefer_File_Over_Environment()
        {
            var values = new[]
            {
                "Test=fromFile",
                "test=fromFile"
            };

            var dict = new Dictionary <string, string>
            {
                { "Test", "fromEnv" },
            };

            EnvironmentVariableSource.SetEnvironment(dict);
            FileSource.SetEnvironment(values);
            EnvironmentVariableRepository.SetConfigurationType(ConfigurationTypeEnum.PreferFile);
            var output = ConfigurationParser.Parse <PreferClass>(EnvironmentVariableRepository);

            Assert.Equal("fromFile", output.Test);
            Assert.Equal("fromFile", output.test);
        }