public void When_there_is_no_value_for_a_nullable_property() { var config = new StronkConfig() .From.Source(_source) .Build <NullablePropertyConfig>(); config.SomeValue.HasValue.ShouldBeFalse(); }
public void Consul_can_be_added_via_the_dsl() { var config = new StronkConfig().From.Consul() as IStronkConfig; config.ConfigSources .ShouldHaveSingleItem() .ShouldBeOfType <ConsulConfigurationSource>(); }
public ConfigBuilderTests() { _target = new TargetConfig(); _settings = new Dictionary <string, string>(); _options = new StronkConfig() .From.Source(new DictionarySource(_settings)); _builder = new ConfigBuilder(_options); }
public void When_there_is_a_value_for_a_nullable_property() { _settings["SomeValue"] = "17"; var config = new StronkConfig() .From.Source(_source) .Build <NullablePropertyConfig>(); config.SomeValue.HasValue.ShouldBeTrue(); config.SomeValue.ShouldBe(17); }
protected ValidationTests() { var source = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); source[nameof(TargetParent.ParentValue)] = "1"; source[nameof(Target.TargetValue)] = "2"; source[nameof(TargetChild.ChildValue)] = "3"; _builder = new StronkConfig(); _builder.From.Source(new DictionarySource(source)); }
public static void Main(string[] args) { Console.WriteLine("Reading from settings.json..."); Console.WriteLine(""); var config = new StronkConfig() .From.Source(new JsonConfigFile("settings.json")) .Build <Configuration>(); Console.WriteLine($"{nameof(config.Timeout)}: {config.Timeout.TotalSeconds} seconds"); Console.WriteLine($"{nameof(config.Callback)}: {config.Callback}"); }
public void When_a_property_is_selected_by_two_different_writers() { var config = new StronkConfig() .From.Source(new DictionarySource(new Dictionary <string, string> { { "TestValue", "16" } })) .Write.To(new BackingFieldPropertyWriter()) .Write.To(new PrivateSetterPropertyWriter()) .Build <MultiWriteConfig>(); config.AlreadySet.ShouldBe(false); config.TestValue.ShouldBe(16); }
public static async Task <int> Main(string[] args) { using (var consul = await LaunchConsul()) { var config = new StronkConfig() .From.Consul(prefix: ApplicationName) .Build <Configuration>(); Console.WriteLine("Values read from Consul:"); Console.WriteLine($"* {nameof(config.Timeout)}: {config.Timeout.TotalSeconds} seconds"); Console.WriteLine($"* {nameof(config.Callback)}: {config.Callback}"); consul.Close(); } return(0); }
public static void Main(string[] args) { try { Console.WriteLine("Try changing the app.config values to be invalid:"); Console.WriteLine("* Timeout should be between 1 and 120 seconds"); Console.WriteLine("* Callback should be HTTPS, and the host should be either 'localhost' or 'internal'"); Console.WriteLine(""); var config = new StronkConfig() .Validate.With <ConfigurationValidator>() .Build <Configuration>(); Console.WriteLine($"{nameof(config.Timeout)}: {config.Timeout.TotalSeconds} seconds"); Console.WriteLine($"{nameof(config.Callback)}: {config.Callback}"); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.ToString()); Console.ResetColor(); } }
public ValidationExpression(StronkConfig configRoot) { _configRoot = configRoot; _validators = new List <IValidator>(); }
public LogExpression(StronkConfig configRoot) { _configRoot = configRoot; _loggers = new List <Action <LogMessage> >(); }
public ConversionExpression(StronkConfig configRoot) { _configRoot = configRoot; _converters = new List <IValueConverter>(); _onlySpecifiedConverters = false; }
public MapExpression(StronkConfig configRoot) { _configRoot = configRoot; _selectors = new List <IPropertyMapper>(); }
public SourceExpression(StronkConfig configRoot) { _configRoot = configRoot; _sources = new List <IConfigurationSource>(); }
public WriterExpression(StronkConfig configRoot) { _configRoot = configRoot; _writers = new List <IPropertyWriter>(); }