public void RegisterCommandHandler_ShouldReturnException_WhenRegisteringMultipleCommandHandlersForCommand() { bus = new InternalBus(); bus.ResetRoutes(); bus.RegisterCommandHandler<CreateUserCommand, CreateUserCommandHandler>(); // Bus.Instance.RegisterHandler<CreateUserCommand>(new CreateUserCommandHandler().Handle); Assert.Throws(typeof(InvalidOperationException), new TestDelegate(RegisterSecondCommandHandler)); }
public void Publish_ShouldCallRegisteredEvent() { bus = new InternalBus(); bus.ResetRoutes(); bus.RegisterEventHandler<UserCreatedEvent, CreateUserEventHandler>(); var newEvent = new UserCreatedEvent() { UserName = "******" }; CreateUserEventHandler.Called = false; bus.Publish(newEvent); Assert.IsTrue(CreateUserEventHandler.Called); }
public void Send_ShouldReturnException_WhenCallingUnRegisteredCommands() { bus = new InternalBus(); bus.ResetRoutes(); command = new CreateUserCommand() { UserName = "******" }; CreateUserCommandHandler.Called = false; Assert.Throws(typeof(InvalidOperationException), new TestDelegate(sendBusCommand)); }
public void Send_ShouldCallRegisteredCommands() { bus = new InternalBus(); bus.ResetRoutes(); bus.RegisterCommandHandler<CreateUserCommand, CreateUserCommandHandler>(); var command = new CreateUserCommand() {UserName = "******"}; CreateUserCommandHandler.Called = false; bus.Send(command); Assert.IsTrue(CreateUserCommandHandler.Called); }