Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void Send_ShouldReturnException_WhenCallingUnRegisteredCommands()
        {
            bus = new InternalBus();
            bus.ResetRoutes();

            command = new CreateUserCommand() { UserName = "******" };
            CreateUserCommandHandler.Called = false;
            Assert.Throws(typeof(InvalidOperationException), new TestDelegate(sendBusCommand));
        }
Ejemplo n.º 4
0
        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);
        }