using System.Net; using FluentAssertions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.Configuration; using Xunit; namespace StellaOps.Timeline.WebService.Tests; [Trait("Category", "Integration")] public sealed class TimelineStartupRegistrationTests { [Fact] public async Task Startup_WithPostgresStoreConfiguration_BuildsHost() { await using var factory = new WebApplicationFactory() .WithWebHostBuilder(builder => { builder.UseEnvironment("Development"); builder.ConfigureAppConfiguration((_, config) => { config.AddInMemoryCollection(new Dictionary { ["Eventing:ServiceName"] = "timeline-tests", ["Eventing:UseInMemoryStore"] = "false", ["Eventing:ConnectionString"] = "Host=localhost;Port=5432;Database=timeline;Username=postgres;Password=postgres", ["Authority:ResourceServer:Authority"] = "http://localhost", // Required by TimelineIndexer Postgres registration (merged from timeline-indexer) ["Postgres:Timeline:ConnectionString"] = "Host=localhost;Port=5432;Database=timeline;Username=postgres;Password=postgres", }); }); }); using var client = factory.CreateClient(); var response = await client.GetAsync("/does-not-exist"); response.StatusCode.Should().Be(HttpStatusCode.NotFound); } }