public void ArgumentKeysCaseInsensitive() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='CONSOLE'> <arg key='LeVel1' value='DEBUG' /> <arg key='LEVEL2' value='DEBUG' /> <arg key='level3' value='DEBUG' /> </factoryAdapter> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); LogSetting setting = reader.GetSection(null) as LogSetting; Assert.IsNotNull(setting); Assert.AreEqual(3, setting.Properties.Count); var expectedValue = new[] { "DEBUG" }; CollectionAssert.AreEqual(expectedValue, setting.Properties.GetValues("level1")); CollectionAssert.AreEqual(expectedValue, setting.Properties.GetValues("level2")); CollectionAssert.AreEqual(expectedValue, setting.Properties.GetValues("LEVEL3")); //Assert.AreEqual( 1, setting.Properties.Count ); //Assert.AreEqual( 3, setting.Properties.GetValues("LeVeL").Length ); }
public void NoKeyElementForAdapterArguments() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging'> <arg kez='level' value='DEBUG' /> </factoryAdapter> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); reader.GetSection(null); }
public void ConsoleShortCut() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='CONSOLE'/> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); LogSetting setting = reader.GetSection(null) as LogSetting; Assert.IsNotNull(setting); Assert.AreEqual(typeof(ConsoleOutLoggerFactoryAdapter), setting.FactoryAdapterType); }
public void ArgumentKeysCaseInsensitive() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='CONSOLE'> <arg key='LeVel' value='DEBUG' /> <arg key='LEVEL' value='DEBUG' /> <arg key='level' value='DEBUG' /> </factoryAdapter> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader( xml ); LogSetting setting = reader.GetSection( null ) as LogSetting; Assert.IsNotNull( setting ); Assert.AreEqual( 1, setting.Properties.Count ); Assert.AreEqual( 3, setting.Properties.GetValues("LeVeL").Length ); }
public void TooManyAdapterElements() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging'> </factoryAdapter> <factoryAdapter type='Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging'> </factoryAdapter> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); Assert.Throws( Is.TypeOf<ConfigurationException>() .And.Message.EqualTo("Only one <factoryAdapter> element allowed") , delegate { reader.GetSection(null); }); }
public void TooManyAdapterElements() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging'> </factoryAdapter> <factoryAdapter type='Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging'> </factoryAdapter> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); Assert.Throws(Is.TypeOf <ConfigurationException>() .And.Message.EqualTo("Only one <factoryAdapter> element allowed") , delegate { reader.GetSection(null); }); }