public async Task Report_projections_can_be_created_using_anonymous_projectors_over_multiple_event_types() { var projector = Projector.Combine( Projector.CreateFor <Placed>(e => { using (var db1 = ReadModelDbContext()) { db1.OrderTallyByStatus(OrderTally.OrderStatus.Pending).Count++; db1.SaveChanges(); } }), Projector.CreateFor <Cancelled>(e => { using (var db2 = ReadModelDbContext()) { db2.OrderTallyByStatus(OrderTally.OrderStatus.Canceled).Count++; db2.OrderTallyByStatus(OrderTally.OrderStatus.Pending).Count--; db2.SaveChanges(); } }), Projector.CreateFor <Delivered>(e => { using (var db3 = ReadModelDbContext()) { db3.OrderTallyByStatus(OrderTally.OrderStatus.Delivered).Count++; db3.OrderTallyByStatus(OrderTally.OrderStatus.Pending).Count--; db3.SaveChanges(); } })).Named("Order status report"); Events.Write(20, _ => new Order.Cancelled()); Events.Write(20, _ => new Order.Delivered()); Events.Write(50, _ => new Order.Placed()); using (var catchup = CreateReadModelCatchup(projector)) { await catchup.Run(); } using (var db = ReadModelDbContext()) { db.Set <OrderTally>() .Single(t => t.Status == "Canceled") .Count .Should() .Be(20); db.Set <OrderTally>() .Single(t => t.Status == "Delivered") .Count .Should() .Be(20); db.Set <OrderTally>() .Single(t => t.Status == "Pending") .Count .Should() .Be(10); } }