← ClaudeAtlas

dotnet-unit-testslisted

Use this skill whenever the user asks you to write, generate, add, or scaffold unit tests for C# or .NET code. Trigger on: "write tests for this", "add unit tests", "test this class", "generate tests", "cover this with tests", "write NUnit tests", "mock this dependency", "how do I test this", "add test coverage", "write a test for this method", or any request that involves C#/.NET testing. Also trigger proactively when the user shows you a C# class or method and asks you to improve, review, or complete it — if there are no tests, offer to write them.
jzills/Claude-Marketplace · ★ 0 · Testing & QA · score 62
Install: claude install-skill jzills/Claude-Marketplace
# .NET Unit Test Writer You are writing production-quality unit tests for C# code using **NUnit** and **Moq**. Tests should be readable, maintainable, and actually catch bugs — not just satisfy a coverage metric. --- ## Project Setup If no test project exists, scaffold one using `assets/test-project.csproj` as the starting point. --- ## Test Structure: AAA Every test follows **Arrange / Act / Assert**. Separate the three sections with blank lines. Skip `// Arrange` comments unless the test is unusually long — well-named variables make the sections self-evident. ```csharp [Test] public void Withdraw_WhenBalanceSufficient_DeductsAmount() { var account = new BankAccount(initialBalance: 100m); account.Withdraw(30m); account.Balance.Should().Be(70m); } ``` --- ## Naming Convention Use the format: `MethodName_Condition_ExpectedOutcome` - `Calculate_WhenInputIsNegative_ThrowsArgumentException` - `GetUser_WhenUserExists_ReturnsUserDto` - `ProcessOrder_WhenStockIsEmpty_PublishesOutOfStockEvent` - `Save_Always_PersistsToRepository` (use `Always` when there is no meaningful condition) This makes failures self-documenting — the test name alone tells you exactly what broke. --- ## Fixture Setup NUnit creates a **new instance per test**, so use `[SetUp]` for per-test construction and `[OneTimeSetUp]` only for genuinely expensive shared resources. ```csharp [TestFixture] public class OrderServiceTests { private Mock<IOrderRepository> _repositoryMock; p