/// <summary>
 /// Does and doesn't break the OCP principles depending on your view point.
 /// 
 /// Reagrdless this is for the purposes of example so that not external libraries are introduced too soon
 /// 
 /// Be good topics for refactoring with a clear objective.
 /// 
 /// Should not be too much work either...
 /// </summary>
 /// <returns></returns>
 public IEventMappings CreateMappingCollection()
 {
     var mappingCollection = new NServiceBusEventMappings();
     mappingCollection.AddMapper(new UserCreatedMapper());
     mappingCollection.AddMapper(new AccommodationLeadApprovedMapper());
     mappingCollection.AddMapper(new AccommodationLeadCreatedMapper());
     mappingCollection.AddMapper(new AccommodationSupplierCreatedMapper());
     mappingCollection.AddMapper(new AuthenticationCreatedMapper());
     return mappingCollection;
 }
 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));
 }
        public void ShouldLocateAnExistingMapperUsingASuppliedDomainEventType()
        {
            var domainEventMappingCollection = new NServiceBusEventMappings();

            domainEventMappingCollection.AddMapper(
                new AccommodationLeadApprovedMapper());

            var domainEvent = new AccommodationLeadApproved
                {
                    ID = Guid.NewGuid()
                };

            var mappedEvent =
                domainEventMappingCollection.GetMappedObjectFor(domainEvent);

            Assert.That(mappedEvent, Is.TypeOf<Messages.Events.AccommodationLeadApproved>());
        }