/// <summary>   Gets the failure handler. </summary>
        /// <remarks>   ebrown, 1/3/2011. </remarks>
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are null. </exception>
        /// <param name="configuration">    The configuration. </param>
        /// <returns>   The failure handler. </returns>
        public static IFailureHandler GetFailureHandler(HttpAuthenticationConfigurationSection configuration)
        {
            if (null == configuration) { throw new ArgumentNullException("configuration"); }

            if (string.IsNullOrEmpty(configuration.FailureHandlerFactoryName))
                return null;

            return failureFactoryInstances.GetOrAdd(configuration.FailureHandlerFactoryName, (factoryName) =>
            {
                return (IFailureHandlerFactory)Activator.CreateInstance(Type.GetType(factoryName));
            }).Construct(FailureHandlerConfigurationSectionLocator.Resolve(configuration.CustomFailureHandlerConfigurationSectionName));
        }
        /// <summary>   Gets the failure handler. </summary>
        /// <remarks>   ebrown, 1/3/2011. </remarks>
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are null. </exception>
        /// <param name="configuration">    The configuration. </param>
        /// <returns>   The failure handler. </returns>
        public static IFailureHandler GetFailureHandler(HttpAuthenticationConfigurationSection configuration)
        {
            if (null == configuration)
            {
                throw new ArgumentNullException("configuration");
            }

            if (string.IsNullOrEmpty(configuration.FailureHandlerFactoryName))
            {
                return(null);
            }

            return(failureFactoryInstances.GetOrAdd(configuration.FailureHandlerFactoryName, (factoryName) =>
            {
                return (IFailureHandlerFactory)Activator.CreateInstance(Type.GetType(factoryName));
            }).Construct(FailureHandlerConfigurationSectionLocator.Resolve(configuration.CustomFailureHandlerConfigurationSectionName)));
        }
 public void GetFailureHandler_ThrowsOnInvalidConfigurationTypeName()
 {
     var config = new HttpAuthenticationConfigurationSection() { FailureHandlerFactoryName = "GobbledyGook" };
     Assert.Throws<ArgumentNullException>(() => HttpContextInspectorsLocator.GetFailureHandler(config));
 }
 public void GetFailureHandler_ReturnsNullOnNullConfiguration()
 {
     var config = new HttpAuthenticationConfigurationSection();
     Assert.Null(HttpContextInspectorsLocator.GetFailureHandler(config));
 }
        public void GetFailureHandler_ReturnsCorrectlyTypedInstance()
        {
            var config = new HttpAuthenticationConfigurationSection() { FailureHandlerFactoryName = typeof(MockConfigFactory).AssemblyQualifiedName };

            Assert.IsType<MockFailureHandler>(HttpContextInspectorsLocator.GetFailureHandler(config));
        }