Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api-gen/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@
"line": "v4",
"targetFramework": "net452",
"assemblyName": "AutoFixture.AutoRhinoMock"
},
{
"id": "tunit",
"name": "AutoFixture.TUnit",
"nugetId": "AutoFixture.TUnit",
"version": "0.1.0-preview0001",
"line": "v4",
"targetFramework": "net8.0"
}
]
}
147 changes: 74 additions & 73 deletions api-gen/readme.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
# API markdown generator

Uses DocFX `metadata` with `outputFormat: markdown` against NuGet package assemblies. All automation is Node.js (`api-gen/run.mjs`).

## Prerequisites

- [.NET SDK](https://dotnet.microsoft.com/download) (for DocFX)
- [DocFX](https://dotnet.github.io/docfx/): `dotnet tool install -g docfx`
- Node.js
- [just](https://github.com/casey/just#installation) (optional wrapper)

On **Linux/WSL**, dotnet global tools are not always on `PATH`. Add this to `~/.bashrc`:

```bash
export PATH="$PATH:$HOME/.dotnet/tools"
```

Then verify: `docfx --version`

## Commands (from repo root)

```bash
node api-gen/run.mjs prepare # generate + sync into site/public/
just prepare-api # same via just
just clean-api # delete generated output and NuGet cache
```

Output layout after sync:

| Path | Contents |
|------|----------|
| `site/public/api-markdown/{packageId}/{version}/` | Raw DocFX markdown (`.md`) |
| `site/public/api-meta/{packageId}/{version}/` | `toc.json`, `search.json`, `pages/{slug}.json` |
| `site/public/api-meta/routes.json` | All API routes for prerender |
| `site/public/api-catalog.json` | Package/version picker data |

Configure packages in `api-gen/packages.json`. Each entry is one package version (same `id` groups versions in the UI). Generated routes use `/api/{packageId}/{versionSegment}/...`.

Packages are downloaded from nuget.org into `api-gen/packages-cache/` and DocFX reads the `.dll` plus companion `.xml` documentation file from the chosen target framework folder.

Required fields per package:

| Field | Purpose |
|-------|---------|
| `id` | URL slug |
| `name` | Display name |
| `nugetId` | NuGet package id (defaults to `name`) |
| `version` | Pinned NuGet version |
| `line` | UI grouping (`v4` / `v5`) |
| `targetFramework` | TFM folder under `lib/` (for example `netstandard2.0`, `net8.0`, `net452`) |
| `assemblyName` | Optional when the DLL name differs from the NuGet id |

Currently generated packages (URL slug → NuGet name):

| Slug | NuGet package | v5 | v4 |
|------|---------------|----|----|
| `autofixture` | AutoFixture | yes | yes |
| `xunit3` | AutoFixture.Xunit3 | yes | — |
| `nunit4` | AutoFixture.NUnit4 | yes | — |
| `xunit` | AutoFixture.xUnit | — | yes |
| `xunit2` | AutoFixture.xUnit2 | — | yes |
| `nunit2` | AutoFixture.NUnit2 | — | yes |
| `nunit3` | AutoFixture.NUnit3 | — | yes |
| `automoq` | AutoFixture.AutoMoq | yes | yes |
| `autonsubstitute` | AutoFixture.AutoNSubstitute | yes | yes |
| `autofakeiteasy` | AutoFixture.AutoFakeItEasy | yes | yes |
| `seedextensions` | AutoFixture.SeedExtensions | yes | yes |
| `idioms` | AutoFixture.Idioms | yes | yes |
| `idioms-fscheck` | AutoFixture.Idioms.FsCheck | — | yes |
| `autofoq` | AutoFixture.AutoFoq | — | yes |
| `autorhinomocks` | AutoFixture.AutoRhinoMocks | — | yes |

v5 is pinned to `5.0.0-rc.1`; v4 is pinned to `4.18.1`.
# API markdown generator

Uses DocFX `metadata` with `outputFormat: markdown` against NuGet package assemblies. All automation is Node.js (`api-gen/run.mjs`).

## Prerequisites

- [.NET SDK](https://dotnet.microsoft.com/download) (for DocFX)
- [DocFX](https://dotnet.github.io/docfx/): `dotnet tool install -g docfx`
- Node.js
- [just](https://github.com/casey/just#installation) (optional wrapper)

On **Linux/WSL**, dotnet global tools are not always on `PATH`. Add this to `~/.bashrc`:

```bash
export PATH="$PATH:$HOME/.dotnet/tools"
```

Then verify: `docfx --version`

## Commands (from repo root)

```bash
node api-gen/run.mjs prepare # generate + sync into site/public/
just prepare-api # same via just
just clean-api # delete generated output and NuGet cache
```

Output layout after sync:

| Path | Contents |
|------|----------|
| `site/public/api-markdown/{packageId}/{version}/` | Raw DocFX markdown (`.md`) |
| `site/public/api-meta/{packageId}/{version}/` | `toc.json`, `search.json`, `pages/{slug}.json` |
| `site/public/api-meta/routes.json` | All API routes for prerender |
| `site/public/api-catalog.json` | Package/version picker data |

Configure packages in `api-gen/packages.json`. Each entry is one package version (same `id` groups versions in the UI). Generated routes use `/api/{packageId}/{versionSegment}/...`.

Packages are downloaded from nuget.org into `api-gen/packages-cache/` and DocFX reads the `.dll` plus companion `.xml` documentation file from the chosen target framework folder.

Required fields per package:

| Field | Purpose |
|-------|---------|
| `id` | URL slug |
| `name` | Display name |
| `nugetId` | NuGet package id (defaults to `name`) |
| `version` | Pinned NuGet version |
| `line` | UI grouping (`v4` / `v5`) |
| `targetFramework` | TFM folder under `lib/` (for example `netstandard2.0`, `net8.0`, `net452`) |
| `assemblyName` | Optional when the DLL name differs from the NuGet id |

Currently generated packages (URL slug → NuGet name):

| Slug | NuGet package | v5 | v4 |
|------|---------------|----|----|
| `autofixture` | AutoFixture | yes | yes |
| `xunit3` | AutoFixture.Xunit3 | yes | — |
| `nunit4` | AutoFixture.NUnit4 | yes | — |
| `xunit` | AutoFixture.xUnit | — | yes |
| `xunit2` | AutoFixture.xUnit2 | — | yes |
| `nunit2` | AutoFixture.NUnit2 | — | yes |
| `nunit3` | AutoFixture.NUnit3 | — | yes |
| `automoq` | AutoFixture.AutoMoq | yes | yes |
| `autonsubstitute` | AutoFixture.AutoNSubstitute | yes | yes |
| `autofakeiteasy` | AutoFixture.AutoFakeItEasy | yes | yes |
| `seedextensions` | AutoFixture.SeedExtensions | yes | yes |
| `idioms` | AutoFixture.Idioms | yes | yes |
| `idioms-fscheck` | AutoFixture.Idioms.FsCheck | — | yes |
| `autofoq` | AutoFixture.AutoFoq | — | yes |
| `autorhinomocks` | AutoFixture.AutoRhinoMocks | — | yes |
| `tunit` | AutoFixture.TUnit | — | yes (`0.1.0-preview0001`) |

v5 is pinned to `5.0.0-rc.1`; v4 is pinned to `4.18.1` (except AutoFixture.TUnit, which is on its own preview version).
11 changes: 6 additions & 5 deletions site/app/app.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<script setup lang="ts">
import type { ContentNavigationItem } from '@nuxt/content'
import type { NavigationMenuItem } from '@nuxt/ui'
import { mapDocsNavigationBadges } from '~/utils/docsNavigationBadge'

const route = useRoute()

const { data: docsNavigationRaw } = await useAsyncData('docs-navigation', () =>
queryCollectionNavigation('docs'),
queryCollectionNavigation('docs', ['badge']),
)

/** Collection root ("Docs") is not useful in the sidebar — expose its children as top level. */
const docsNavigation = computed(() => {
const items = docsNavigationRaw.value ?? []
if (items.length === 1 && items[0]?.children?.length) {
return items[0].children
}
return items
const topLevel = items.length === 1 && items[0]?.children?.length
? items[0].children
: items
return mapDocsNavigationBadges(topLevel)
})

provide('docsNavigation', docsNavigation)
Expand Down
66 changes: 66 additions & 0 deletions site/app/utils/docsNavigationBadge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import type { ContentNavigationItem } from '@nuxt/content'
import type { BadgeProps } from '@nuxt/ui'

/** Known string shortcuts → consistent Nuxt UI badge styles. */
const BADGE_PRESETS: Record<string, BadgeProps> = {
new: { label: 'New', color: 'primary', variant: 'subtle' },
updated: { label: 'Updated', color: 'info', variant: 'subtle' },
preview: { label: 'Preview', color: 'warning', variant: 'subtle' },
}

function isBadgeObject(value: unknown): value is BadgeProps {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}

/**
* Normalize a docs frontmatter `badge` value for UContentNavigation.
* Strings use presets when known; other strings become a neutral outline badge.
* Objects are passed through as BadgeProps.
*/
export function resolveDocsNavigationBadge(badge: unknown): BadgeProps | undefined {
if (badge === undefined || badge === null || badge === false) {
return undefined
}

if (typeof badge === 'string' || typeof badge === 'number') {
const key = String(badge).trim().toLowerCase()
if (!key) {
return undefined
}

return BADGE_PRESETS[key] ?? {
label: String(badge).trim(),
color: 'neutral',
variant: 'outline',
}
}

if (isBadgeObject(badge)) {
return badge
}

return undefined
}

/** Recursively attach resolved badges onto a Content navigation tree. */
export function mapDocsNavigationBadges(
items: ContentNavigationItem[] | undefined,
): ContentNavigationItem[] {
if (!items?.length) {
return []
}

return items.map((item) => {
const badge = resolveDocsNavigationBadge(
(item as ContentNavigationItem & { badge?: unknown }).badge,
)

return {
...item,
...(badge !== undefined ? { badge } : {}),
children: item.children?.length
? mapDocsNavigationBadges(item.children)
: item.children,
}
})
}
9 changes: 9 additions & 0 deletions site/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { defineCollection, defineContentConfig, z } from '@nuxt/content'

const badgeObjectSchema = z.object({
label: z.union([z.string(), z.number()]).optional(),
color: z.string().optional(),
variant: z.string().optional(),
size: z.string().optional(),
})

export default defineContentConfig({
collections: {
docs: defineCollection({
Expand All @@ -10,6 +17,8 @@ export default defineContentConfig({
},
schema: z.object({
description: z.string().optional(),
/** Sidebar badge — string shortcut (`New`, `Updated`, `Preview`) or Nuxt UI BadgeProps. */
badge: z.union([z.string(), z.number(), badgeObjectSchema]).optional(),
}),
}),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Overview
description: Third-party test frameworks and libraries that AutoFixture integrates with on v5.
description: Third-party test frameworks and libraries that AutoFixture integrates with.
---

AutoFixture ships extension packages that connect to tools you already use in .NET test projects. Each guide below covers the third-party library, what AutoFixture adds, and how to install both sides.
Expand All @@ -9,10 +9,11 @@ Pick the test framework you use, then add a mocking library if your tests need s

## Test frameworks

These libraries run your tests. AutoFixture extensions add `[AutoData]`, `[InlineAutoData]`, and related attributes so method parameters become anonymous specimens.
These libraries run your tests. AutoFixture extensions add data attributes so method parameters become anonymous specimens (`[AutoData]` / `[InlineAutoData]` on xUnit and NUnit; `[AutoDataSource]` / `[AutoArguments]` on TUnit).

- [xUnit.net 3](/docs/integrations/xunit3)
- [NUnit 4](/docs/integrations/nunit4)
- [xUnit.net 3](/docs/integrations/xunit3) — AutoFixture 5
- [NUnit 4](/docs/integrations/nunit4) — AutoFixture 5
- [TUnit](/docs/integrations/tunit) — AutoFixture 4 (preview)

## Mocking libraries

Expand All @@ -26,6 +27,7 @@ These libraries create test doubles. AutoFixture extensions register them as res

- [Custom AutoData attribute](/docs/integrations/xunit3#custom-autodata-attribute) — share fixture setup (for example AutoMoq) across xUnit.net 3 theories
- [NUnit 4 custom attributes](/docs/integrations/nunit4#custom-autodata-attribute) — the same pattern for NUnit 4 tests
- [TUnit custom AutoDataSource](/docs/integrations/tunit#custom-autodatasource-attribute) — the same pattern for TUnit tests
- [AutoFixture integration packages](/docs/reference/packages) — NuGet packages that wrap the libraries above
- [v4 to v5 migration](/docs/reference/v4-to-v5-migration) — map older xUnit.net and NUnit integration packages to v5
- [FAQ](/docs/reference/faq) — interfaces, Freeze, AutoData, and other common failures
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: xUnit.net 3
description: Use AutoData, InlineAutoData, and parameter attributes with xUnit.net 3 test projects.
---

`[AutoData]` turns test method parameters into anonymous specimens so you skip manual arrange setup.
[xUnit.net](https://xunit.net/) is a popular .NET unit testing framework. Theories and facts take parameters; you normally supply those values yourself (or with `[InlineData]` / `[MemberData]`).

**AutoFixture.Xunit3** connects AutoFixture to xUnit.net 3. Attributes such as `[AutoData]` and `[InlineAutoData]` fill theory parameters with anonymous specimens so you skip most of the arrange setup.

## Prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: AutoMoq
description: Moq integration — let AutoFixture create Moq mocks for interfaces and abstract types automatically.
---

AutoMoq turns interface and abstract dependencies into Moq mocks when AutoFixture builds object graphs.
[Moq](https://github.com/moq/moq) is a .NET mocking library. You create `Mock<T>` instances for interfaces and abstract types, then set up return values and verify calls.

**AutoFixture.AutoMoq** plugs Moq into AutoFixture. When AutoFixture builds an object graph and needs an interface or abstract dependency, AutoMoq supplies a Moq mock instead of failing — so you can `Freeze` mocks and assert on them with less manual setup.

## Prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: NUnit 4
description: Use AutoData, InlineAutoData, and parameter attributes with NUnit 4 test projects.
---

`[AutoData]` turns test method parameters into anonymous specimens so you skip manual arrange setup. Works like [xUnit.net 3](/docs/integrations/xunit3), but uses NUnit's `[Test]` attribute.
[NUnit](https://nunit.org/) is a long-standing .NET unit testing framework. Tests can take parameters; you normally supply those values yourself (or with `[TestCase]` / `[TestCaseSource]`).

**AutoFixture.NUnit4** connects AutoFixture to NUnit 4. Attributes such as `[AutoData]` and `[InlineAutoData]` fill test parameters with anonymous specimens so you skip most of the arrange setup. The pattern matches [xUnit.net 3](/docs/integrations/xunit3), but uses NUnit's `[Test]` attribute.

## Prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: AutoNSubstitute
description: NSubstitute integration — create substitutes automatically with AutoNSubstituteCustomization.
---

AutoNSubstitute turns interface and abstract dependencies into NSubstitute substitutes when AutoFixture builds object graphs.
[NSubstitute](https://nsubstitute.github.io/) is a .NET mocking library with a substitute-focused API. You create substitutes for interfaces and abstract types, then configure returns and assert received calls.

**AutoFixture.AutoNSubstitute** plugs NSubstitute into AutoFixture. When AutoFixture builds an object graph and needs an interface or abstract dependency, AutoNSubstitute supplies a substitute instead of failing — so collaborators resolve automatically and you can assert on them with less manual setup.

## Prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: AutoFakeItEasy
description: FakeItEasy integration — use fakes with AutoFixture.AutoFakeItEasy on v5.
---

AutoFakeItEasy turns interface and abstract dependencies into FakeItEasy fakes when AutoFixture builds object graphs.
[FakeItEasy](https://fakeiteasy.github.io/) is a .NET mocking library. You create fakes for interfaces and abstract types, then configure behavior and assert calls.

**AutoFixture.AutoFakeItEasy** plugs FakeItEasy into AutoFixture. When AutoFixture builds an object graph and needs an interface or abstract dependency, AutoFakeItEasy supplies a fake instead of failing — so collaborators resolve automatically and you can assert on them with less manual setup.

## Prerequisites

Expand Down
Loading