Пример #1
0
        public void RegisterEventHandler_ShouldReturnSuccede_WhenRegisteringMultipleEventHandlersForEvent()
        {
            bus = new InternalBus();
            bus.RegisterEventHandler<UserCreatedEvent, CreateUserEventHandler>();
            bus.RegisterEventHandler<UserCreatedEvent, CreateUserEventHandlerTwo>();

            Assert.IsTrue(true);
        }
Пример #2
0
 public void Publish_ShouldCallMultipleRegisteredRegisteredEvents()
 {
     bus = new InternalBus();
     bus.ResetRoutes();
     bus.RegisterEventHandler<UserCreatedEvent, CreateUserEventHandler>();
     bus.RegisterEventHandler<UserCreatedEvent, CreateUserEventHandlerTwo>();
     var newEvent = new UserCreatedEvent() { UserName = "******" };
     CreateUserEventHandler.Called = false;
     CreateUserEventHandlerTwo.Called = false;
     bus.Publish(newEvent);
     Assert.IsTrue(CreateUserEventHandler.Called && CreateUserEventHandlerTwo.Called);
 }
Пример #3
0
 public void RegisterEventHandler_ShouldReturnException_WhenRegisteringSameEventHandlerMultipleTimes()
 {
     bus = new InternalBus();
     bus.RegisterEventHandler<UserCreatedEvent, CreateUserEventHandler>();
     Assert.Throws(typeof(InvalidOperationException), new TestDelegate(RegisterSecondEventHandler));
 }