public void can_determine_negative_trigger_effect()
        {
            var filter1 = Mock <IPreProcessor>();
            var filter2 = Mock <IPreProcessor>();

            var sourceNode = Stub <IInteractionNode>();
            var message    = new ActionMessage();

            message.Initialize(sourceNode);

            var handlingNode = Stub <IInteractionNode>();
            var target       = new object();
            var parameters   = new object[] {
                5, "param"
            };

            messageBinder.Expect(x => x.DetermineParameters(message, null, handlingNode, null))
            .Return(parameters);

            filterManager.Stub(x => x.TriggerEffects)
            .Return(new[] {
                filter1, filter2
            }).Repeat.Any();

            filter1.Expect(x => x.Execute(message, handlingNode, parameters))
            .Return(false);

            filter2.Expect(x => x.Execute(message, handlingNode, parameters))
            .Return(true);

            var result = action.ShouldTriggerBeAvailable(message, handlingNode);

            result.ShouldBeFalse();
        }
Beispiel #2
0
        public void alters_return_with_post_execute_filters()
        {
            var handlingNode = Stub <IInteractionNode>();
            var sourceNode   = Stub <IInteractionNode>();
            var result       = Mock <IResult>();

            var message = new ActionMessage();

            message.Initialize(sourceNode);

            var target     = new object();
            var parameters = new object[] {
                5, "param"
            };
            var returnValue = new object();
            var filter      = MockRepository.GenerateMock <IPostProcessor>();
            var context     = EventArgs.Empty;

            var handler = Stub <IRoutedMessageHandler>();

            handler.Stub(x => x.Unwrap()).Return(new object());
            handlingNode.Stub(x => x.MessageHandler).Return(handler);

            messageBinder.Expect(x => x.DetermineParameters(message, null, handlingNode, context))
            .Return(parameters);

            filterManager.Stub(x => x.PreProcessors)
            .Return(new IPreProcessor[] {});

            method.Expect(x => x.Invoke(target, parameters))
            .Return(returnValue);

            filterManager.Stub(x => x.PostProcessors)
            .Return(new[] {
                filter
            });

            var outcome = new MessageProcessingOutcome(returnValue, returnValue.GetType(), false);

            filter.Expect(x => x.Execute(message, handlingNode, outcome));

            messageBinder.Expect(x => x.CreateResult(outcome))
            .IgnoreArguments()
            .Return(result);

            result.Expect(x => x.Execute(null)).IgnoreArguments();

            action.Execute(message, handlingNode, context);
        }