本文整理汇总了C#中IEventHandler.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IEventHandler.Stub方法的具体用法?C# IEventHandler.Stub怎么用?C# IEventHandler.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEventHandler
的用法示例。
在下文中一共展示了IEventHandler.Stub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Context
protected override void Context()
{
_handler = MockRepository.GenerateMock<IEventHandler<EventData>>();
_handler.Stub(h => h.Handle(null)).IgnoreArguments().Callback(delegate(EventData data)
{
_eventData = data.SomeData;
return true;
});
IEventPublisher eventPublisher = new EventPublisher();
eventPublisher.RegisterHandler(_handler);
eventPublisher.Publish(new EventData("My Event Data"));
}
示例2: Context
protected override void Context()
{
IEventPublisher eventPublisher = new EventPublisher();
_handler1 = MockRepository.GenerateMock<IEventHandler<EventData>>();
_handler1.Stub(h => h.Handle(null)).IgnoreArguments().Callback(delegate(EventData data)
{
eventPublisher.Publish(new SecondEvent());
return true;
});
_handler2 = MockRepository.GenerateMock<IEventHandler<SecondEvent>>();
_handler2.Stub(h => h.Handle(null)).IgnoreArguments().Callback(delegate(SecondEvent data)
{
_eventTwoWasHandled = true;
return true;
});
eventPublisher.RegisterHandler(_handler1);
eventPublisher.RegisterHandler(_handler2);
eventPublisher.Publish(new EventData("My Event Data"));
}