private static ILogger GetLog(string xml) { var configReader = new StandaloneConfigurationReader(xml); LogManager.Reset(configReader); return(LogManager.GetLogger(typeof(LogManagerTests))); }
public void logging_trace_short_cut_test() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <loggerAdapter type='TRACE'/> </logging>"; var reader = new StandaloneConfigurationReader(xml); var setting = reader.GetSection(null) as LogSetting; setting.Should().NotBeNull(); setting.FactoryAdapterType.Should().Be(typeof(TraceLoggerAdapter)); }
public void logging_no_key_element_for_adapter_arguments_test() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <loggerAdapter type='Ucoin.Framework.Logging.Simple.ConsoleOutLoggerAdapter, Ucoin.Framework.Logging'> <arg kez='level' value='DEBUG' /> </loggerAdapter> </logging>"; var reader = new StandaloneConfigurationReader(xml); var exception = Assert.Throws <ConfigurationException>(delegate { reader.GetSection(null); }); exception.Message.Should().Be("Required Attribute 'key' not found in element 'arg'"); }
public void logging_too_many_adapter_elements_test() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <loggerAdapter type='Ucoin.Framework.Logging.Simple.ConsoleOutLoggerAdapter, Ucoin.Framework.Logging'> </loggerAdapter> <loggerAdapter type='Ucoin.Framework.Logging.Simple.ConsoleOutLoggerAdapter, Ucoin.Framework.Logging'> </loggerAdapter> </logging>"; var reader = new StandaloneConfigurationReader(xml); var exception = Assert.Throws <ConfigurationException>(delegate { reader.GetSection(null); }); exception.Message.Should().Be("Only one <loggerAdapter> element allowed"); }
public void logging_argument_keys_case_insensitive_test() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <loggerAdapter type='CONSOLE'> <arg key='LeVel1' value='DEBUG' /> <arg key='LEVEL2' value='DEBUG' /> <arg key='level3' value='DEBUG' /> </loggerAdapter> </logging>"; var reader = new StandaloneConfigurationReader(xml); var setting = reader.GetSection(null) as LogSetting; setting.Should().NotBeNull(); setting.Properties.Count.Should().Be(3); var expectedValue = "DEBUG"; setting.Properties.Get("level1").Should().Be(expectedValue); setting.Properties.Get("level2").Should().Be(expectedValue); setting.Properties.Get("level3").Should().Be(expectedValue); }