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 can_execute_a_callback() { var method = Mock<IMethod>(); var target = new MethodHost(); var result = new object(); var handlingNode = new InteractionNode( new ControlHost(), Mock<IRoutedMessageController>() ); handlingNode.RegisterHandler(Mock<IRoutedMessageHandler>()); handlingNode.MessageHandler.Stub(x => x.Unwrap()) .Return(target); methodFactory.Expect(x => x.CreateFrom(info)) .Return(method); attribute.Initialize(typeof(MethodHost), null, container); method.Expect(x => x.Invoke(target, result)).Return(typeof(string)); method.Stub(x => x.Info).Return(typeof(object).GetMethod("ToString")); var outcome = new MessageProcessingOutcome(result, result.GetType(), false); attribute.Execute(null, handlingNode, outcome); }
public void can_execute_a_callback() { var method = Mock <IMethod>(); var target = new MethodHost(); var result = new object(); var handlingNode = new InteractionNode( new ControlHost(), Mock <IRoutedMessageController>() ); handlingNode.RegisterHandler(Mock <IRoutedMessageHandler>()); handlingNode.MessageHandler.Stub(x => x.Unwrap()) .Return(target); methodFactory.Expect(x => x.CreateFrom(info)) .Return(method); attribute.Initialize(typeof(MethodHost), null, container); method.Expect(x => x.Invoke(target, result)).Return(typeof(string)); method.Stub(x => x.Info).Return(typeof(object).GetMethod("ToString")); var outcome = new MessageProcessingOutcome(result, result.GetType(), false); attribute.Execute(null, handlingNode, outcome); }
public void can_handle_an_exception() { var method = Mock<IMethod>(); method.Stub(x => x.Info).Return(info); var target = new MethodHost(); var exception = new Exception(); var handlingNode = new InteractionNode( new ControlHost(), Mock<IRoutedMessageController>() ); handlingNode.RegisterHandler(Mock<IRoutedMessageHandler>()); handlingNode.MessageHandler.Stub(x => x.Unwrap()) .Return(target); methodFactory.Expect(x => x.CreateFrom(info)) .Return(method); attribute.Initialize(typeof(MethodHost), null, container); attribute.Handle(null, handlingNode, exception); method.AssertWasCalled(x => x.Invoke(target, exception)); }