Skip to content

[Test] Unit + Integration tests for DeleteCategoryHandler and DeleteStatusHandler #122

@mpaulosky

Description

@mpaulosky

Summary

Sprint 3 adds DeleteCategoryHandler and DeleteStatusHandler. This issue covers all test coverage for those handlers.

Test Files to Create

Unit Tests — Handler Layer

tests/Api.Tests.Unit/Handlers/Categories/DeleteCategoryHandlerTests.cs

  • Handle_ValidId_SetsArchivedFieldsAndPersists — verifies Archived=true, ArchivedBy, ArchivedOn are set
  • Handle_CategoryNotFound_ReturnsFailure
  • Handle_RepositoryThrows_ReturnsFailure

tests/Api.Tests.Unit/Handlers/Statuses/DeleteStatusHandlerTests.cs

  • Same three tests, mirrored for Status domain

Unit Tests — Endpoint Layer

tests/Api.Tests.Unit/Endpoints/CategoryEndpointsTests.cs (extend existing)

  • DeleteCategory_AdminUser_Returns204
  • DeleteCategory_NonAdmin_Returns403
  • DeleteCategory_NotFound_Returns404

tests/Api.Tests.Unit/Endpoints/StatusEndpointsTests.cs (extend existing)

  • Mirror above for Status

Integration Tests

tests/Api.Tests.Integration/Handlers/DeleteCategoryHandlerIntegrationTests.cs

  • Full round-trip: create a category via handler, delete it, verify it's not returned in List
  • Use TestContainers MongoDB setup (follow existing integration test pattern)

tests/Api.Tests.Integration/Handlers/DeleteStatusHandlerIntegrationTests.cs

  • Same round-trip for Status

Test Tooling (match existing patterns)

  • xUnit, FluentAssertions, NSubstitute (unit)
  • TestContainers + MongoDbRunner (integration)
  • Follow the existing *HandlerTests.cs pattern in Api.Tests.Unit/Handlers/Categories/

Acceptance Criteria

  • All new unit tests pass locally
  • All new integration tests pass locally (with TestContainers)
  • Code coverage for DeleteCategoryHandler and DeleteStatusHandler is ≥ 80%
  • CI pipeline stays green

Depends On

Metadata

Metadata

Labels

go:yesReady to implementpriority:p2Next sprintrelease:backlogNot yet targetedsprint-3Sprint 3 — Full CRUD UI + ArchivesquadSquad triage inbox — Lead will assign to a membersquad:copilotAssigned to @copilot (Coding Agent) for autonomous worksquad:gimliAssigned to Gimli (Tester)type:choreMaintenance, refactoring, cleanup

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions