Exemplo n.º 1
0
        protected override void Given()
        {
            base.Given();

            _container = new UnityContainer();
            _container.RegisterInstance(_container);

            _eventRepository = new MockEventRepository();
            _container.RegisterInstance<IEventRepository>(_eventRepository);

            _messageLog = new MockMessageLog();
            _container.RegisterInstance<IMessageLog>(_messageLog);

            _messageConsumerRepository = new UnityMessageConsumerRepository();
            _container.RegisterInstance<IMessageConsumerRepository>(_messageConsumerRepository);

            _eventHandlerResolver = new UnityEventHandlerResolver<IEntity>(_container);
            _container.RegisterInstance<IEventHandlerResolver>(_eventHandlerResolver);

            var domainRepository = _container.Resolve<DomainRepository>();
            _container.RegisterInstance<IDomainRepository>(domainRepository);

            EventProcessor.Clear();
            EventProcessor.Setup(_container);

            MessageBroker.Setup(_container);
        }
Exemplo n.º 2
0
        public Window1()
        {
            InitializeComponent();

            var container = new UnityContainer();
            container.RegisterInstance(container);

            NHibConfig config = NHibConfig.Create()
                .DatabaseNameIs("Praetorian")
                .ServerIs("localhost\\SQLEXPRESS2")
                .RegisterMappings(Assembly.GetAssembly(typeof (NHibEventRepository)))
                .RegisterMappings(Assembly.GetAssembly(typeof (ExpenseDtoMapping)))
                .Build();

            container.RegisterInstance<IEventRepository>(new NHibEventRepository(config));

            container.RegisterInstance<IMessageLog>(new NHibMessageLog(config));

            var repository = new UnityMessageConsumerRepository();
            repository.RegisterAssemby(Assembly.GetAssembly(typeof (Expense)));
            container.RegisterInstance<IMessageConsumerRepository>(repository);

            container.RegisterInstance<IEventHandlerResolver>(new UnityEventHandlerResolver<IEntity>(container));

            container.RegisterInstance<IDomainRepository>(container.Resolve<DomainRepository>());

            container.RegisterInstance<IWriteRepositoryStrategy>(new NHibWriteRepositoryStrategy(config));
            container.RegisterInstance<IReadRepositoryStrategy>(new NHibReadRepositoryStrategy(config));

            var writeEventHandlerRepository = new UnityEventHandlerResolver<IWriteRepository>(container);
            writeEventHandlerRepository.RegisterAssemby(Assembly.GetAssembly(typeof (ExpenseWriteRepository)));

            var writeRepositoryEventSubscriber = new WriteRepositoryEventSubscriber(writeEventHandlerRepository);

            EventProcessor.SubscribeToAll(writeRepositoryEventSubscriber);

            EventProcessor.Setup(container);
            MessageBroker.Setup(container);

            content.Content = container.Resolve<ExpensesViewModel>();
        }