コード例 #1
0
        public void CanCreateCustomAttributeMatchingRuleNodeFromData()
        {
            ExceptionCallHandlerData handlerData = new ExceptionCallHandlerData();

            handlerData.Name = "exceptionHandler";

            ExceptionCallHandlerNode handlerNode = new ExceptionCallHandlerNode(handlerData);

            Assert.AreEqual(handlerData.Name, handlerNode.Name);
        }
コード例 #2
0
        public void CanCreateRuleDataFromCustomAttributeMatchingRuleNode()
        {
            ExceptionCallHandlerNode handlerNode = new ExceptionCallHandlerNode();

            handlerNode.Name = "exceptionHandler";


            ExceptionCallHandlerData handlerData = handlerNode.CreateCallHandlerData() as ExceptionCallHandlerData;

            Assert.IsNotNull(handlerData);
            Assert.AreEqual(handlerData.Name, handlerNode.Name);
        }
コード例 #3
0
        public void ShouldBeAbleToMoveHandlers()
        {
            ApplicationNode.Hierarchy.Load();
            ApplicationNode.Hierarchy.Open();
            ConfigurationNode policyInjectionNode =
                ApplicationNode.Hierarchy.FindNodeByType(typeof(PolicyInjectionSettingsNode));
            ConfigurationNode policyCollectionNode =
                policyInjectionNode.Hierarchy.FindNodeByType(typeof(PolicyCollectionNode));

            PolicyNode policy1Node = (PolicyNode)policyCollectionNode.Nodes[0];

            CallHandlersCollectionNode handlersNode =
                (CallHandlersCollectionNode)
                policy1Node.Hierarchy.FindNodeByType(typeof(CallHandlersCollectionNode));
            ExceptionCallHandlerNode     exceptionNode = (ExceptionCallHandlerNode)handlersNode.Nodes[3];
            AuthorizationCallHandlerNode authNode      =
                (AuthorizationCallHandlerNode)handlersNode.Nodes[0];

            ConfigurationNode logNode =
                handlersNode.Hierarchy.FindNodeByType(typeof(LogCallHandlerNode));
            ConfigurationNode validationNode =
                handlersNode.Hierarchy.FindNodeByType(typeof(ValidationCallHandlerNode));

            handlersNode.MoveBefore(exceptionNode, authNode);
            handlersNode.MoveAfter(logNode, validationNode);

            IConfigurationSource configSource = ApplicationNode.Hierarchy.BuildConfigurationSource();

            PolicyInjectionSettings settings =
                (PolicyInjectionSettings)
                configSource.GetSection(PolicyInjectionSettings.SectionName);

            PolicyData policy1Data = settings.Policies.Get(0);

            Assert.IsTrue(policy1Data.Handlers.Get(0) is ExceptionCallHandlerData);
            Assert.IsTrue(policy1Data.Handlers.Get(1) is AuthorizationCallHandlerData);
            Assert.IsTrue(policy1Data.Handlers.Get(policy1Data.Handlers.Count - 2) is ValidationCallHandlerData);
            Assert.IsTrue(policy1Data.Handlers.Get(policy1Data.Handlers.Count - 1) is LogCallHandlerData);
        }
コード例 #4
0
        public void ExceptionCallHandlerNodeHasProperName()
        {
            ExceptionCallHandlerNode node = new ExceptionCallHandlerNode();

            Assert.AreEqual("Exception Handling Handler", node.Name);
        }