protected IDomainRepository CreateDomainRepository(IBus bus)
 {
     var eventMappings = new NServiceBusDomainEventMappingFactory().CreateMappingCollection();
     var eventPersistence = new InProcEventPersistence();
     var eventPublisher = new NServiceBusEventPublisher(bus, eventMappings);
     var eventStore = new EventStore(eventPersistence, eventPublisher);
     var domainRepository = new DomainRepository(eventStore);
     return domainRepository;
 }
        protected IDomainRepository CreateDomainRepository(IBus bus)
        {
            var eventMappings    = new NServiceBusDomainEventMappingFactory().CreateMappingCollection();
            var eventPersistence = new InProcEventPersistence();
            var eventPublisher   = new NServiceBusEventPublisher(bus, eventMappings);
            var eventStore       = new EventStore(eventPersistence, eventPublisher);
            var domainRepository = new DomainRepository(eventStore);

            return(domainRepository);
        }
コード例 #3
0
        public static T Create <T>(IBus bus)
        {
            var mapperFactory    = new NServiceBusDomainEventMappingFactory();
            var mapperCollection = mapperFactory.CreateMappingCollection();
            var eventPersistence = new InProcEventPersistence();
            var eventPublisher   = new NServiceBusEventPublisher(bus, mapperCollection);
            var eventStore       = new EventStore(eventPersistence, eventPublisher);
            var instance         = Activator.CreateInstance(typeof(T), eventStore);

            return((T)instance);
        }
 public void ShouldPublishEvent()
 {
     var mockBus = MockRepository.GenerateMock<IBus>();
     var domainEventMappingCollection = new NServiceBusEventMappings();
     domainEventMappingCollection.AddMapper(new AccommodationLeadApprovedMapper());
     var eventPublisher = new NServiceBusEventPublisher(mockBus, domainEventMappingCollection);
     var domainEvent = new AccommodationLeadApproved
         {
             ID = Guid.NewGuid()
         };
     eventPublisher.Publish(domainEvent);
     //Already tested that the correct event should be being published here where the
     //DomainEventMappingTests
     mockBus.AssertWasCalled(x => x.Publish(Arg<IEvent>.Is.Anything));
 }
コード例 #5
0
        public void ShouldPublishEvent()
        {
            var mockBus = MockRepository.GenerateMock <IBus>();
            var domainEventMappingCollection = new NServiceBusEventMappings();

            domainEventMappingCollection.AddMapper(new AccommodationLeadApprovedMapper());
            var eventPublisher = new NServiceBusEventPublisher(mockBus, domainEventMappingCollection);
            var domainEvent    = new AccommodationLeadApproved
            {
                ID = Guid.NewGuid()
            };

            eventPublisher.Publish(domainEvent);
            //Already tested that the correct event should be being published here where the
            //DomainEventMappingTests
            mockBus.AssertWasCalled(x => x.Publish(Arg <IEvent> .Is.Anything));
        }