Skip to content

feat(testimonials): add Testimonials module domain model and persistence - #1493

Merged
ardalis merged 2 commits into
mainfrom
issue-1489-testimonials-module-domain
Nov 16, 2026
Merged

ardalis merged 2 commits into
mainfrom
issue-1489-testimonials-module-domain

Conversation

@ardalis

@ardalis ardalis commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

This adds the Testimonials module, the first module built on the modular-monolith layout in .claude/plans/2026-07-29-modular-monolith-recommendations.md §4.4. It covers the domain model and persistence only. Authoring UI, the admin review queue and public display come next, in #1490, #1491 and #1492.

New projects

  • DevBetterWeb.Modules.Testimonials.Contracts has no dependencies. It holds TestimonialStatus, the TestimonialDto read model and ITestimonialQueries.ListAcceptedAsync.
  • DevBetterWeb.Modules.Testimonials keeps everything internal. Its only public surface is AddTestimonialsModule, UseTestimonialsSqlServer and ApplyTestimonialsMigrationsAsync. It does not reference DevBetterWeb.Core, and it points at the author by MemberId only.
  • tests/DevBetterWeb.Modules.Testimonials.Tests is the module's test project (xUnit and Shouldly).

Domain

Testimonial aggregate, with these transitions:

From To Notes
Draft PendingReview submit
PendingReview Accepted accept
PendingReview Declined feedback optional
PendingReview ChangesRequested feedback required
ChangesRequested PendingReview resubmit, which clears the feedback
Accepted Declined unpublish
  • Declined is terminal.
  • Editing is allowed only in Draft and ChangesRequested. An author can delete only a Draft (EnsureCanBeDeletedByAuthor).
  • An invalid transition throws InvalidTestimonialStateException. Inputs are checked before any state changes.
  • AuthorProfile value object: display name (required), title and organization (optional), and an optional https-only photo URL override.
  • Role checks (who counts as admin or author) belong to the use cases in Testimonials: member authoring UI #1490 and Testimonials: admin review queue #1491, not the entity.

Persistence

  • TestimonialsDbContext owns the testimonials schema, including its own __EFMigrationsHistory table. It shares the existing database through DefaultConnection.
  • Initial migration AddTestimonials:
    • AuthorProfile stored as an owned type
    • status stored as a string
    • RowVersion concurrency token
    • indexes on MemberId and (Status, ReviewedAt)

Host wiring

  • Program.cs registers the module (SQL Server with Metronome tracking outside Testing). It applies the module's migrations in the same Development, container or Aspire cases as the other contexts.
  • The FunctionalTests factory registers an in-memory provider for the module.
  • efscripts.txt gains the module's dotnet ef commands.
  • Directory.Packages.props adds Microsoft.EntityFrameworkCore.Design 11.0.0, which dotnet ef needs on the module project.

Deploy note

Production migrations are applied by hand. Before #1492 reads from the table, run the script below (also in efscripts.txt) from src/DevBetterWeb.Modules.Testimonials. The DB login needs CREATE SCHEMA permission.

dotnet ef migrations script --idempotent --context TestimonialsDbContext

Tests

  • Module tests (73):
    • every valid transition, plus every invalid one as a theory over all statuses
    • failed operations leave status, feedback and timestamps unchanged
    • AuthorProfile validation, including rejecting http, javascript: and data: photo URLs
    • the schema is testimonials, and migrations match the model (HasPendingModelChanges is false)
    • in-memory round trip
    • ListAcceptedAsync filtering, ordering and limit
    • DI registration
  • Functional test: the Testing host resolves ITestimonialQueries against its in-memory database.

Verification

  • dotnet BuildTestFormat.cs: the build succeeds and all 396 tests pass (AppHost 4, Functional 6, Testimonials 73, Tests 118, UnitTests 195).
  • The format step fails on errors that already exist across the repo on main. The three new projects and the new or changed test files are clean. Program.cs reports the same whitespace errors as on main (about 30, file-wide).
  • Separate-agent review: no blockers. It applied the migration to a throwaway LocalDB and rolled it back. Its minor findings were addressed; what was deliberately left alone, and why, is recorded in .claude/plans/2026-11-15-issue-1489-testimonials-module-domain.md.

Fixes #1489
Relates to #1472

🤖 Generated with Claude Code

ardalis and others added 2 commits November 15, 2026 16:19
Adds DevBetterWeb.Modules.Testimonials (+ .Contracts) as the first
modular-monolith module: Testimonial aggregate with review state machine,
AuthorProfile value object, module-owned DbContext in the testimonials
schema with initial migration, ITestimonialQueries.ListAcceptedAsync, and
host wiring. Includes a module test project.

Refs #1489

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Guard author deletion to drafts (EnsureCanBeDeletedByAuthor)
- Add RowVersion concurrency token; regenerate migration
- Require https photo URLs
- Make generated migration internal
- Add tests for review gaps and functional-host DI resolution

Refs #1489

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ardalis
ardalis merged commit d78a33d into main Nov 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Testimonials module: domain model and persistence

1 participant