public void CanBuildCustomAuthorizationProviderFromGivenConfiguration()
        {
            CustomAuthorizationProviderData customData
                = new CustomAuthorizationProviderData("custom", typeof(MockCustomAuthorizationProvider));

            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            SecuritySettings settings = new SecuritySettings();

            settings.AuthorizationProviders.Add(customData);
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            configurationSource.Add(SecuritySettings.SectionName, settings);

            IAuthorizationProvider custom
                = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance <IAuthorizationProvider>("custom");

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomAuthorizationProvider), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomAuthorizationProvider)custom).customValue);
        }
        public void CanBuildCustomAuthorizationProviderFromSavedConfiguration()
        {
            CustomAuthorizationProviderData customData
                = new CustomAuthorizationProviderData("custom", typeof(MockCustomAuthorizationProvider));

            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            SecuritySettings settings = new SecuritySettings();

            settings.AuthorizationProviders.Add(customData);

            IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(1);

            sections[SecuritySettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            IAuthorizationProvider custom
                = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance <IAuthorizationProvider>("custom");

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomAuthorizationProvider), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomAuthorizationProvider)custom).customValue);
        }