Agent skill

Writing Unit Tests Csharp

by microsoft-foundry in microsoft-foundry/foundry-agent-webapp

Guidelines and patterns for writing unit tests in C using MSTest SDK.

MITAuto-check passedTesting & QA

Install Writing Unit Tests Csharp

skills CLI
$ npx skills add microsoft-foundry/foundry-agent-webapp --skill writing-unit-tests-csharp -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft-foundry/foundry-agent-webapp writing-unit-tests-csharp --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft-foundry/foundry-agent-webapp.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/writing-unit-tests-csharp .claude/skills/writing-unit-tests-csharp && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
writing-unit-tests-csharp
GitHub stars
127
Token cost
~1k tokens
SKILL.md length
203 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

Guidelines and patterns for writing unit tests in C using MSTest SDK.

  • Tasks that involve Unit testing
  • SKILL.md covers Overview, Project Structure, Test Project Configuration and Test Anatomy, plus 6 more sections
  • Calls dotnet

What it does

Writing Unit Tests Csharp is an agent skill from microsoft-foundry/foundry-agent-webapp. Guidelines and patterns for writing unit tests in C using MSTest SDK.

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing. It works with C# and .NET. The repository describes itself as: GitHub Copilot enabled repo for building and deploying a web application with Entra ID authentication and integrated with Azure AI Foundry Agents. The licence is MIT.

When your agent uses it

  • Tasks that involve Unit testing

Example prompts

  • “Use the writing-unit-tests-csharp skill to guideline and patterns for writing unit tests in C using MSTest SDK”
  • “/writing-unit-tests-csharp”

What it can do on your machine

Read from SKILL.md and the folder at commit f6cb362. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Writing Unit Tests Csharp loads about 1k tokens when it runs. Until then it costs about 24 tokens; SKILL.md has 203 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~24
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft-foundry/foundry-agent-webapp at commit f6cb362, republished under its MIT licence (© microsoft-foundry). 203 words, ~1,024 tokens.

