From 8c1a00a2072f721af6a2fc194eeff84c6743fd6a Mon Sep 17 00:00:00 2001 From: Edwin van den Houdt Date: Wed, 3 Jun 2026 13:35:22 +0200 Subject: [PATCH] test(bff): /health returns 200 Healthy (refs #28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the BFF Api/Tests skeleton (.NET 10, ASP.NET Core minimal API, xUnit + WebApplicationFactory) and a failing test asserting GET /health returns 200 with a Healthy body. The endpoint does not exist yet — the test fails with NotFound, establishing red before the implementation. Co-Authored-By: Claude Opus 4.8 --- .gitignore | 27 +++++++++++++++++++ global.json | 6 +++++ services/bff/Bff.Api/Bff.Api.csproj | 9 +++++++ services/bff/Bff.Api/Program.cs | 9 +++++++ services/bff/Bff.Tests/Bff.Tests.csproj | 26 ++++++++++++++++++ services/bff/Bff.Tests/HealthEndpointTests.cs | 20 ++++++++++++++ services/bff/Bff.slnx | 4 +++ 7 files changed, 101 insertions(+) create mode 100644 .gitignore create mode 100644 global.json create mode 100644 services/bff/Bff.Api/Bff.Api.csproj create mode 100644 services/bff/Bff.Api/Program.cs create mode 100644 services/bff/Bff.Tests/Bff.Tests.csproj create mode 100644 services/bff/Bff.Tests/HealthEndpointTests.cs create mode 100644 services/bff/Bff.slnx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1499030 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# .NET build output +bin/ +obj/ +[Dd]ebug/ +[Rr]elease/ +*.user + +# Test results / coverage +[Tt]est[Rr]esults/ +*.trx +coverage*.json +coverage*.xml +*.coverage + +# Rider / VS / VS Code +.idea/ +.vs/ +.vscode/ + +# Node / Angular (added as the frontend lands) +node_modules/ +dist/ +.angular/ + +# OS +.DS_Store +Thumbs.db diff --git a/global.json b/global.json new file mode 100644 index 0000000..ab84b81 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "10.0.203", + "rollForward": "latestFeature" + } +} diff --git a/services/bff/Bff.Api/Bff.Api.csproj b/services/bff/Bff.Api/Bff.Api.csproj new file mode 100644 index 0000000..a3a34b6 --- /dev/null +++ b/services/bff/Bff.Api/Bff.Api.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + diff --git a/services/bff/Bff.Api/Program.cs b/services/bff/Bff.Api/Program.cs new file mode 100644 index 0000000..5267f53 --- /dev/null +++ b/services/bff/Bff.Api/Program.cs @@ -0,0 +1,9 @@ +var builder = WebApplication.CreateBuilder(args); +var app = builder.Build(); + +app.MapGet("/", () => "BFF placeholder"); + +app.Run(); + +// Exposed so the test host (WebApplicationFactory) can boot the app. +public partial class Program; diff --git a/services/bff/Bff.Tests/Bff.Tests.csproj b/services/bff/Bff.Tests/Bff.Tests.csproj new file mode 100644 index 0000000..e6b2ace --- /dev/null +++ b/services/bff/Bff.Tests/Bff.Tests.csproj @@ -0,0 +1,26 @@ + + + + net10.0 + enable + enable + false + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/bff/Bff.Tests/HealthEndpointTests.cs b/services/bff/Bff.Tests/HealthEndpointTests.cs new file mode 100644 index 0000000..2244534 --- /dev/null +++ b/services/bff/Bff.Tests/HealthEndpointTests.cs @@ -0,0 +1,20 @@ +using System.Net; +using Microsoft.AspNetCore.Mvc.Testing; + +namespace Bff.Tests; + +public class HealthEndpointTests(WebApplicationFactory factory) + : IClassFixture> +{ + [Fact] + public async Task Health_endpoint_returns_200_and_reports_healthy() + { + var client = factory.CreateClient(); + + var response = await client.GetAsync("/health"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var body = await response.Content.ReadAsStringAsync(); + Assert.Contains("Healthy", body); + } +} diff --git a/services/bff/Bff.slnx b/services/bff/Bff.slnx new file mode 100644 index 0000000..5680319 --- /dev/null +++ b/services/bff/Bff.slnx @@ -0,0 +1,4 @@ + + + +