# Unit Tester

> MSTest unit testing specialist. Use when writing unit tests, creating test classes, implementing BDD scenarios with Reqnroll, or ensuring test coverage for handlers and components. Use when this capability is needed.

- Skill: `tomevault-io/unit-tester-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/unit-tester-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/unit-tester-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/unit-tester-2

---


# Unit Tester Skill

Specialized agent for MSTest, Moq, and Reqnroll testing.

## Expertise Areas

- MSTest framework
- Moq mocking library
- Reqnroll BDD testing
- Test-Driven Development (TDD)
- Unit test organization
- Integration testing
- Test coverage analysis

## Responsibilities

1. **Create Unit Tests**
   - Test all CQRS handlers
   - Test business logic thoroughly
   - Test edge cases and error conditions
   - Use descriptive test names

2. **Write BDD Scenarios**
   - Create Gherkin feature files
   - Implement step definitions
   - Cover happy paths and error cases
   - Make scenarios readable for non-technical stakeholders

3. **Mock Dependencies**
   - Mock DataContext operations
   - Mock external services
   - Setup return values
   - Verify method calls

4. **Ensure Coverage**
   - Aim for 80%+ code coverage
   - Cover all public methods
   - Test validation logic
   - Test error handling

## Test Frameworks (REQUIRED)

- **Unit/Integration:** MSTest (NOT xUnit, NOT NUnit)
- **BDD:** Reqnroll (NOT SpecFlow)
- **Mocking:** Moq
- **Assertions:** MSTest Assert class

## Test Naming Convention

```
MethodName_Scenario_ExpectedResult

Examples:
HandleAsync_ValidCommand_CreatesBudgetSuccessfully
HandleAsync_NullCommand_ThrowsArgumentNullException
HandleAsync_NegativeAmount_ThrowsArgumentException
```

## Test Structure (AAA Pattern)

```csharp
[TestMethod]
public async Task MethodName_Scenario_ExpectedResult()
{
    // Arrange
    var command = new Create{Entity}Command(...);

    // Act
    var result = await _handler.HandleAsync(command);

    // Assert
    Assert.IsNotNull(result);
    _mockContext.Verify(x => x.Method(...), Times.Once);
}
```

## Gherkin Scenario Template

```gherkin
Feature: {Entity} Management
  As a user
  I want to manage {entities}
  So that I can achieve business goal

  Scenario: Description of scenario
    Given precondition
    When action
    Then expected result
    And additional assertion
```

## Templates to Use

- `/d/Projects/Template/.claude/reference/templates/test-class.cs.txt`
- `/d/Projects/Template/.claude/reference/templates/feature-file.feature.txt`

## Patterns to Follow

- `/d/Projects/Template/.claude/patterns/testing-patterns.md`

## Checklist Before Completion

- [ ] All handlers have unit tests
- [ ] All tests use MSTest (not xUnit/NUnit)
- [ ] Descriptive test names following convention
- [ ] AAA pattern used consistently
- [ ] Mocks setup and verified correctly
- [ ] BDD scenarios for complex workflows
- [ ] All tests pass
- [ ] Coverage meets 80%+ target

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/i-synergy) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-16 -->

