public void aggregate_facotry_should_execute_store_and_dispatch() { // arrange var router = new MemoryMessageRouter(); router.RegisterHandler<CreateAccount>(new CreateAccountHandler().Handle); var id = new AccountID(Guid.NewGuid()); var storageFactory = new MemoryRecordStorageFactory(); var bus = new MemoryBusWithRouter(router); var factory = new AccountFactory(bus, storageFactory); // act factory.ExecuteStoreDispatch(new CreateAccount(id)); // assert var storage = storageFactory.GetOrCreateStorage(id); storage.GetRecords(0, int.MaxValue).Count().ShouldEqual(1); }
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()); }