-
Notifications
You must be signed in to change notification settings - Fork 0
chore: solution review & modernization — AI config, CI coverage, test coverage #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cef677a
chore: update AI system config, CI, editorconfig, and add test coverage
Copilot b57e8d5
chore: fix test files to compile and pass (use Assert.*, ThrowsExactl…
Copilot 8f09081
chore: fix prompt templates (ThrowsExactly, Assert.*, TestMethod not …
Copilot 4a4d925
Fix review comments: align test templates with conventions and update…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| --- | ||
| mode: edit | ||
| description: Add a new MSTest test class for a SharedCode source file following project conventions. | ||
| --- | ||
|
|
||
| # Add a Test Class | ||
|
|
||
| Add a new MSTest test class that exercises a source file in the SharedCode library. | ||
|
|
||
| ## Steps | ||
|
|
||
| 1. **Identify the source file** you want to test and locate it in the solution. | ||
|
|
||
| 2. **Choose the right test project** | ||
|
|
||
| | Source project | Test project | | ||
| |---|---| | ||
| | `SharedCode.Core` | `SharedCode.Core.Tests` | | ||
| | `SharedCode.Data` | `SharedCode.Data.Tests` | | ||
|
|
||
| 3. **Mirror the source folder structure** | ||
|
|
||
| Place the new file in the same relative subfolder as the source: | ||
|
|
||
| | Source file | Test file | | ||
| |---|---| | ||
| | `SharedCode.Core/Calendar/DateTimeExtensions.cs` | `SharedCode.Core.Tests/Calendar/DateTimeExtensionsTests.cs` | | ||
| | `SharedCode.Data/Paging/PagingDescriptor.cs` | `SharedCode.Data.Tests/PagingDescriptorTests.cs` | | ||
|
|
||
| 4. **Write the test class** following these rules: | ||
| - Annotate with `[TestClass]` | ||
| - Do **not** add a per-class `CA1515` suppression — it is already disabled at the project level via `.editorconfig` | ||
| - Use `[TestMethod]` for single-scenario tests | ||
| - Use `[DataTestMethod]` + `[DataRow(...)]` for parameterized tests | ||
| - Follow the **Arrange / Act / Assert** pattern with blank lines separating each block | ||
| - Use **MSTest assertions** (`Assert.AreEqual`, `Assert.IsTrue`, `Assert.IsNotNull`, `Assert.ThrowsExactly`) | ||
| - Name test methods as `<MemberUnderTest>_<Scenario>_<ExpectedOutcome>` | ||
|
|
||
| 5. **Verify zero warnings**: `dotnet build SharedCode.sln` | ||
|
|
||
| ## Template — single-scenario test | ||
|
|
||
| ```csharp | ||
| namespace SharedCode.Tests.<Folder>; | ||
|
|
||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| /// <summary> | ||
| /// Tests for <see cref="<TypeUnderTest>" />. | ||
| /// </summary> | ||
| [TestClass] | ||
| public class <TypeUnderTest>Tests | ||
| { | ||
| /// <summary> | ||
| /// Tests that <Member> does [expected behavior]. | ||
| /// </summary> | ||
| [TestMethod] | ||
| public void <Member>_<Scenario>_<ExpectedOutcome>() | ||
| { | ||
| // Arrange | ||
| var sut = <create instance or value>; | ||
|
|
||
| // Act | ||
| var result = sut.<Member>(...); | ||
|
|
||
| // Assert | ||
| Assert.AreEqual(<expected>, result); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Template — parameterized test | ||
|
|
||
| ```csharp | ||
| /// <summary> | ||
| /// Tests that <Member> returns the expected result for various inputs. | ||
| /// </summary> | ||
| [DataTestMethod] | ||
| [DataRow(<input1>, <expected1>)] | ||
| [DataRow(<input2>, <expected2>)] | ||
| public void <Member>_<Scenario>_<ExpectedOutcome>(<InputType> input, <ExpectedType> expected) | ||
| { | ||
| // Arrange | ||
| var sut = <create instance or value>; | ||
|
|
||
| // Act | ||
| var result = sut.<Member>(input); | ||
|
|
||
| // Assert | ||
| Assert.AreEqual(expected, result); | ||
| } | ||
| ``` | ||
|
|
||
| ## Template — exception test | ||
|
|
||
| ```csharp | ||
| /// <summary> | ||
| /// Tests that <Member> throws <ExceptionType> when [condition]. | ||
| /// </summary> | ||
| [TestMethod] | ||
| public void <Member>_<Condition>_Throws<ExceptionType>() | ||
| { | ||
| // Act / Assert | ||
| _ = Assert.ThrowsExactly<<ExceptionType>>( | ||
| () => <sut>.<Member>(<args>)); | ||
| } | ||
| ``` | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| mode: edit | ||
| description: Identify untested public members and add test coverage for them. | ||
| --- | ||
|
|
||
| # Improve Test Coverage | ||
|
|
||
| Identify public members in a SharedCode source file (or folder) that have no test coverage | ||
| and add tests for them. | ||
|
|
||
| ## Process | ||
|
|
||
| ### 1 — Identify what is missing | ||
|
|
||
| For each `.cs` file in the source project: | ||
|
|
||
| 1. List every `public` method, property, and indexer. | ||
| 2. Open the corresponding `*Tests.cs` file in the test project (if it exists). | ||
| 3. Note every member that has **no** `[TestMethod]` exercising it. | ||
| 4. If no test file exists at all, every public member needs coverage. | ||
|
|
||
| ### 2 — Prioritize | ||
|
|
||
| Cover members in this order: | ||
| 1. Pure logic methods (no I/O or infrastructure) — easiest to test | ||
| 2. Guard-clause paths (`ArgumentNullException`, `ArgumentException`) | ||
| 3. Edge cases (empty collections, null-optional parameters, boundary values) | ||
| 4. Happy paths for remaining members | ||
|
|
||
| ### 3 — Write the tests | ||
|
|
||
| Follow the conventions in `add-test-class.prompt.md`: | ||
| - `[TestMethod]` for single scenarios | ||
| - `[DataRow]` for parameterized scenarios | ||
| - MSTest assertions (`Assert.AreEqual`, `Assert.IsTrue`, `Assert.ThrowsExactly`) | ||
| - Arrange / Act / Assert blocks separated by blank lines | ||
|
|
||
| ### 4 — Verify | ||
|
|
||
| ```bash | ||
| dotnet test SharedCode.sln | ||
| ``` | ||
|
|
||
| Zero failures required before merging. | ||
|
|
||
| ## Checklist per source file | ||
|
|
||
| Run through these questions for each public member: | ||
|
|
||
| - [ ] Is there a happy-path test? | ||
| - [ ] Is there a null-argument test (if the member accepts reference-type parameters)? | ||
| - [ ] Is there a boundary/edge-case test (empty string, zero, `int.MaxValue`, etc.)? | ||
| - [ ] Is the test parameterized with `[DataRow]` instead of repeated copy-paste? | ||
|
|
||
| ## Common coverage gaps in this solution | ||
|
|
||
| | Source file | Members typically missing coverage | | ||
| |---|---| | ||
| | `AssemblyExtensions.cs` | `GetAttribute<T>` (found / not found) | | ||
| | `EventHandlerExtensions.cs` | `Raise` overloads (null handler, non-null handler) | | ||
| | `Extensions.cs` | `IsBetween`, `In`, `IfNotNull`, `IsNull<T>`, `ChangeType<T>` | | ||
| | `FunctionExtensions.cs` | `Memoize` (cache hit, cache miss) | | ||
| | `TypeExtensions.cs` | `GetDisplayName`, `IsNullable`, `IsSubclassOfRawGeneric` | | ||
| | `PropertySupport.cs` | `ExtractPropertyName` | | ||
| | `Linq/` | All `IEnumerable<T>` extension methods | | ||
| | `Security/` | Hashing / encryption helpers | | ||
| | `Text/` | All string extension methods | | ||
| | `Threading/` | All task/threading helpers | | ||
| | `Domain/` | `ValueObject` equality | | ||
| | `Specifications/` | `InMemorySpecificationEvaluator` | |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.