csharp-mstest
Get best practices for MSTest 3.x/4.x unit testing, including modern assertion APIs and data-driven tests
Skill by viniciuscs84
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/viniciuscs84-csharp-mstest
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/csharp-mstest
What's inside
- Skill name
csharp-mstest- Description
- Get best practices for MSTest 3.x/4.x unit testing, including modern assertion APIs and data-driven tests
- License
- MIT
- Instructions
- 475 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# MSTest Best Practices (MSTest 3.x/4.x)
Your goal is to help me write effective unit tests with modern MSTest, using current APIs and best practices.
## Project Setup
- Use a separate test project with naming convention `[ProjectName].Tests`
- Reference MSTest 3.x+ NuGet packages (includes analyzers)
- Consider using MSTest.Sdk for simplified project setup
- Run tests with `dotnet test`
## Test Class Structure
- Use `[TestClass]` attribute for test classes
- **Seal test classes by default** for performance and design clarity
- Use `[TestMethod]` for test methods (prefer over `[DataTestMethod]`)
- Follow Arrange-Act-Assert (AAA) pattern
- Name tests using pattern `MethodName_Scenario_ExpectedBehavior`
```csharp
[TestClass]
public sealed class CalculatorTests
{
[TestMethod]
public void Add_TwoPositiveNumbers_ReturnsSum()
{
// Arrange
var calculator = new Calculator();
// Act
var result = calculator.Add(2, 3);
// Assert
Assert.AreEqual(5, result);
}
}
```
## Test Lifecycle
- **Prefer constructors over `[TestInitialize]`** - enables `readonly` fields and follows standard C# patterns
- Use `[TestCleanup]` for cleanup that must run even if test fails
- Combine constructor with async `[TestInitialize]` when async setup is needed
```csharp
[TestClass]
public sealed class ServiceTests
{
private readonly MyService _service; // readonly enabled by constructor
public ServiceTests()
{
_service = new MyService();
}
[TestInitialize]
public async Task InitAsync()
{
// Use for async initialization only
await _service.WarmupAsync();
}
[TestCleanup]
public void Cleanup() => _service.Reset();
}
```
### Execution Order
1. **Assembly Initialization** - `[AssemblyInitialize]` (once per test assembly)
2. **Class Initialization** - `[ClassInitialize]` (once per test class)
3. **Test Initialization** (for every test method):
1. Constructor
2. Set `TestContext` property
3. `[TestInitialize]`
4. **Test Execution** - test method runs
5. **Test Cleanup** (for every test method):
1. `[TestCleanup]`
2. `DisposeAsync` (if implemented)
3. `Dispose` (if implemented)
6. **Class Cleanup** - `[ClassCleanup]` (once per test class)
7. **Assembly Cleanup** - `[AssemblyCleanup]` (once per test assembly)
## Modern Assertion APIs
MSTest provides three assertion classes: `Assert`, `StringAssert`, and `CollectionAssert`.
### Assert Class - Core Assertions
```csharp
// Equality
Assert.AreEqual(expected, actual);
Assert.AreNotEqual(notExpected, actual);
Assert.AreSame(expectedObject, actualObject); // Reference equality
Assert.AreNotSame(notExpectedObject, actualObject);
// Null checks
Assert.IsNull(value);
Assert.IsNotNull(value);
// Boolean
Assert.IsTrue(condition);
Assert.IsFalse(condition);
// Fail/Inconclusive
Assert.Fail("Test failed due to...");
Assert.Inconclusive("Test cannot be completed because...");
```
### Exception Testing (Prefer over `[ExpectedException]`)
```csharp
// Assert.Throws - matches TException or derived types
var ex = Assert.Throws<ArgumentException>(() => Method(null));
Assert.AreEqual("Value cannot be null.", ex.Message);
// Assert.ThrowsExactly - matches exact type only
var ex = Assert.ThrowsExactly<InvalidOperationException>(() => Method());From viniciuscs84/sdd-toolkit, MIT.
More from viniciuscs84/sdd-toolkit
- 0.479score
csharp-xml-docs
viniciuscs84
C# XML documentation with on-demand Haiku→Expert Review→Final workflow.
SkillCFreshness: CClaude Code +9 - 0.476score
agent-browser
viniciuscs84
Use for automated browser tasks (navigation, form filling, scraping, screenshots, web app testing).
SkillCFreshness: CClaude Code +9 - 0.474score
cpp-development
viniciuscs84
Use when writing, reviewing, or refactoring C++ code — covers workflow, essential patterns, and pre-commit checklist for modern C++17/20.
SkillCFreshness: CClaude Code +9 - 0.474score
audio-dsp
viniciuscs84
Use when implementing real-time DSP algorithms, audio thread architecture, or offline spectral analysis in C++/Rust.
SkillCFreshness: CClaude Code +9 - 0.473score
cpp-testing
viniciuscs84
Use when writing or fixing C++ tests, configuring GoogleTest/CTest, or adding coverage/sanitizers.
SkillCFreshness: CClaude Code +9 - 0.473score
code-review-excellence
viniciuscs84
Use when conducting code reviews or establishing review standards.
SkillCFreshness: CClaude Code +9 - 0.473score
agents-md
viniciuscs84
Use when asked to write or review AGENTS.md/CLAUDE.md/LLMs.md context files.
SkillCFreshness: CClaude Code +9 - 0.471score
audio-engineering-principles
viniciuscs84
Use for real-time audio code safety, determinism, and numeric hygiene.
SkillCFreshness: CClaude Code +9 - 0.470score
csharp-refactor
viniciuscs84
C# code refactoring skill.
SkillCFreshness: CClaude Code +9 - 0.469score
csharp-docs
viniciuscs84
Ensure that C# types are documented with XML comments and follow best practices for documentation.
SkillCFreshness: CClaude Code +9 - 0.468score
csharp-code-review
viniciuscs84
C# code review skill.
SkillCFreshness: CClaude Code +9 - 0.466score
csharp-async
viniciuscs84
Get best practices for C# async programming
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 30, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/viniciuscs84/sdd-toolkit
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from viniciuscs84
- 0.479score
csharp-xml-docs
viniciuscs84
C# XML documentation with on-demand Haiku→Expert Review→Final workflow.
SkillCFreshness: CClaude Code +9 - 0.476score
agent-browser
viniciuscs84
Use for automated browser tasks (navigation, form filling, scraping, screenshots, web app testing).
SkillCFreshness: CClaude Code +9 - 0.474score
audio-dsp
viniciuscs84
Use when implementing real-time DSP algorithms, audio thread architecture, or offline spectral analysis in C++/Rust.
SkillCFreshness: CClaude Code +9 - 0.474score
cpp-development
viniciuscs84
Use when writing, reviewing, or refactoring C++ code — covers workflow, essential patterns, and pre-commit checklist for modern C++17/20.
SkillCFreshness: CClaude Code +9 - 0.473score
code-review-excellence
viniciuscs84
Use when conducting code reviews or establishing review standards.
SkillCFreshness: CClaude Code +9 - 0.473score
cpp-testing
viniciuscs84
Use when writing or fixing C++ tests, configuring GoogleTest/CTest, or adding coverage/sanitizers.
SkillCFreshness: CClaude Code +9
Cite this page
csharp-mstest skill. Agent Mart. https://agentmart.dev/skills/viniciuscs84-csharp-mstest (last updated 2026-10-24)