Download SKILL.mdSave it as .claude/skills/writing-unit-tests-csharp/SKILL.md (or your agent's skills folder).
name
writing-unit-tests-csharp
description
Guidelines and patterns for writing unit tests in C# using MSTest SDK.

Skill: Writing C# Unit Tests

Overview

This skill covers writing unit tests for the backend using MSTest SDK. The project uses a lean, zero-config approach that leverages Microsoft's official SDK-style testing.

Project Structure

text
backend/
├── WebApp.sln
├── WebApp.Api/
│   ├── Models/           # DTOs and request/response models
│   ├── Services/         # Business logic and agent integration
│   └── Program.cs        # Minimal API endpoints
└── WebApp.Api.Tests/
    ├── WebApp.Api.Tests.csproj
    └── [TestClass].cs    # Test files organized by class under test

Test Project Configuration

The test project uses MSTest SDK which eliminates the need for explicit package references:

See backend/WebApp.Api.Tests/WebApp.Api.Tests.csproj for current configuration. The project uses MSTest SDK which eliminates the need for explicit package references — just set Sdk="MSTest.Sdk/{version}" in the project element.

Test Anatomy

csharp
using WebApp.Api.Models;

namespace WebApp.Api.Tests;

[TestClass]
public class ErrorResponseFactoryTests
{
    [TestMethod]
    public void CreateFromException_ReturnsCorrectStatusCode()
    {
        // Arrange
        var exception = new InvalidOperationException("Test");
        
        // Act
        var result = ErrorResponseFactory.CreateFromException(exception, 500, isDevelopment: false);
        
        // Assert
        Assert.AreEqual(500, result.Status);
    }
    
    [TestMethod]
    [DataRow(400, "Bad Request")]
    [DataRow(401, "Unauthorized")]
    [DataRow(500, "Internal Server Error")]
    public void CreateFromException_MapsStatusToTitle(int status, string expectedTitle)
    {
        // Parameterized test using DataRow
    }
}

Running Tests

powershell
# Run all backend tests
cd backend
dotnet test

# Run with verbose output
dotnet test --verbosity normal

# Run specific test class
dotnet test --filter "FullyQualifiedName~ErrorResponseFactoryTests"

# Run with coverage (requires coverlet)
dotnet test --collect:"XPlat Code Coverage"

Testable Units in This Project

Models (Pure, Easy to Test)
ClassWhat to Test
ErrorResponseFactoryStatus code mapping, dev vs prod mode, exception detail hiding
ChatRequestValidation logic if any
StreamChunkSerialization/deserialization
AnnotationInfoProperty mapping
Services (Require Integration Testing)
ClassTesting Approach
AgentFrameworkServiceUse validating-ui-features skill with Playwright for integration tests

Test Naming Convention

Use descriptive names following: MethodName_Scenario_ExpectedBehavior

csharp
[TestMethod]
public void CreateFromException_WhenDevelopmentMode_IncludesStackTrace() { }

[TestMethod]
public void CreateFromException_WhenProductionMode_HidesStackTrace() { }

Assertions Reference

MSTest provides these assertion methods:

csharp
// Equality
Assert.AreEqual(expected, actual);
Assert.AreNotEqual(notExpected, actual);

// Nullability
Assert.IsNull(value);
Assert.IsNotNull(value);

// Boolean
Assert.IsTrue(condition);
Assert.IsFalse(condition);

// Type
Assert.IsInstanceOfType(obj, typeof(ExpectedType));

// Collections
CollectionAssert.Contains(collection, element);
CollectionAssert.AreEqual(expected, actual);

// Exceptions
Assert.ThrowsException<InvalidOperationException>(() => MethodThatThrows());

When Unit Tests Aren't Enough

Use the validating-ui-features skill and Playwright when:

  • Testing requires a running backend server
  • Testing SSE streaming behavior
  • Testing authentication flows
  • Testing the full chat request/response cycle

Quick Reference

CommandPurpose
dotnet testRun all tests
dotnet test --filter "Name~Test"Run filtered tests
dotnet buildBuild without running
dotnet test --list-testsList all tests

© microsoft-foundry, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/skills/writing-unit-tests-csharp of microsoft-foundry/foundry-agent-webapp.

Open the folder on GitHubat commit f6cb362

Compare with similar skills

Writing Unit Tests Csharp next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Writing Unit Tests Csharp compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Writing Unit Tests Csharp this skillmicrosoft-foundry/foundry-agent-webapp127—~1kAutomated safety check: PassMIT
ScottPlot Test RunnerScottPlot/ScottPlot6.8k—~308Automated safety check: PassMIT
Verifyvaldisiljuconoks/LocalizationProvider180—~159Automated safety check: PassApache-2.0
Csharp Testingaffaan-m/ECC274k1 repos~2.2kAutomated safety check: PassMIT
Csharp Testingaffaan-m/ECC274k—~2kAutomated safety check: PassMIT
Csharp Testingaffaan-m/ECC274k—~2kAutomated safety check: PassMIT

Similar skills

  • ScottPlot Test Runner

    ScottPlot/ScottPlot

    Run or add ScottPlot 5 tests. Use for unit-test and cookbook-test work; unless explicitly asked otherwise, restrict manual test execution to the Unit Tests…

    6.8k GitHub stars~308 tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Verify

    valdisiljuconoks/LocalizationProvider

    Build the solution and run unit tests to verify changes are correct.

    180 GitHub stars~159 tokensUpdated 3 mo ago
    Testing & QAAuto-check passed
  • Csharp Testing

    affaan-m/ECC

    C and .NET testing patterns with xUnit, FluentAssertions, mocking, integration tests, and test organization best practices.

    274k GitHub starsUsed in 1 repo~2.2k tokens
    Testing & QAAuto-check passed
  • Csharp Testing

    affaan-m/ECC

    xUnit、FluentAssertions、モッキング、統合テスト、テスト組織のベストプラクティスを使用したCと.NETのテストパターン。

    274k GitHub stars~2k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Csharp Testing

    affaan-m/ECC

    使用 xUnit、FluentAssertions、模拟、集成测试和测试组织最佳实践的 C 和 .NET 测试模式. An agent skill from affaan-m/ECC.

    274k GitHub stars~2k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Csharp Tunit

    github/awesome-copilot

    Official

    Get best practices for TUnit unit testing, including data-driven tests

    40k GitHub starsUsed in 1 repo~1.3k tokens
    Testing & QAAuto-check passed

More from microsoft-foundry/foundry-agent-webapp

All 19 skills in this repo
  • Committing Code

    microsoft-foundry/foundry-agent-webapp

    Provides commit message format and workflow for this repository.

    127 GitHub stars~512 tokensUpdated 5 mo ago
    Auto-check passed
  • Implementing Chat Streaming

    microsoft-foundry/foundry-agent-webapp

    Provides SSE streaming patterns for the chat API and frontend.

    127 GitHub stars~1.9k tokensUpdated 5 mo ago
    Auto-check passed
  • Planning Features

    microsoft-foundry/foundry-agent-webapp

    Provides structured plan template for feature implementation.

    127 GitHub stars~548 tokensUpdated 5 mo ago
    Auto-check passed
  • Researching Azure AI SDK

    microsoft-foundry/foundry-agent-webapp

    Provides research patterns for Foundry Agent Service SDK. An agent skill from microsoft-foundry/foundry-agent-webapp.

    127 GitHub stars~4.7k tokensUpdated 5 mo ago
    Auto-check passed
  • Deploying To Azure

    microsoft-foundry/foundry-agent-webapp

    Provides deployment commands and troubleshooting for Azure Container Apps.

    127 GitHub stars~2.2k tokensUpdated 5 mo ago
    Auto-check: warnings
  • Syncing MCP Servers

    microsoft-foundry/foundry-agent-webapp

    Synchronize MCP server configuration between VS Code (.vscode/mcp.json) and Copilot CLI (~/.copilot/mcp-config.json).

    127 GitHub stars~1.3k tokensUpdated 5 mo ago
    Auto-check passed

Works with

Categories

Questions about Writing Unit Tests Csharp

What does Writing Unit Tests Csharp do?

Guidelines and patterns for writing unit tests in C using MSTest SDK. Writing Unit Tests Csharp is an agent skill from microsoft-foundry/foundry-agent-webapp. Guidelines and patterns for writing unit tests in C using MSTest SDK.

When should I use Writing Unit Tests Csharp?

Writing Unit Tests Csharp fits situations like: tasks that involve Unit testing.

How do I install Writing Unit Tests Csharp in Claude Code?

Run `npx skills add microsoft-foundry/foundry-agent-webapp --skill writing-unit-tests-csharp -a claude-code`. Or copy the skill folder (.github/skills/writing-unit-tests-csharp in microsoft-foundry/foundry-agent-webapp) into .claude/skills/writing-unit-tests-csharp in your project. Claude Code loads it when a task matches its description.

How do I install Writing Unit Tests Csharp in Codex?

Run `npx skills add microsoft-foundry/foundry-agent-webapp --skill writing-unit-tests-csharp -a codex`. Or copy the skill folder (.github/skills/writing-unit-tests-csharp in microsoft-foundry/foundry-agent-webapp) into .agents/skills/writing-unit-tests-csharp in your project. Codex loads it when a task matches its description.

Can I use Writing Unit Tests Csharp in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft-foundry/foundry-agent-webapp --skill writing-unit-tests-csharp -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/writing-unit-tests-csharp, .gemini/skills/writing-unit-tests-csharp, .github/skills/writing-unit-tests-csharp and .opencode/skills/writing-unit-tests-csharp in your project.

What does Writing Unit Tests Csharp need to run?

Going by SKILL.md and its folder, Writing Unit Tests Csharp needs the command-line tools its instructions call (dotnet).

Does Writing Unit Tests Csharp access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Writing Unit Tests Csharp safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Writing Unit Tests Csharp use?

Writing Unit Tests Csharp is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Writing Unit Tests Csharp use?

About 1k tokens (SKILL.md is roughly 4.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Writing Unit Tests Csharp?

Skills that share tags, products or a category with Writing Unit Tests Csharp: ScottPlot Test Runner (ScottPlot/ScottPlot, 6.8k stars), Verify (valdisiljuconoks/LocalizationProvider, 180 stars), Csharp Testing (affaan-m/ECC, 274k stars) and Csharp Testing (affaan-m/ECC, 274k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Writing Unit Tests Csharp?

microsoft-foundry (a GitHub organization) maintains it in microsoft-foundry/foundry-agent-webapp, which has 127 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on April 21, 2026.

Source: microsoft-foundry/foundry-agent-webapp on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.