public void Should_be_able_to_use_full_type_as_provider_type()
            {
                string configSectionName = "commonProvider";
                var configSection = new ProviderConfigSection();

                configSection.Types.Add(
                    new TypeElement()
                    {
                        Name = "FooProvider",
                        Type = "CommonProvider.Tests.TestClasses.FooProvider,CommonProvider.Tests"
                    });

                configSection.Types.Add(
                    new TypeElement()
                    {
                        Name = "BarProvider",
                        Type = "CommonProvider.Tests.TestClasses.BarProvider,CommonProvider.Tests"
                    });

                configSection.Settings.Add(new ProviderSettingElement()
                {
                    Key = "GlobalTestSetting",
                    Value = "GlobalTestValue"
                });

                var providerSettingElement =
                    new ProviderSettingElement()
                    {
                        Key = "TestSetting",
                        Value = "TestValue"
                    };

                var fooProvider = new ProviderElement()
                {
                    Name = "Foo",
                    Group = "FooGroup",
                    IsEnabled = true,
                    Type = "CommonProvider.Tests.TestClasses.FooProvider,CommonProvider.Tests",
                };
                fooProvider.Settings.Add(providerSettingElement);
                configSection.Providers.Add(fooProvider);

                var barProvider = new ProviderElement()
                {
                    Name = "Bar",
                    Group = "BarGroup",
                    IsEnabled = true,
                    Type = "CommonProvider.Tests.TestClasses.BarProvider,CommonProvider.Tests",
                };
                barProvider.Settings.Add(providerSettingElement);
                configSection.Providers.Add(barProvider);

                var xmlProviderConfigSource = new XmlProviderConfigSource(configSection);
                var providerConfig = xmlProviderConfigSource.GetProviderConfiguration();

                Assert.That(providerConfig.ProviderDescriptors, Is.Not.Null);
                Assert.That(providerConfig.ProviderDescriptors.Count(), Is.EqualTo(2));
                Assert.That(providerConfig.Settings.Count, Is.EqualTo(1));
                Assert.That(providerConfig.ProviderDescriptors.Sum(x => x.ProviderSettings.Count), Is.EqualTo(2));
            }
 /// <summary>
 /// Adds a configuration element to the collection.
 /// </summary>
 /// <param name="element">The element to add.</param>
 internal void Add(ProviderElement element)
 {
     this.BaseAdd(element);
 }
 /// <summary>
 /// Adds a configuration element to the collection.
 /// </summary>
 /// <param name="element">The element to add.</param>
 internal void Add(ProviderElement element)
 {
     this.BaseAdd(element);
 }
        private Type GetProviderType(ProviderConfigSection configSection, ProviderElement providerElement)
        {
            var errorMessage = "The Type defined for Provider '{0}' is not valid.";
            Type providerType;

            var providerElementType = GetObjectType(configSection, providerElement.Type);
            if (!string.IsNullOrEmpty(providerElementType))
            {
                providerType = Type.GetType(providerElementType);
                if (providerType == null)
                {
                    throw new ConfigurationErrorsException(
                        string.Format(errorMessage, providerElement.Name));
                }
            }
            else
            {
                providerType = Type.GetType(providerElement.Type);
                if (providerType == null)
                {
                    throw new ConfigurationErrorsException(
                        string.Format(errorMessage, providerElement.Name));
                }
            }
            return providerType;
        }
            public void Should_get_enabled_providers_when_provider_settings_not_defined()
            {
                string configSectionName = "commonProvider";
                var configSection = new ProviderConfigSection();

                var providerSettingElement =
                    new ProviderSettingElement()
                    {
                        Key = "TestSetting",
                        Value = "TestValue"
                    };

                var fooProvider = new ProviderElement()
                {
                    Name = "Foo",
                    Group = "FooGroup",
                    IsEnabled = true,
                    Type = "CommonProvider.Tests.TestClasses.FooProvider,CommonProvider.Tests",
                };
                configSection.Providers.Add(fooProvider);

                var barProvider = new ProviderElement()
                {
                    Name = "Bar",
                    Group = "BarGroup",
                    IsEnabled = true,
                    Type = "CommonProvider.Tests.TestClasses.BarProvider,CommonProvider.Tests",
                };
                barProvider.Settings.Add(providerSettingElement);
                configSection.Providers.Add(barProvider);

                var xmlProviderConfigSource = new XmlProviderConfigSource(configSection);
                var providerConfig = xmlProviderConfigSource.GetProviderConfiguration();

                Assert.That(providerConfig.ProviderDescriptors, Is.Not.Null);
                Assert.That(providerConfig.ProviderDescriptors.Count(), Is.EqualTo(2));
                Assert.That(providerConfig.Settings, Is.Null);
                Assert.That(providerConfig.ProviderDescriptors.Where(x => x.ProviderSettings != null)
                    .Sum(x => x.ProviderSettings.Count), Is.EqualTo(1));
            }