public void Then_the_child_projector_should_project_all_the_transactions() { using (ISession session = The <ISessionFactory>().OpenSession()) { ProductCatalogChildEntry childEntry1 = session.Get <ProductCatalogChildEntry>("c350E"); childEntry1.Should().NotBeNull(); childEntry1.Category.Should().Be("Hybrid"); ProductCatalogChildEntry childEntry2 = session.Get <ProductCatalogChildEntry>("c350F"); childEntry2.Should().NotBeNull(); childEntry2.Category.Should().Be("Gas"); } }
public When_there_is_a_child_projector() { Given(() => { Events.Map <ProductAddedToCatalogEvent>() .AsCreateOf(anEvent => anEvent.ProductKey) .Using((entry, anEvent) => entry.Category = anEvent.Category); Events.Map <ProductAddedToCatalogEvent>().As((anEvent, context) => { ProductCatalogChildEntry childEntry1 = context.Session.Get <ProductCatalogChildEntry>("c350E"); ProductCatalogChildEntry childEntry2 = context.Session.Get <ProductCatalogChildEntry>("c350F"); childProjectionStates.Add(new ChildProjectionState { Entry1Exists = childEntry1 != null, Entry2Exists = childEntry2 != null }); }); var childMapBuilder = new EventMapBuilder <ProductCatalogChildEntry, string, NHibernateProjectionContext>(); childMapBuilder.Map <ProductAddedToCatalogEvent>() .AsCreateOf(anEvent => anEvent.ProductKey) .Using((entry, anEvent) => entry.Category = anEvent.Category); var childProjector = new NHibernateChildProjector <ProductCatalogChildEntry, string>(childMapBuilder); StartProjecting(children: new INHibernateChildProjector[] { childProjector }); }); When(async() => { var transaction1 = new Transaction { Events = new[] { new EventEnvelope { Body = new ProductAddedToCatalogEvent { ProductKey = "c350E", Category = "Hybrid" } } } }; transaction2 = new Transaction { Events = new[] { new EventEnvelope { Body = new ProductAddedToCatalogEvent { ProductKey = "c350F", Category = "Gas" } } } }; await The <MemoryEventSource>().Write(transaction1, transaction2); }); }