dotnet-test
Skill1 starsChanged 7 months agoMITView on GitHub
Manages unit tests using xUnit in .NET projects. Creates the test project if it doesn't exist, organizes tests by layer (Domain, Application, Infra, API), mirrors the source folder structure, and generates test files. Use when creating, updating, or organizing unit tests.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- codebeltnet/agentictheir own version, first seen Oct 3, 2026
- KonH/GlobalStrategytheir own version, first seen Sep 3, 2026
- emaginebr/AvaBotword for word, first seen Apr 8, 2026
Other versions3 projects use a version of this.
Word for word · 1
- emaginebr/AvaBot★ 2100% same
Edited · 0
None found.
Wrote their own version · 2
- codebeltnet/agentic★ 3same name
- KonH/GlobalStrategy★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- readme-generatorSkill
- add-react-i18nSkill
- band-album-campaignSkill
- band-music-reflectionSkill
- band-streaming-launchSkill
- ckm:banner-designSkill
- ckm:brandSkill
- deploy-prodSkill
- ckm:designSkill
- ckm:design-systemSkill
- docker-compose-configSkill
- doc-managerSkill
- dotnet-architectureSkill
- dotnet-doc-controllerSkill
- dotnet-envSkill
- dotnet-fluent-validationSkill
- dotnet-graphqlSkill
- dotnet-multi-tenantSkill
- dotnet-test-apiSkill
- frontend-designSkill
- gitversionSkill
- maui-architectureSkill
- mermaid-chartSkill
- nauth-guideSkill
- nnews-guideSkill
- react-alertSkill
- react-architectureSkill
- react-archSkill
- react-modalSkill
- readme-generatorSkill
- ckm:slidesSkill
- social-media-assetsSkill
- social-media-schedulingSkill
- social-post-authoringSkill
- ckm:ui-stylingSkill
- ui-ux-pro-maxSkill
- wsl-dockerSkill
- ztools-guideSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
Create only one test project for the entire solution, named {SolutionName}.Tests.
- Very specific: line 65
Test file name = {ClassName}Test.cs (e.g., ProductService → ProductServiceTest.cs)
- Distinctive: line 71
If the test project does not exist, create it:
- Distinctive: line 170
Mock dependencies: All repository and external service calls
- Distinctive: line 173
All properties mapped correctly: Verify each field in the output matches the input
- Distinctive: line 178
Only test if there is custom logic (e.g., complex queries, computed values)
- Very specific: line 179
Use in-memory database (UseInMemoryDatabase) for EF Core repository tests
- Distinctive: line 180
Do NOT test basic CRUD that EF Core already guarantees
- Very specific: line 183
Authorization: Verify Unauthorized() when no session
- Very specific: line 184
Not found: Verify NotFound() for missing resources
- Very specific: line 185
Forbidden: Verify Forbid() for access denied
- Very specific: line 186
Happy path: Verify Ok() with correct data
- Distinctive: line 187
Mock services: All service layer calls
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
.NET Unit Test Manager (xUnit)
You are an expert assistant that helps developers create and manage unit tests using xUnit in .NET projects. You follow a strict convention for project structure, naming, and organization.
Input
The user will describe what to test: $ARGUMENTS
Before generating tests:
- Read the solution structure — Identify all projects/layers and the
.slnfile - Find the test project — Look for a project ending in
.Tests(e.g.,MyApp.Tests) - Read the class to be tested — Understand its dependencies, methods, and behavior
- Read the DI/Startup — Understand how services are wired up
- Identify existing test patterns — If tests already exist, match their style exactly
Test Project Convention
Single Test Project
Create only one test project for the entire solution, named {SolutionName}.Tests.
MySolution/
├── MySolution.sln
├── MySolution.API/
├── MySolution.Application/
├── MySolution.Domain/
├── MySolution.Infra/
├── MySolution.Infra.Interfaces/
├── MySolution.DTO/
└── MySolution.Tests/ ← Single test project
├── MySolution.Tests.csproj
├── Domain/
│ ├── Services/
│ │ ├── ProductServiceTest.cs
│ │ └── OrderServiceTest.cs
│ └── Mappers/
│ └── ProductMapperTest.cs
├── Application/
│ └── StartupTest.cs
├── Infra/
│ ├── Repository/
│ │ └── ProductRepositoryTest.cs
│ └── Mappers/
│ └── ProductDbMapperTest.cs
└── API/
└── Controllers/
└── ProductControllerTest.csFolder Mirroring Rules
- The test project mirrors the layer names as top-level folders:
Domain/,Application/,Infra/,API/, etc. - Inside each layer folder, mirror the subfolder structure of the source project (e.g.,
Services/,Repository/,Mappers/,Controllers/) - Each test file corresponds to one source class
- Test file name =
{ClassName}Test.cs(e.g.,ProductService→ProductServiceTest.cs)
Creating the Test Project
If the test project does not exist, create it:
# 1. Create the xUnit project
dotnet new xunit -n {SolutionName}.Tests -o {SolutionName}.Tests
# 2. Add it to the solution
dotnet sln {SolutionName}.sln add {SolutionName}.Tests/{SolutionName}.Tests.csproj
# 3. Add references to all projects that need testing
dotnet add {SolutionName}.Tests/{SolutionName}.Tests.csproj reference {SolutionName}.Domain/{SolutionName}.Domain.csproj
dotnet add {SolutionName}.Tests/{SolutionName}.Tests.csproj reference {SolutionName}.Infra/{SolutionName}.Infra.csproj
dotnet add {SolutionName}.Tests/{SolutionName}.Tests.csproj reference {SolutionName}.Application/{SolutionName}.Application.csproj
dotnet add {SolutionName}.Tests/{SolutionName}.Tests.csproj reference {SolutionName}.API/{SolutionName}.API.csproj
# ... add all projects that contain classes to test
# 4. Add Moq for mocking
dotnet add {SolutionName}.Tests/{SolutionName}.Tests.csproj package Moq
# 5. Delete the default UnitTest1.cs
rm {SolutionName}.Tests/UnitTest1.csRequired Packages
The test project must have:
xunit(included by template)xunit.runner.visualstudio(included by template)Microsoft.NET.Test.Sdk(included by template)Moq(add manually)
Test File Structure
Naming Conventions
- Class name:
{ClassName}Test(e.g.,ProductServiceTest) - Namespace:
{SolutionName}.Tests.{Layer}.{SubFolder}(e.g.,MyApp.Tests.Domain.Services) - Method name:
{MethodName}_Should{ExpectedBehavior}_When{Condition}(e.g.,InsertAsync_ShouldThrowException_WhenNameIsEmpty)
Template
using Xunit;
using Moq;
// ... other usings
namespace {SolutionName}.Tests.{Layer}.{SubFolder}
{
public class {ClassName}Test
{
private readonly Mock<IDependency1> _dependency1Mock;
private readonly Mock<IDependency2> _dependency2Mock;
private readonly {ClassName} _sut; // System Under Test
public {ClassName}Test()
{
_dependency1Mock = new Mock<IDependency1>();
_dependency2Mock = new Mock<IDependency2>();
_sut = new {ClassName}(
_dependency1Mock.Object,
_dependency2Mock.Object
);
}
[Fact]
public async Task {MethodName}_Should{Expected}_When{Condition}()
{
// Arrange
// ...
// Act
// ...
// Assert
// ...
}
[Theory]
[InlineData("", false)]
[InlineData("valid", true)]
public async Task {MethodName}_ShouldValidate_When{Condition}(string input, bool expected)
{
// Arrange, Act, Assert
}
}
}What to Test
Services (Domain Layer)
- Validation logic: Empty/null inputs, invalid values, boundary conditions
- Business rules: Authorization checks, ownership validation, state transitions
- Happy path: Successful operations with correct data
- Exception handling: Expected exceptions for error scenarios
- Mock dependencies: All repository and external service calls
Mappers
- All properties mapped correctly: Verify each field in the output matches the input
- Null/default handling: Nullable fields, default values
- No mocking needed: Mappers are pure functions, test with real data
Repositories (Infra Layer)
- Only test if there is custom logic (e.g., complex queries, computed values)
- Use in-memory database (
UseInMemoryDatabase) for EF Core repository tests - Do NOT test basic CRUD that EF Core already guarantees
Controllers (API Layer)
- Authorization: Verify
Unauthorized()when no session - Not found: Verify
NotFound()for missing resources - Forbidden: Verify
Forbid()for access denied - Happy path: Verify
Ok()with correct data - Mock services: All service layer calls
Running Tests
# Run all tests
dotnet test {SolutionName}.Tests
# Run with verbose output
dotnet test {SolutionName}.Tests --verbosity normal
# Run specific test class
dotnet test {SolutionName}.Tests --filter "FullyQualifiedName~ProductServiceTest"
# Run specific test method
dotnet test {SolutionName}.Tests --filter "FullyQualifiedName~InsertAsync_ShouldThrowException_WhenNameIsEmpty"Checklist
Before finishing, verify:
- Test project exists and is added to the solution
- Folder structure mirrors the source project layers
- Each test file tests only one source class
- Test file names end with
Test.cs - All dependencies are mocked (no real DB, no real HTTP calls)
- Tests follow Arrange/Act/Assert pattern
- Method names describe behavior:
{Method}_Should{What}_When{Condition} - Tests compile:
dotnet build {SolutionName}.Tests - Tests pass:
dotnet test {SolutionName}.Tests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

