예제 #1
0
        public void SetupForMakeAwareOf(string memberName, MethodInfo info, object handler)
        {
            var method = Mock <IMethod>();

            method.Stub(x => x.Info).Return(info).Repeat.Any();
            methodFactory.Expect(x => x.CreateFrom(info)).Return(method);

            var attribute = new PreviewAttribute(memberName);

            attribute.Initialize(handler.GetType(), info, container);

            if (routedMessageHandler.Unwrap() == null) //prevents double configuration
            {
                routedMessageHandler.Stub(x => x.Unwrap()).Return(handler).Repeat.Any();
            }

            var message = Mock <IRoutedMessage>();

            message.Stub(x => x.RelatesTo(info)).Return(true);
            var messageTrigger = Mock <IMessageTrigger>();

            messageTrigger.Stub(x => x.Message).Return(message).Repeat.Any();
            attribute.MakeAwareOf(routedMessageHandler);
            attribute.MakeAwareOf(routedMessageHandler, messageTrigger);
        }
예제 #2
0
        protected override void given_the_context_of()
        {
            methodFactory = Mock<IMethodFactory>();
            info = typeof(MethodHost).GetMethod("Preview");
            attribute = new PreviewAttribute("Preview");
            container = Stub<IServiceLocator>();
            container.Stub(x => x.GetInstance<IMethodFactory>()).Return(methodFactory).Repeat.Any();

            routedMessageHandler = Mock<IRoutedMessageHandler>();
            var metadata = new List<object>();
            routedMessageHandler.Stub(x => x.Metadata).Return(metadata).Repeat.Any();
        }
예제 #3
0
        protected override void given_the_context_of()
        {
            methodFactory = Mock <IMethodFactory>();
            info          = typeof(MethodHost).GetMethod("Preview");
            attribute     = new PreviewAttribute("Preview");
            container     = Stub <IServiceLocator>();
            container.Stub(x => x.GetInstance(typeof(IMethodFactory), null)).Return(methodFactory).Repeat.Any();

            routedMessageHandler = Mock <IRoutedMessageHandler>();
            var metadata = new List <object>();

            routedMessageHandler.Stub(x => x.Metadata).Return(metadata).Repeat.Any();
        }
예제 #4
0
        public void SetupForMakeAwareOf(string memberName, MethodInfo info, object handler)
        {
            var method = Mock<IMethod>();
            method.Stub(x => x.Info).Return(info).Repeat.Any();
            methodFactory.Expect(x => x.CreateFrom(info)).Return(method);

            var attribute = new PreviewAttribute(memberName);
            attribute.Initialize(handler.GetType(), info, container);

            if(routedMessageHandler.Unwrap() == null) //prevents double configuration
                routedMessageHandler.Stub(x => x.Unwrap()).Return(handler).Repeat.Any();

            var message = Mock<IRoutedMessage>();
            message.Stub(x => x.RelatesTo(info)).Return(true);
            var messageTrigger = Mock<IMessageTrigger>();
            messageTrigger.Stub(x => x.Message).Return(message).Repeat.Any();
            attribute.MakeAwareOf(routedMessageHandler);
            attribute.MakeAwareOf(routedMessageHandler, messageTrigger);
        }