Exemple #1
0
        private static ILogger GetLog(string xml)
        {
            var configReader = new StandaloneConfigurationReader(xml);

            LogManager.Reset(configReader);
            return(LogManager.GetLogger(typeof(LogManagerTests)));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        public void logging_no_key_element_for_adapter_arguments_test()
        {
            const string xml =
                @"<?xml version='1.0' encoding='UTF-8' ?>
            <logging>
              <loggerAdapter type='ZSharp.Framework.Logging.Simple.ConsoleOutLoggerAdapter, ZSharp.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'");
        }
Exemple #4
0
        public void logging_too_many_adapter_elements_test()
        {
            const string xml =
                @"<?xml version='1.0' encoding='UTF-8' ?>
            <logging>
              <loggerAdapter type='ZSharp.Framework.Logging.Simple.ConsoleOutLoggerAdapter, ZSharp.Framework.Logging'>
              </loggerAdapter>
              <loggerAdapter type='ZSharp.Framework.Logging.Simple.ConsoleOutLoggerAdapter, ZSharp.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");
        }
Exemple #5
0
        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);
        }