public void ShouldFailIfBadIncludePathIsProvided() { Check.ThatCode(() => TomlConfig.FromFile("files/sample-with-bad-include.toml").Read <SampleConfig>()) .Throws <TomlConfigurationException>() .AndWhichMessage() .StartsWith("Missing include"); }
public void ShouldInheritUsingDirective() { var config = TomlConfig.FromFile("files/sample-with-include.toml") .Read <SampleConfig>(); Check.That(config.Database) .IsNotNull(); }
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" }); }
public void ShouldReadEnums() { var file = "./files/my-application/enums.toml"; var instance = TomlConfig .FromFile(file) .Read <StoreConfig>(); CompareToExpectedResult(instance, file); }
public void ReadConfigFromFile() { var file = "./files/my-application/common.toml"; var config = TomlConfig .FromFile(file) .Read <MyApplicationConfiguration>(); CompareToExpectedResult(config, file); }
public void ShouldCascadeValuesForHierarchicalValues() { var file = "./files/my-application/ftp-config.toml"; var config = TomlConfig .FromFile(file) .Read <FtpConfig>(); CompareToExpectedResult(config, file); }
public void RemoveDuplicationByIncludingACommonFile() { var file = "./files/my-application/staging.toml"; var config = TomlConfig .FromFile(file) .Read <MyApplicationConfiguration>(); CompareToExpectedResult(config, file); }
public void ReadConfigFromFileWithSecrets() { var file = "./files/my-application/production.toml"; var config = TomlConfig .FromFile(file) .WithMasterKey("masterkey") .Read <MyApplicationConfiguration>(); CompareToExpectedResult(config, file); }
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"); }