Restructure tests and reach full coverage - #23
Merged
Conversation
Applies the C# test conventions: fixtures renamed from *TestFixture to *Tests, unit test methods named MethodUnderTest_Scenario, methods sorted alphabetically, and arrange/act/assert comments removed. End-to-end scenario tests move into an Integration namespace, where the method name is just the scenario being verified. Per-class unit tests stay at the root next to the class they cover. Also renames the MetadataProviderScenario folder to match the namespace its files already declared. Adds tests for the previously uncovered argument guards on MetadataHelper, MetadataModule and AutofacAttributeExtensions, a direct test of the IMetadataProvider path, and one for the documented rule that write-only attribute properties contribute no metadata. Line and branch coverage are now both 100%.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #23 +/- ##
=============================================
+ Coverage 56.52% 100.00% +43.47%
=============================================
Files 4 4
Lines 69 69
Branches 24 24
=============================================
+ Hits 39 69 +30
+ Misses 14 0 -14
+ Partials 16 0 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Nests single-use support types as private classes in the test that uses them: the nested scope component and all four metadata modules. Merges duplicate support types. The Name-only and Name-plus-Age metadata views each existed twice under different names, and three separate attributes carried a single string property. These become INameMetadata, INameAndAgeMetadata, NameMetadataAttribute, AgeMetadataAttribute and NameAndAgeMetadataAttribute. Flattens ScenarioTypes to a single namespace, which removes the MetadataModuleScenarioDiscoveryTargets name. Service interfaces stay distinct per scenario because the assembly scanning tests filter on them and assert exact counts. Merges the three single-test assembly scanning classes into Integration.AssemblyScanningTests. Scenario support files drop from 32 to 20. Coverage stays at 100% of lines and branches.
The old names described the test that used a type rather than the type itself, so ScenarioTypes becomes Stubs and every name now says what the thing is: - Metadata views: IDataView, IDataAndCountView, DataView, ProvidedDataView. - Attributes: DataAttribute and CountAttribute are reflected into the metadata dictionary; DataAndCountAttribute implements its view so the typed discovery overload can find it; ProvidedDataAttribute supplies its own dictionary. - Components: Reflected, Combined, Typed, Programmatic and Provided, each named for how its metadata arrives. The weak/strong typed wording is gone. It had no counterpart in the implementation, so the two discovery modes are now described where they live: the untyped GetMetadata overload takes every metadata attribute, while the typed overload takes only attributes assignable to a given view. Each stub carries an XML summary saying what it is and why it exists. Payload properties are Data and Count rather than Name and Age so they read as arbitrary values and not as domain concepts. Coverage stays at 100% of lines and branches.
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.
Test-only change. No production source is touched.
Conventions applied
*TestFixture→*Testsfor every file and class.MethodUnderTest_Scenariowith a single underscore.// arrange/// act/// assertcomments removed.Layout
End-to-end scenario tests moved to an
Integrationnamespace, where the method name is just the scenario being verified. Per-class unit tests stay at the root, next to the class they cover.Coverage
Went from 79.71% lines / 47 of 50 branches to 100% lines and 100% branches, 40 tests up from 22.
New tests cover the argument guards on
MetadataHelper,MetadataModule<,>andAutofacAttributeExtensions(one test per guard, no parameterization, asserting only the exception type), plus a direct test of theIMetadataProviderpath inGetProperties.Two of the branch gaps were worth understanding rather than papering over:
AutofacAttributeExtensions.cshad a half-covered branch on the typed-metadata scanning overload. It was the compiler's cached-delegate initialization, only reachable by invoking that overload more than once per closed generic. Covered by giving that overload its own positive unit test, which it was missing anyway.MetadataHelper.cshad a half-covered branch in the property filter: no test ever passed an attribute with a non-readable property. Covered byGetProperties_WriteOnlyProperty, which pins the documented rule that only publicly readable properties become metadata.Also
Renamed the
ScenarioTypes/MetadataProviderScenariofolder toMetadataProviderScenarioTypesso it matches the namespace its files already declared. Folder-only move, no code change. Happy to drop this if you'd rather keep the PR strictly to the test restructure.Verification
dotnet msbuild ./default.projclean: 40/40 tests pass on net10.0 and net8.0, zero warnings, packages build.dotnet format --verify-no-changesclean. Verified programmatically that noFixturenames or arrange/act/assert comments remain and that every class's test methods are in alphabetical order.