public static CreateNew ( object>.Func |
||
instanceCreatorFunction | object>.Func | |
리턴 |
public void Subscribed_event_handler_should_not_receive_events_which_are_not_supported_by_handler_with_type_registration() { var objectsCreator = ObjectsCreator.CreateNew(_substituteCreatorFunction); var eventBroker = new SimpleInProcEventBroker(objectsCreator.InstanceCreatorFunction); eventBroker.SubscribeHandlerType <IEventHandler <EventA> >(); var eventB = new EventB(Guid.NewGuid()); eventBroker.Publish(eventB); objectsCreator.CreatedInstances.Should().BeEmpty(); }
public void Subscribed_event_handler_should_receive_published_event_of_same_type_with_type_registration() { var objectsCreator = ObjectsCreator.CreateNew(_substituteCreatorFunction); var eventBroker = new SimpleInProcEventBroker(objectsCreator.InstanceCreatorFunction); eventBroker.SubscribeHandlerType <IEventHandler <EventA> >(); var eventA = new EventA(Guid.NewGuid()); eventBroker.Publish(eventA); objectsCreator.CreatedInstances.Should().HaveCount(1); objectsCreator.CreatedInstances.Cast <IEventHandler <EventA> >().Single().Received(1).Handle(eventA); }
public void Handler_that_handles_multiple_event_types_should_receive_all_supported_events_with_type_registration() { var objectsCreator = ObjectsCreator.CreateNew(); var eventBroker = new SimpleInProcEventBroker(objectsCreator.InstanceCreatorFunction); eventBroker.SubscribeHandlerType <MultiEventHandler>(); var eventA = new EventA(Guid.NewGuid()); var eventB = new EventB(Guid.NewGuid()); eventBroker.Publish(eventA); eventBroker.Publish(eventB); objectsCreator.CreatedInstances.Should().HaveCount(2); }
public void All_subscribed_handlers_should_receive_appropriate_events_with_type_registration() { var objectsCreator = ObjectsCreator.CreateNew(_substituteCreatorFunction); var eventBroker = new SimpleInProcEventBroker(objectsCreator.InstanceCreatorFunction); eventBroker.SubscribeHandlerType <IEventHandler <EventA> >(); eventBroker.SubscribeHandlerType <IEventHandler <EventB> >(); var eventA = new EventA(Guid.NewGuid()); var eventA2 = new EventA(Guid.NewGuid()); var eventB = new EventB(Guid.NewGuid()); eventBroker.Publish(eventA); eventBroker.Publish(eventA2); eventBroker.Publish(eventB); objectsCreator.CreatedInstances.Should().HaveCount(3); ((IEventHandler <EventA>)objectsCreator.CreatedInstances.First()).Received(1).Handle(eventA); ((IEventHandler <EventA>)objectsCreator.CreatedInstances.Skip(1).First()).Received(1).Handle(eventA2); ((IEventHandler <EventB>)objectsCreator.CreatedInstances.Skip(2).First()).Received(1).Handle(eventB); }