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 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);
        }