Refactor nunit tests off InMemory/WebApplicationFactory, remove tuple returns #4

Merged
wamplerj merged 2 commits from unit-test-refactor into main 2026-07-04 21:40:48 -07:00
Owner

Summary

  • Extract IMicCheckDbContext and mock DB access with Moq instead of the EF InMemory provider, per CLAUDE.md testing guidelines.
  • Rewrite HTTP-pipeline tests to exercise controllers/auth handlers directly instead of WebApplicationFactory.
  • Remove tuple return types across the API in favor of named records (PagedResult<T>, ProfileUpdateResult, ApiKeyCreationResult).

Test plan

  • dotnet build (full solution)
  • dotnet test tests/api/MicCheck.Api.Tests.Unit — 187/187 pass
  • dotnet test tests/api/MicCheck.Api.Tests.Integration — 8/8 pass (live API + Postgres via Aspire)
  • Verified Aspire AppHost/dashboard starts and API responds
## Summary - Extract `IMicCheckDbContext` and mock DB access with Moq instead of the EF InMemory provider, per CLAUDE.md testing guidelines. - Rewrite HTTP-pipeline tests to exercise controllers/auth handlers directly instead of `WebApplicationFactory`. - Remove tuple return types across the API in favor of named records (`PagedResult<T>`, `ProfileUpdateResult`, `ApiKeyCreationResult`). ## Test plan - [x] `dotnet build` (full solution) - [x] `dotnet test tests/api/MicCheck.Api.Tests.Unit` — 187/187 pass - [x] `dotnet test tests/api/MicCheck.Api.Tests.Integration` — 8/8 pass (live API + Postgres via Aspire) - [x] Verified Aspire AppHost/dashboard starts and API responds
wamplerj added 2 commits 2026-07-04 21:40:17 -07:00
Extract IMicCheckDbContext so DB access can be mocked with Moq instead
of the InMemory provider, per project testing guidelines. Add shared
async DbSet test doubles (TestSupport/) to back the mocks. Rewrite
HTTP-pipeline tests (WebApplicationFactory) to exercise controllers
and auth handlers directly instead of running the web server. Drop
DbContext/seeder tests that only made sense against a real provider,
and remove stale duplicate test files left over from a namespace move.
CLAUDE.md prohibits tuples as return types. Add PagedResult<T>,
ProfileUpdateResult, and ApiKeyCreationResult records and update all
callers (AuditLogQueryService, AdminIdentityService, UserService,
ApiKeyService and their controllers/endpoints).
wamplerj merged commit 20188c61a2 into main 2026-07-04 21:40:48 -07:00
wamplerj deleted branch unit-test-refactor 2026-07-04 21:40:48 -07:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wamplerj/mic-check#4