Beispiel #1
0
        public void ShouldCreateHandlerWithCorrectPolicy()
        {
            string policy = "Swallow Exceptions";
            ExceptionCallHandlerAttribute attribute = new ExceptionCallHandlerAttribute(policy);
            ExceptionCallHandler          handler   = (ExceptionCallHandler)attribute.CreateHandler();

            Assert.AreEqual(policy, handler.ExceptionPolicyName);
        }
Beispiel #2
0
        /// <summary>
        /// Builds an instance of the subtype of <typeparamref name="TObject"/> type the receiver knows how to build,  based on
        /// an a configuration object.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="objectConfiguration">The configuration object that describes the object to build.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A fully initialized instance of the <typeparamref name="TObject"/> subtype.</returns>
        public ICallHandler Assemble(IBuilderContext context, CallHandlerData objectConfiguration,
                                     IConfigurationSource configurationSource,
                                     ConfigurationReflectionCache reflectionCache)
        {
            ExceptionCallHandlerData handlerData = (ExceptionCallHandlerData)objectConfiguration;

            ExceptionCallHandler handler = new ExceptionCallHandler(handlerData.ExceptionPolicyName);

            return(handler);
        }
        public void ShouldCreateHandlerWithCorrectPolicy()
        {
            string policyName = "Swallow Exceptions";
            ExceptionCallHandlerAttribute attribute = new ExceptionCallHandlerAttribute(policyName);

            attribute.Order = 400;

            IUnityContainer container = new UnityContainer();
            var             policy    = new ExceptionPolicyImpl(policyName, new ExceptionPolicyEntry[0]);

            container.RegisterInstance(policyName, policy);

            ExceptionCallHandler handler = (ExceptionCallHandler)attribute.CreateHandler(container);

            Assert.AreSame(policy, handler.ExceptionPolicy);
            Assert.AreEqual(400, handler.Order);
        }