public void Base() { Converts.Repository .AddJsonEnumSearchHandler() .AddJsonPrimitivesSearchHandler() .AddJsonObjectSearchHandler() .AddJsonKey() .AddJsonTimeSpan(); CompositeEventFormatter formatter = new CompositeEventFormatter( new ReflectionCompositeTypeProvider(new ReflectionCompositeDelegateFactory()), Factory.Default <JsonCompositeStorage>() ); MockEventStore eventStore = new MockEventStore(); // Creation of state. Order order = new Order(KeyFactory.Create(typeof(Order))); order.AddItem(KeyFactory.Create(typeof(T_EventSourcing_ReadModels_Rebuilder)), 2); order.AddItem(KeyFactory.Create(typeof(Rebuilder)), 5); eventStore.Save(order.Events.Select(e => new EventModel(order.Key, e.Key, formatter.Serialize(e), e.Version))); // Rebuilding model. Rebuilder rebuilder = new Rebuilder(eventStore, formatter); ReadModelHandler handler = new ReadModelHandler(); rebuilder.AddAll(handler); rebuilder.RunAsync().Wait(); Assert.AreEqual(1, handler.Totals.Count); Assert.AreEqual( order.Events.OfType <OrderTotalRecalculated>().Last().TotalPrice, handler.Totals.FirstOrDefault().Value ); }
private Task RecreateReadModelContext() { using (var readModels = new ReadModelContext()) { readModels.Database.EnsureDeleted(); readModels.Database.EnsureCreated(); } // Should match with ReadModels. Rebuilder rebuilder = new Rebuilder(eventStore, eventFormatter); rebuilder.AddAll(new CategoryBuilder()); rebuilder.AddAll(new OutcomeBuilder(domainFacade.PriceFactory)); return(rebuilder.RunAsync()); }
internal async Task RecreateReadModelContextAsync() { using (var readModels = readModelContextFactory.Create()) { await readModels.Database.EnsureDeletedAsync(); await readModels.Database.EnsureCreatedAsync(); } // Should match with ReadModels. Rebuilder rebuilder = new Rebuilder(eventStore, eventFormatter); DefaultQueryDispatcher queryDispatcher = new DefaultQueryDispatcher(); Models.Builders.BootstrapTask bootstrapTask = new Models.Builders.BootstrapTask(queryDispatcher, rebuilder, readModelContextFactory, priceConverter); bootstrapTask.Initialize(); await rebuilder.RunAsync(); }