feat: make the example exemplary (model the house testing pattern)#180
Merged
Conversation
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>
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe 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.
Updated |
There was a problem hiding this comment.
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
ExampleClasswith a single documented, purestaticmethod: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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ExampleClasswas an empty class andTest1()only assertedAssert.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 flaggedCA1822(mark as static) and elevated to an error byTreatWarningsAsErrors, so the example models the analyzer-clean form (astaticutility) rather than suppressing the rule.Method_State_ExpectedResultnaming, 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)
ExampleClasshas one documented member; the example stays minimal and idiomatic.Method_State_Expectednaming with clear AAA and assert real behaviour.dotnet build+dotnet test(Release) pass under the houseTreatWarningsAsErrors+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.