public void can_execute_a_preview() { var method = Mock <IMethod>(); var target = new MethodHost(); var parameter = new object(); methodFactory.Expect(x => x.CreateFrom(info)) .Return(method); var handlingNode = new InteractionNode( new ControlHost(), Mock <IRoutedMessageController>() ); handlingNode.RegisterHandler(Mock <IRoutedMessageHandler>()); handlingNode.MessageHandler.Stub(x => x.Unwrap()) .Return(target); attribute.Initialize(typeof(MethodHost), null, container); method.Stub(x => x.Info).Return(info); attribute.Execute(null, handlingNode, new[] { parameter }); method.AssertWasCalled(x => x.Invoke(target, parameter)); }
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); }
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); }