dotnet-testing-fluentvalidation-testing

dotnet-testing-fluentvalidation-testing is a skill for Claude Code, Codex from kevintsengtw/dotnet-testing-agent-skills. It costs 183 tokens per session (3,145 once invoked), scanned A, original, MIT.

A guide for testing FluentValidation validators, which are .NET components that check whether data follows rules before the application accepts it. It covers checking validation errors, messages, asynchronous rules, and rules involving multiple fields.

In plain words
What is it for?
Use it to write xUnit tests for validator classes, including valid and invalid inputs, expected error messages, asynchronous validation, and cross-field business rules.
Why use it?
It helps catch invalid business data and makes the rules clear through tests. It also provides a safety net when validation rules change.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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-fluentvalidation-testing
Any agent
npx skills add kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-fluentvalidation-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-fluentvalidation-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-fluentvalidation-testing.svg)](https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-fluentvalidation-testing)
Your own site
<a href="https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-fluentvalidation-testing"><img src="https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-fluentvalidation-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 183 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,145 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.1 $0.00183 $0.03145
Opus 5 $0.00092 $0.01572
Sonnet 5 $0.00037 $0.00629
Haiku 4.5 $0.00018 $0.00314

Measured 6d ago against content hash fa4457a4fb9b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

dotnet-testing-fluentvalidation-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 6d 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-fluentvalidation-testing/SKILL.md · 293 lines

How it starts

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

FluentValidation 驗證器測試指南

為什麼要測試驗證器?

驗證器是應用程式的第一道防線,測試驗證器能:

  1. 確保資料完整性 - 防止無效資料進入系統
  2. 業務規則文件化 - 測試即活文件,清楚展示業務規則
  3. 安全性保障 - 防止惡意或不當資料輸入
  4. 重構安全網 - 業務規則變更時提供保障
  5. 跨欄位邏輯驗證 - 確保複雜邏輯正確運作

前置需求

套件安裝

<PackageReference Include="FluentValidation" Version="12.1.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.4.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />

注意FluentValidation.TestHelper 命名空間(TestValidateShouldHaveValidationErrorFor 等 API)已包含在 FluentValidation 主套件中,不需要額外安裝獨立套件。只需 using FluentValidation.TestHelper; 即可使用。

FluentValidation 12.x 注意事項:FluentValidation 12.0 為主要版本升級,最低需求為 .NET 8。已移除的 API 包括 Transform/TransformForEach(改用 Must + 手動轉換)、InjectValidator(改用建構子注入 + SetValidator)、CascadeMode.StopOnFirstFailure(改用 RuleLevelCascadeMode = CascadeMode.Stop)。ShouldHaveAnyValidationError 已更名為 ShouldHaveValidationErrors。完整遷移指南請參閱 FluentValidation 12.0 Upgrade Guide

基本 using 指令

using FluentValidation;
using FluentValidation.TestHelper;
using Microsoft.Extensions.Time.Testing;
using NSubstitute;
using Xunit;
using AwesomeAssertions;

核心測試模式

本節涵蓋 7 種核心測試模式,每種模式包含驗證器定義與完整測試範例。

完整程式碼範例請參考 references/core-test-patterns.md

  • 模式 1:基本欄位驗證 — 使用 TestValidate + ShouldHaveValidationErrorFor / ShouldNotHaveValidationErrorFor 測試單一欄位規則
  • 模式 2:參數化測試 — 使用 [Theory] + [InlineData] 測試多種無效/有效輸入組合
  • 模式 3:跨欄位驗證 — 密碼確認、自訂 Must() 規則等多欄位關聯驗證
  • 模式 4:時間相依驗證 — 注入 TimeProvider,搭配 FakeTimeProvider 控制時間進行測試
  • 模式 5:條件式驗證 — 使用 .When() 的可選欄位驗證,測試條件觸發與跳過情境
  • 模式 6:非同步驗證MustAsync + TestValidateAsync,搭配 NSubstitute Mock 外部服務
  • 模式 7:集合驗證 — 驗證集合非空與元素有效性

快速範例:基本欄位驗證

public class UserValidatorTests
{
    private readonly UserValidator _validator = new();

    [Fact]
    public void Validate_空白使用者名稱_應該驗證失敗()
    {
        var result = _validator.TestValidate(
            new UserRegistrationRequest { Username = "" });

        result.ShouldHaveValidationErrorFor(x => x.Username)
              .WithErrorMessage("使用者名稱不可為 null 或空白");
    }
}

Read the full file on GitHub · 293 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 6d ago First seen · 293 lines · 183 tokens per session scan A fa4457a4fb9b

Subscribe to this mod's changes

dotnet-testing-fluentvalidation-testing is a skill published in the GitHub repository kevintsengtw/dotnet-testing-agent-skills (28 stars, last pushed 21d ago), licensed MIT. It adds 183 tokens to every session and 3,145 once invoked, about $0.0009 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

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

nunit-code-style

Use when writing or modifying C# method bodies, type declarations, or non-trivial logic in NUnit source. Covers NUnit's taste-and-judgment conventions — exception construction, simplification, naming intent, StringComparison, non-null check form, and var usage — that aren't already caught at build time.

nunit/nunit · 69 tokens