Ejemplo n.º 1
0
        public void can_add_command_handler_and_use_it()
        {
            var commandBus = new CommandBus();
            var command    = new TestCommand();
            var handler    = new TestCommandHandler();

            commandBus.RegisterHandler(handler);

            commandBus.PublishCommand(command);

            Thread.Sleep(500); // wait for command thread to execute

            Assert.IsTrue(command.WasHandled);
        }
Ejemplo n.º 2
0
        public void can_add_action_handler_and_use_it()
        {
            var commandBus = new CommandBus();
            var command    = new TestCommand();

            commandBus.RegisterHandler <TestCommand>(x =>
            {
                x.WasHandled = true;
            });

            commandBus.PublishCommand(command);

            Thread.Sleep(500); // wait for command thread to execute

            Assert.IsTrue(command.WasHandled);
        }