Skip to content

feat: make the example exemplary (model the house testing pattern)#180

Merged
botantler[bot] merged 2 commits into
mainfrom
claude/dotnet-exemplary-example
May 31, 2026
Merged

feat: make the example exemplary (model the house testing pattern)#180
botantler[bot] merged 2 commits into
mainfrom
claude/dotnet-exemplary-example

Conversation

@devantler
Copy link
Copy Markdown
Contributor

🤖 Generated by the Daily AI Assistant

Fixes #170 (roadmap epic #167, direction 3 — exemplary by example).

Problem

The scaffold's example modeled no pattern a new project would want to copy: ExampleClass was an empty class and Test1() only asserted Assert.NotNull(new ExampleClass()). A template's job is to set the pattern, so the example should be exemplary while staying minimal.

Change

  • ExampleClass → one documented, idiomatic pure member: static int Add(int augend, int addend). The strict house analyzers themselves dictate the shape — a pure method that touches no instance data is flagged CA1822 (mark as static) and elevated to an error by TreatWarningsAsErrors, so the example models the analyzer-clean form (a static utility) rather than suppressing the rule.
  • Tests → rewritten to the house convention: Method_State_ExpectedResult naming, explicit Arrange / Act / Assert, and assertions on real behaviour (the computed sum) instead of non-null. A second case (negative operand) shows more than the happy path.

Acceptance criteria (all met)

  • ExampleClass has one documented member; the example stays minimal and idiomatic.
  • ✅ Tests follow Method_State_Expected naming with clear AAA and assert real behaviour.
  • dotnet build + dotnet test (Release) pass under the house TreatWarningsAsErrors + AnalysisMode=All: 0 warnings, 2 tests pass locally.

Notes

Mirrors the analogous go-template#74 example enrichment so the two starter templates read consistently (portfolio consistency). XS, scaffolding-only — no product features.

Draft pending your promotion.

The scaffold's example modeled no pattern worth copying: ExampleClass was an
empty class and the sole test (Test1) only asserted `Assert.NotNull(new
ExampleClass())`. Since a template's job is to set the pattern, make the example
exemplary while staying minimal.

- ExampleClass: one documented, idiomatic pure member — a static `Add(int, int)`.
  The strict house analyzers themselves guide the shape: a pure method that
  touches no instance data is flagged static (CA1822), so the example models the
  analyzer-clean form rather than fighting it.
- Tests: rewritten to the house convention — `Method_State_ExpectedResult`
  naming, explicit Arrange/Act/Assert, and assertions on real behaviour (the
  computed sum) rather than non-null. Adds a second case (negative operand) so
  the example shows more than the happy path.

Validated with `dotnet build` + `dotnet test` (Release) under the house
`TreatWarningsAsErrors` + `AnalysisMode=All` settings: 0 warnings, 2 tests pass.

Fixes #170

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 31, 2026 00:17
@github-code-quality
Copy link
Copy Markdown

github-code-quality Bot commented May 31, 2026

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the branch is 100%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 992be80 +/-
/home/runner/wo...ExampleClass.cs 100%

Updated May 31, 2026 07:16 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the template’s example code to demonstrate an analyzer-clean, minimal “house style” pattern with meaningful behavior and corresponding tests, addressing #170.

Changes:

  • Replaced the empty ExampleClass with a single documented, pure static method: Add(int, int).
  • Rewrote tests to follow clearer naming and explicit Arrange/Act/Assert while asserting real behavior (including a negative-operand case).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Example/ExampleClass.cs Makes the example type “exemplary” by adding one documented, analyzer-friendly pure member (Add).
tests/Example.Tests/ExampleClassTests.cs Replaces the placeholder test with two behavior-focused tests using explicit AAA structure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Example.Tests/ExampleClassTests.cs
@devantler devantler marked this pull request as ready for review May 31, 2026 06:35
The test name and summary implied Add special-cases a negative operand as
subtraction; it simply returns the sum. Rename to Add_NegativeOperand_ReturnsTheirSum
and reword the summary so the exemplar models accurate test naming.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@botantler botantler Bot enabled auto-merge (squash) May 31, 2026 07:16
@botantler botantler Bot merged commit f038294 into main May 31, 2026
11 checks passed
@botantler botantler Bot deleted the claude/dotnet-exemplary-example branch May 31, 2026 07:17
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.

Make the example exemplary (model the house testing pattern)

2 participants