Skip to content

Assert there is exactly one, rather than counting to one - #158

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/peaceful-mayer-oo6l2u
Sep 10, 2026
Merged

Assert there is exactly one, rather than counting to one#158
matt-edmondson merged 1 commit into
mainfrom
claude/peaceful-mayer-oo6l2u

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

The one finding SonarCloud left on #157 after its gate passed, in the test that PR added.

MSTEST0037 on GeneratorRegistryTests.RegisteringTwiceReplaces:

// before
Assert.AreEqual(1, SchemaGenerator.SupportedLanguages.Count(l => string.Equals(l, "fake-replaced", StringComparison.OrdinalIgnoreCase)));

// after
Assert.ContainsSingle(l => string.Equals(l, "fake-replaced", StringComparison.OrdinalIgnoreCase), SchemaGenerator.SupportedLanguages);

ContainsSingle says what the assertion means, and it reports which entries it found when there is more than one — which is precisely the failure this test exists to catch, a registration that duplicated instead of replacing. AreEqual(1, …) would only say "expected 1, was 2".

376 tests pass, 0 warnings, 0 errors.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk


Generated by Claude Code

MSTEST0037 on the replacement test: Assert.ContainsSingle says what the
assertion means, and reports which entries it found when there is more than
one - which is the failure this test exists to catch, a registration that
duplicated instead of replacing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit c3af369 into main Sep 10, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/peaceful-mayer-oo6l2u branch September 10, 2026 13:13
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.

2 participants