test: add xUnit test coverage for API controllers and client services

Create ChatAgent.Api.Tests and ChatAgent.Client.Tests projects with xUnit
and Moq. Test HealthController (200 + valid response), ChatController
(SSE streaming with mocked upstream, error handling), and ChatApiClient
(delta parsing, error events, health endpoint). 6 tests, all passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
local
2026-04-04 02:21:10 +01:00
parent 00e7df2802
commit 17a5a58e73
13 changed files with 632 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
## Why
The project has zero test coverage. There are two controllers, a typed HttpClient service, and shared models — all untested. Adding tests now establishes the pattern before the codebase grows, and catches regressions as new phases are added.
## What Changes
- Create an xUnit test project for the API (`ChatAgent.Api.Tests`)
- Create an xUnit test project for the Client services (`ChatAgent.Client.Tests`)
- Add tests for HealthController (GET /api/health)
- Add tests for ChatController (POST /api/chat SSE streaming proxy)
- Add tests for ChatApiClient (GetHealthAsync, SendChatStreamingAsync)
- Add both test projects to the solution
## Capabilities
### New Capabilities
- `test-infrastructure`: Test project setup, test framework choices, and shared test utilities
### Modified Capabilities
<!-- None — adding tests doesn't change existing specs -->
## Impact
- `tests/ChatAgent.Api.Tests/`: New xUnit test project
- `tests/ChatAgent.Client.Tests/`: New xUnit test project
- `ChatAgent.sln`: Add test projects