Implementation of IConfigurationReader that uses a supplied LogConfiguration object.
Наследование: IConfigurationReader
        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));
        }
        public void ctor_NullConfiguration_ThrowsArgumentNull()
        {
            var ex = Assert.Throws <ArgumentNullException>(() => {
                var reader = new LogConfigurationReader(null);
            });

            Assert.AreEqual("configuration", ex.ParamName);
        }
        public void ctor_NullConfiguration_ThrowsArgumentNull()
        {
            var ex = Assert.Throws<ArgumentNullException>(() => {
                var reader = new LogConfigurationReader(null);
            });

            Assert.AreEqual("configuration", ex.ParamName);
        }
        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"]);
        }
        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_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"]);
        }
        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);
        }