protected async Task ExecuteTest(IEventStoreInitializer eventStoreInitializer, IEventStore eventStore) { // Arrange var events = new List <TestEvent> { new TestEvent("arid", "sp1"), new TestEvent("arid", "sp2"), new TestEvent("arid", "sp3") }; for (var i = 0; i < events.Count; i++) { events[i].SetVersion(i); } // Act await eventStoreInitializer.InitializeAsync(); await eventStore.SaveAsync(events); var queriedEvents = await eventStore.GetByAggregateRootIdAsync("arid", Constants.INITIAL_VERSION); // Assert queriedEvents .Should() .BeEquivalentTo(events); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IEventStoreInitializer <GiftCard, Guid> eventStoreInitializer, ISnapshotStoreInitializer <GiftCard, Guid> snapshotStoreInitializer) { eventStoreInitializer.EnsureCreatedAsync().Wait(); snapshotStoreInitializer.EnsureCreatedAsync().Wait(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); }
protected async Task ExecuteConcurrencyCheckTest(IEventStoreInitializer eventStoreInitializer, IEventStore eventStore) { // Arrange var events = new List <TestEvent> { new TestEvent("arid", "sp1"), new TestEvent("arid", "sp2") }; events[0].SetVersion(0); events[1].SetVersion(0); // Act await eventStoreInitializer.InitializeAsync(); Func <Task> act = async() => await eventStore.SaveAsync(events); // Assert act.Should() .Throw <ConcurrencyException>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IEventStoreInitializer <GiftCard, Guid> eventStoreInitializer) { eventStoreInitializer.EnsureCreatedAsync().Wait(); app.UseExceptionHandler("/Error"); app.UseHsts(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); }