Esempio n. 1
0
 public void ShouldFailIfBadIncludePathIsProvided()
 {
     Check.ThatCode(() => TomlConfig.FromFile("files/sample-with-bad-include.toml").Read <SampleConfig>())
     .Throws <TomlConfigurationException>()
     .AndWhichMessage()
     .StartsWith("Missing include");
 }
Esempio n. 2
0
        public void ShouldInheritUsingDirective()
        {
            var config = TomlConfig.FromFile("files/sample-with-include.toml")
                         .Read <SampleConfig>();

            Check.That(config.Database)
            .IsNotNull();
        }
Esempio n. 3
0
        public void ShouldParseDictionaries()
        {
            var config = TomlConfig.FromFile("files/my-application/dictionary.toml")
                         .Read <Dictionary <string, UserConfig> >();

            Check.That(config.Keys)
            .IsEquivalentTo(new [] { "User1", "User2", "User3" });
        }
Esempio n. 4
0
        public void ShouldReadEnums()
        {
            var file     = "./files/my-application/enums.toml";
            var instance = TomlConfig
                           .FromFile(file)
                           .Read <StoreConfig>();

            CompareToExpectedResult(instance, file);
        }
Esempio n. 5
0
        public void ReadConfigFromFile()
        {
            var file = "./files/my-application/common.toml";

            var config = TomlConfig
                         .FromFile(file)
                         .Read <MyApplicationConfiguration>();

            CompareToExpectedResult(config, file);
        }
Esempio n. 6
0
        public void ShouldCascadeValuesForHierarchicalValues()
        {
            var file = "./files/my-application/ftp-config.toml";

            var config = TomlConfig
                         .FromFile(file)
                         .Read <FtpConfig>();

            CompareToExpectedResult(config, file);
        }
Esempio n. 7
0
        public void RemoveDuplicationByIncludingACommonFile()
        {
            var file = "./files/my-application/staging.toml";

            var config = TomlConfig
                         .FromFile(file)
                         .Read <MyApplicationConfiguration>();

            CompareToExpectedResult(config, file);
        }
Esempio n. 8
0
        public void ReadConfigFromFileWithSecrets()
        {
            var file = "./files/my-application/production.toml";

            var config = TomlConfig
                         .FromFile(file)
                         .WithMasterKey("masterkey")
                         .Read <MyApplicationConfiguration>();

            CompareToExpectedResult(config, file);
        }
Esempio n. 9
0
        public void ReadConfigAndOverrideFromEnvironmentValue()
        {
            Environment.SetEnvironmentVariable("ApplicationName", "overriden");

            var file = "./files/my-application/common.toml";

            var config = TomlConfig
                         .FromFile(file)
                         .WithOverrideFromEnvironmentVariables() /* Override from environment values */
                         .Read <MyApplicationConfiguration>();

            Check.That(config.ApplicationName)
            .IsEqualTo("overriden");

            var config2 = TomlConfig
                          .FromFile(file)
                          /* Override by value*/
                          .WithOverride(nameof(MyApplicationConfiguration.ApplicationName), "Another Value")
                          .Read <MyApplicationConfiguration>();

            Check.That(config2.ApplicationName)
            .IsEqualTo("Another Value");
        }