dotnet-testing-autofixture-basics

dotnet-testing-autofixture-basics is a skill for Claude Code, Codex from kevintsengtw/dotnet-testing-agent-skills. It costs 184 tokens per session (2,487 once invoked), scanned A, original, MIT.

A guide to AutoFixture, a .NET library that creates sample objects and values for tests automatically. It covers creating one object or collections, setting selected properties, and handling circular references.

In plain words
What is it for?
Use it to generate anonymous test data, create collections, customize selected values, omit properties, handle object graphs, and connect AutoFixture with xUnit.
Why use it?
It reduces repetitive code needed to prepare test data. Tests can focus on the behavior being checked instead of manually filling every field.

Skill for Claude CodeCodex

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

Good fit Use it to generate anonymous test data, create collections, customize selected values, omit properties, handle object graphs, and connect AutoFixture with xUnit.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-autofixture-basics
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.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-autofixture-basics.svg)](https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-autofixture-basics)
Your own site
<a href="https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-autofixture-basics"><img src="https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-autofixture-basics.svg" alt="Measured on agentmods" height="20"></a>
Per session 184 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,487 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00184 $0.02487
Opus 5 $0.00092 $0.01243
Sonnet 5 $0.00037 $0.00497
Haiku 4.5 $0.00018 $0.00249

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

Security

Grade A, and why

dotnet-testing-autofixture-basics 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 8d 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-autofixture-basics/SKILL.md · 184 lines

How it starts

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

AutoFixture 基礎:自動產生測試資料

安裝套件

<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.18.1" />

或透過命令列安裝:

dotnet add package AutoFixture
dotnet add package AutoFixture.Xunit2

核心 API 摘要

API 用途 預設行為
fixture.Create<T>() 產生單一物件 自動填充所有屬性
fixture.CreateMany<T>() 產生集合 預設 3 個元素
fixture.Build<T>() 精確控制屬性 搭配 With/Without
OmitAutoProperties() 只設定必要屬性 其餘保持預設值

基本使用

Fixture 是核心類別,提供自動產生測試資料的能力:

  • 基本型別int(隨機正整數)、string(GUID 格式)、decimalboolDateTimeGuid
  • 複雜物件:自動建構巢狀物件與集合屬性,所有層級的屬性都會自動填入值
  • 集合產生CreateMany<T>() 預設產生 3 個元素,可指定數量如 CreateMany<T>(10)

完整程式碼範例請參考 references/basic-usage-examples.md

Build() 精確控制

當需要對特定屬性進行控制時,使用 Build<T>() 模式:

方法 用途 範例
.With(prop, value) 指定固定值 .With(x => x.Name, "測試客戶")
.With(prop, factory) 使用工廠方法產生值 .With(x => x.Price, () => random.Next())
.Without(prop) 排除屬性,保持預設值 .Without(x => x.InternalId)
.OmitAutoProperties() 不自動設定任何屬性 只設定關心的屬性

循環參考處理

當物件包含循環參考時(如 Category 的 Parent 屬性指向自己),AutoFixture 預設會拋出 ObjectCreationException

解決方案: 使用 OmitOnRecursionBehavior,移除預設的 ThrowingRecursionBehavior 並加入忽略循環參考的行為。

建議: 建立 AutoFixtureTestBase 基底類別統一處理循環參考,避免在每個測試中重複設定。

完整程式碼範例請參考 references/build-and-customization.md

Read the full file on GitHub · 184 lines

Files

What ships with it

7 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. 8d ago First seen · 184 lines · 184 tokens per session scan A c0004ad2da2f

Subscribe to this mod's changes

dotnet-testing-autofixture-basics is a skill published in the GitHub repository kevintsengtw/dotnet-testing-agent-skills (28 stars, last pushed 22d ago), licensed MIT. It adds 184 tokens to every session and 2,487 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

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

migrate-xunit-to-xunit-v3

Migrate .NET test projects from xUnit.net v2 to xunit.v3 and fix v3 breaks. Use for package/CPM conversion, OutputType=Exe, preserving the VSTest or MTP runner (including projects currently using YTest.MTP.XUnit2), incompatible TFMs, async void tests, string-to-Type attributes, custom Fact/Theory/BeforeAfterTest…

managedcode/dotnet-skills · 149 tokens

csharp-xunit

Your goal is to help me write effective unit tests with XUnit, covering both standard and data-driven testing approaches.

PracticalSwan/agent-skills · 25 tokens

cratis-specs-csharp

Step-by-step guidance for writing C# specs in Cratis with BDD Specification by Example — the Establish/Because/should pattern, for/when/and folder hierarchy, reusable given/ contexts, NSubstitute mocking, and the in-process scenario family. Use when writing C# unit or integration specs or structuring the for/when/and…

Cratis/AI · 101 tokens

.NET Patterns

Use this skill when working in .NET projects (C#) and you want clean layering, safe async usage, and maintainable dependency injection patterns.

AmariahAK/atlarix-skills · 2 tokens

csharp-tunit

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

MarieLynneBlock/arcanum-artifex · 18 tokens