public StateChangeGameTestsWeb(ITestOutputHelper outputHelper) { this.context = TestContextBuilder.Create <InMemoryEventStore, GameModule>((store, pub) => { this.helper = outputHelper; var module = GameModule.Initialize(store, new InMemorySnapshotStore(), pub); hostBuilder = RPS.Web.Program.CreateHostBuilder(Array.Empty <string>()) .ConfigureWebHost(webHost => webHost .UseTestServer() .ConfigureTestServices(services => services .AddSingleton(module) .Remove(services.SingleOrDefault(x => x.ImplementationType == typeof(ChangeFeedHostedService))) )); return(module); }); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => webBuilder.ConfigureServices((ctx, services) => services .Tap(s => { //if (ctx.Configuration.GetValue<bool>("fiffi-dapr")) // s.AddFiffiDapr(); //else s.AddFiffiInMemory(); }) .AddApplicationInsightsTelemetry() .AddSingleton(TypeResolver.FromMap(TypeResolver.GetEventsInNamespace <GameCreated>())) .AddSingleton(sp => GameModule.Initialize( sp.GetRequiredService <IAdvancedEventStore>(), sp.GetRequiredService <ISnapshotStore>(), events => sp.GetService <GameModule>().WhenAsync(events) )) .AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "RPS Game", Version = "v1" })) .AddLogging(b => b.AddFilter <ApplicationInsightsLoggerProvider>("", LogLevel.Information)) .AddMvc() .AddDapr() ) .Configure(app => { app.UseRouting(); app.UseCloudEvents(); app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "RPS Game v1")); app.UseEndpoints(endpoints => { endpoints.MapSubscribeHandler(); endpoints.MapControllers(); endpoints.MapDefaultControllerRoute(); }); }) );