dotnet-testing-advanced-webapi-integration-testing

dotnet-testing-advanced-webapi-integration-testing is a skill for Claude Code, Codex from kevintsengtw/dotnet-testing-agent-skills. It costs 201 tokens per session (2,080 once invoked), scanned A, original, MIT.

Guidance for ASP.NET Core Web API integration tests, including HTTP endpoints and ProblemDetails, a standard format for describing API errors.

In plain words
What is it for?
Use it to test endpoints, exception handlers, validation errors, URL building, and multi-service setups such as PostgreSQL with Redis.
Why use it?
It helps verify both successful responses and consistent handling of validation and application failures across the full request pipeline.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-advanced-webapi-integration-testing
Any agent
npx skills add kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-advanced-webapi-integration-testing
Clone the repo
git clone --depth 1 https://github.com/kevintsengtw/dotnet-testing-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dotnet-testing-advanced-webapi-integration-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-advanced-webapi-integration-testing.svg)](https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-advanced-webapi-integration-testing)
Your own site
<a href="https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-advanced-webapi-integration-testing"><img src="https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-advanced-webapi-integration-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 201 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,080 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00201 $0.02080
Opus 5 $0.00101 $0.01040
Sonnet 5 $0.00040 $0.00416
Haiku 4.5 $0.00020 $0.00208

Measured 5d ago against content hash 3a1bcf6f2b90, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dotnet-testing-advanced-webapi-integration-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/dotnet-testing-advanced-webapi-integration-testing/SKILL.md · 171 lines

How it starts

The opening of the file, as written. The whole thing — 171 lines — stays where its author put it; the contents beside it link to each section on GitHub.

WebApi 整合測試

學習目標

完成本技能學習後,您將能夠:

  1. 建立完整的 WebApi 整合測試架構
  2. 使用 IExceptionHandler 實作現代化異常處理
  3. 驗證 ProblemDetailsValidationProblemDetails 標準格式
  4. 使用 Flurl 簡化 HTTP 測試的 URL 建構
  5. 使用 AwesomeAssertions 進行精確的 HTTP 回應驗證
  6. 建立多容器 (PostgreSQL + Redis) 測試環境

核心概念

IExceptionHandler - 現代化異常處理

ASP.NET Core 8+ 引入的 IExceptionHandler 介面提供了比傳統 middleware 更優雅的錯誤處理方式。GlobalExceptionHandler 依據例外類型(KeyNotFoundException → 404、ArgumentException → 400、其他 → 500)產生對應的 ProblemDetails 回應。

ProblemDetails 標準格式

RFC 7807 定義的統一錯誤回應格式:

欄位 說明
type 問題類型的 URI
title 簡短的錯誤描述
status HTTP 狀態碼
detail 詳細的錯誤說明
instance 發生問題的實例 URI

ValidationProblemDetails - 驗證錯誤專用

繼承自 ProblemDetails,額外包含 errors 字典,記錄每個欄位的驗證錯誤訊息。

FluentValidation 異常處理器

FluentValidation 異常處理器實作 IExceptionHandler 介面,專門處理 ValidationException,將驗證錯誤轉換為標準的 ValidationProblemDetails 格式回應。處理器之間按照註冊順序執行,特定處理器(如 FluentValidation)必須在全域處理器之前註冊。

完整實作程式碼請參閱 references/exception-handler-details.md

整合測試基礎設施

測試基礎設施由三個核心組件構成:

  • TestWebApplicationFactory:繼承 WebApplicationFactory<Program>,配置多容器(PostgreSQL + Redis)與 DI 替換(如 FakeTimeProvider)
  • IntegrationTestCollection:Collection Fixture 定義,確保容器共享
  • IntegrationTestBase:測試基底類別,提供 HttpClient、DatabaseManager、FlurlClient 與時間控制方法

完整基礎設施程式碼請參閱 references/test-infrastructure.md

Flurl 簡化 URL 建構

// 傳統方式
var url = $"/products?pageSize={pageSize}&page={page}&keyword={keyword}";

// 使用 Flurl
var url = "/products"
    .SetQueryParam("pageSize", 5)
    .SetQueryParam("page", 2)
    .SetQueryParam("keyword", "特殊");

測試範例

涵蓋成功建立產品(201 Created)、驗證錯誤(400 BadRequest + ValidationProblemDetails)、資源不存在(404 NotFound + ProblemDetails)、分頁查詢(200 OK + PagedResult)等完整測試範例,以及 TestHelpers 資料管理策略。

完整測試範例與資料管理程式碼請參閱 references/test-examples.md

Read the full file on GitHub · 171 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 171 lines · 201 tokens per session scan A 3a1bcf6f2b90

Subscribe to this mod's changes

dotnet-testing-advanced-webapi-integration-testing is a skill published in the GitHub repository kevintsengtw/dotnet-testing-agent-skills (28 stars, last pushed 20d ago), licensed MIT. It adds 201 tokens to every session and 2,080 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

clean-architecture-dotnet

Use when domain logic leaks into API/Infrastructure, project references violate layer boundaries, or you need to decide between CQS (always), CQRS bus (complex domains), and DDD patterns (invariants and events).

SebastienDegodez/copilot-instructions · 50 tokens

creating-dotnet-mcp-servers

Use when building Model Context Protocol (MCP) servers in .NET, configuring tools, transports (SSE/stdio), JSON serialization for AOT, or testing MCP endpoints.

SebastienDegodez/copilot-instructions · 43 tokens

dpg-migration

Migration logic for Azure SDK for .NET data-plane libraries migrating from AutoRest/Swagger to TypeSpec-based generation. Uses MCP tools from the generator-agent server for automated deterministic fixes.

Azure/azure-sdk-for-net · 41 tokens

mitigate-breaking-changes

Patterns and techniques for mitigating breaking changes in Azure management-plane SDKs. Covers SDK-side customizations (partial classes, CodeGenType, CodeGenSuppress) and TypeSpec decorator customizations (clientName, access, markAsPageable, alternateType, hierarchyBuilding).

Azure/azure-sdk-for-net · 60 tokens

generate-code-cs

Generate the code from typespec for C#. Parameter: C# SDK repository root location .

Azure/azure-sdk-for-net · 26 tokens

author-test

Generate a test given sample. Parameters: C# SDK repository root; Package name: one of Azure.AI.Projects, Azure.AI.Projects.Agents or Azure.AI.Extensions.OpenAI; the sample to use as a starting point for the test.

Azure/azure-sdk-for-net · 68 tokens