Exemple #1
0
        public void Setup()
        {
            //
            // observers

            SystemObserver.Setup(new IObserver<ISystemEvent>[] { new ConsoleObserver() });

            //
            // message router

            Router = new MemoryMessageRouter();

            Router.RegisterHandler<CreateAccount>(new CreateAccountHandler().Handle);
            Router.RegisterHandler<AccountCreated>(new AccountCreatedHandler().Handle);

            //
            // message bus

            var bus = new NullBus();
            CommandBus = bus;
            EventBus = bus;

            //
            // Queue Writer

            var queueWriter = new QueueWriterToBus(bus);

            //
            // Misc
            Sender = new MessageSender(new IQueueWriter[] { queueWriter });
            Identifier = new AccountID(Guid.NewGuid());
        }
        public void Setup()
        {
            //
            // observers

            SystemObserver.Setup(new IObserver<ISystemEvent>[] { new ConsoleObserver() });

            //
            // message handlers

            var handler = new CommandHandler();
            handler.WireToLambda<CreateAccount>(new CreateAccountHandler().Handle);
            handler.WireToLambda<AccountCreated>(new AccountCreatedHandler().Handle);

            //
            // message router

            var router = new MemoryMessageRouter();

            m_router = router;
            m_registerRoutes = router;

            m_registerRoutes.RegisterHandler<CreateAccount>(handler.Handle);
            m_registerRoutes.RegisterHandler<AccountCreated>(handler.Handle);

            //
            // message bus

            var bus = new MemoryBusWithRouter(m_router);

            //
            // Queue Writer

            var queueWriter = new QueueWriterToBus(bus);

            //
            // Misc

            m_sender = new MessageSender(new IQueueWriter[] { queueWriter });
            m_id = new AccountID(Guid.NewGuid());
        }