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>
1.1 KiB
1.1 KiB
1. Test Project Setup
- 1.1 Create xUnit test project at tests/ChatAgent.Api.Tests with xUnit, Moq, Microsoft.AspNetCore.Mvc.Testing
- 1.2 Create xUnit test project at tests/ChatAgent.Client.Tests with xUnit, Moq
- 1.3 Add both test projects to ChatAgent.sln under a tests solution folder
- 1.4 Make Api's Program class accessible to tests (public partial class Program)
2. API Tests
- 2.1 Test HealthController: GET /api/health returns 200 with valid HealthResponse
- 2.2 Test ChatController: POST /api/chat streams SSE text deltas from mocked upstream
- 2.3 Test ChatController: POST /api/chat handles upstream error gracefully
3. Client Service Tests
- 3.1 Create SSE response helper for building mock SSE streams
- 3.2 Test ChatApiClient.SendChatStreamingAsync: parses text deltas in order
- 3.3 Test ChatApiClient.SendChatStreamingAsync: throws on error event
- 3.4 Test ChatApiClient.GetHealthAsync: returns HealthResponse on success
4. Verify
- 4.1 Run dotnet test from solution root — all tests pass