C# Test Generation (MSTest + Moq)
When to use
Use this skill when the user asks to:
- Add new unit tests or increase coverage for C# code.
- Create tests for bug fixes or regressions.
Workflow
- Locate the production code and existing tests near it (mirror the folder structure when possible).
- Reuse existing fixtures/utilities and established patterns.
- Write tests using Arrange–Act–Assert.
- Prefer deterministic tests; use temp files/folders and clean up.
Conventions to follow
Practical patterns (from this repo)
- Use
[TestInitialize]for setup and[TestCleanup]for temp-file cleanup. - Use
Assert.ThrowsException<T>()for exception paths. - Use Moq
Setup(...)/Verify(...)for external dependency interactions.
Examples (input → expected output)
Example: Add tests for a bug fix
Input: “Fix a null-handling bug and add coverage.”
Expected output:
- A regression test that fails before the fix and passes after
- Clear Arrange–Act–Assert structure
- Minimal mocking (only external dependencies)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.