csharp-nunit

Guides writing, reviewing, and refactoring NUnit unit tests in C# projects.

Updated Aug 24, 2026
One-click install
npx skills add https://github.com/aggutierrez98/TP-TD --skill csharp-nunit-aggutierrez98
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: csharp-nunit
Source: https://github.com/aggutierrez98/TP-TD/tree/main/.agents/skills/csharp-nunit
Command: npx skills add https://github.com/aggutierrez98/TP-TD --skill csharp-nunit-aggutierrez98

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, maintainable unit tests in C# requires knowing NUnit conventions, attributes, and assertion styles. This Skill provides structured best practices so your tests follow the Arrange-Act-Assert pattern, proper naming, and correct use of data-driven testing features. ## Core Features & Use Cases - Project Setup Guidance: Covers test project naming conventions, required NuGet packages (Microsoft.NET.Test.Sdk, NUnit, NUnit3TestAdapter), and dotnet test commands. - Data-Driven Testing: Explains [TestCase], [TestCaseSource], [Values], [ValueSource], [Random], [Range], and combinatorial approaches for parameterized tests. - Assertion & Organization Standards: Recommends the Assert.That constraint model, exception testing with Assert.Throws<T>, and test organization via [Category], [Order], and [Ignore]. - Use Case: When refactoring a legacy test suite, apply these guidelines to convert classic Assert.AreEqual calls to the constraint model and consolidate repetitive tests into [TestCase] data-driven tests. ## Quick Start Help me write NUnit unit tests for my Calculator class using data-driven [TestCase] attributes and the Assert.That constraint model.

Frequently Asked Questions about csharp-nunit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write data-driven tests in NUnit?▼

Use [TestCase] for inline test data directly on the test method, or [TestCaseSource] for programmatically generated data. For simple parameter combinations, use [Values], [Range], or [Random] attributes with [Combinatorial] or [Pairwise] strategies.

What is the difference between Assert.That and Assert.AreEqual in NUnit?▼

Assert.That uses NUnit's constraint model with expressions like Is.EqualTo and Contains.Item, which is the preferred modern style. Assert.AreEqual is the classic style for simple value equality, while CollectionAssert and StringAssert handle specific types.

How do I test exceptions in NUnit?▼

Use Assert.Throws<T> for synchronous methods and Assert.ThrowsAsync<T> for asynchronous methods to verify that specific exception types are raised. This keeps exception assertions explicit and readable within the Arrange-Act-Assert pattern.

What NuGet packages does an NUnit test project need?▼

An NUnit test project requires Microsoft.NET.Test.Sdk, NUnit, and NUnit3TestAdapter packages. Create a separate project named [ProjectName].Tests and run tests with the dotnet test command.

Can I use Moq or NSubstitute with NUnit?▼

Yes, NUnit works alongside mocking frameworks like Moq or NSubstitute to isolate units under test. Mock dependencies through interfaces, and consider a DI container for complex test setups.

How do I skip or organize NUnit tests?▼

Use [Ignore("Reason")] to temporarily skip tests and [Explicit] for tests that should not run automatically. Organize suites with [Category], control execution order with [Order], and document ownership using [Author] and [Description].