public void GetSection_NullFactoryAdapter_ThrowsConfigurationException() { var config = new LogConfiguration(); var reader = new LogConfigurationReader(config); Assert.Throws<ConfigurationException>(() => reader.GetSection(null)); }
public void GetSection_NullFactoryAdapter_ThrowsConfigurationException() { var config = new LogConfiguration(); var reader = new LogConfigurationReader(config); Assert.Throws <ConfigurationException>(() => reader.GetSection(null)); }
/// <summary> /// Creates a new <see cref="LogConfigurationReader"/> given a <see cref="LogConfiguration"/> object. /// </summary> /// <param name="configuration"><see cref="LogConfiguration"/> to be parsed.</param> public LogConfigurationReader(LogConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _configuration = configuration; }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); var logConfiguration = new LogConfiguration(); Configuration.GetSection("LogConfiguration").Bind(logConfiguration); LogManager.Configure(logConfiguration); }
public void GetSection_BadFactoryAdapterType_ThrowsConfigurationException() { var config = new LogConfiguration() { FactoryAdapter = new FactoryAdapterConfiguration() { Type = "SomeType, SomeAssembly" } }; var reader = new LogConfigurationReader(config); Assert.Throws <ConfigurationException>(() => reader.GetSection(null)); }
public void GetSection_EmptyFactoryAdapterType_ThrowsConfigurationException() { var config = new LogConfiguration() { FactoryAdapter = new FactoryAdapterConfiguration() { Type = "" } }; var reader = new LogConfigurationReader(config); Assert.Throws<ConfigurationException>(() => reader.GetSection(null)); }
public void GetSection_GoodFactoryAdapterType_ReturnsLogSettingWithType() { var config = new LogConfiguration() { FactoryAdapter = new FactoryAdapterConfiguration() { Type = typeof(FakeFactoryAdapter).AssemblyQualifiedName } }; var reader = new LogConfigurationReader(config); var result = reader.GetSection(null) as LogSetting; Assert.NotNull(result); Assert.AreEqual(typeof(FakeFactoryAdapter), result.FactoryAdapterType); }
public void GetSection_NoArguments_ReturnsLogSettingWithNullArguments() { var config = new LogConfiguration() { FactoryAdapter = new FactoryAdapterConfiguration() { Type = typeof(FakeFactoryAdapter).AssemblyQualifiedName } }; var reader = new LogConfigurationReader(config); var result = reader.GetSection(null) as LogSetting; Assert.NotNull(result); Assert.IsNull(result.Properties); }
public void GetSection_HasArguments_ReturnsLogSettingWithArguments() { var config = new LogConfiguration() { FactoryAdapter = new FactoryAdapterConfiguration() { Type = typeof(FakeFactoryAdapter).AssemblyQualifiedName, Arguments = new NameValueCollection { { "arg1", "value1" } } } }; var reader = new LogConfigurationReader(config); var result = reader.GetSection(null) as LogSetting; Assert.NotNull(result); Assert.AreEqual("value1", result.Properties["arg1"]); }