public void When_CommandIsQueued_CommandDispatcherIsCalled()
        {
            var cmdGuid           = Guid.NewGuid();
            var state             = 0;
            var commandDispatcher = new TestCommandDispatcher()
            {
                Action = (cmd) =>
                {
                    if (cmd.AggregateId == cmdGuid)
                    {
                        state = 2;
                    }
                    return(null);
                }
            };

            var commandListener = new CommandQueueListener <TestAggregate>(_eventStore, _commandQueue, commandDispatcher);

            _commandQueue.DispatchCommands(typeof(TestAggregate).Name, new List <ICommand> {
                new TestCommand(cmdGuid)
            });
            commandListener.DequeueAndDispatchCommands();

            Assert.True(state == 2);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var commandQueueListener = new CommandQueueListener();
            var readModelListener    = new ReadModelListener();

            while (true)
            {
                commandQueueListener.ProcessCommands();
                readModelListener.ProcessEvents();
            }
        }