Seed extensions
The AutoFixture.SeedExtensions package adds seed-aware Create, CreateMany, and Freeze overloads. Seeds are generic (Create<T>(T seed)), not string-only — string seeds are the most common case because AutoFixture turns them into readable prefixes by default.
Prerequisites
- .NET 8+ test project
- AutoFixture 5.0.0-rc.1
Install
<PackageReference Include="AutoFixture.SeedExtensions" Version="5.0.0-rc.1" />
Example scenario
You are testing code that displays generated labels. Random strings are hard to read in failure output — you want values that start with a known prefix but stay anonymous. Or you customize numeric creation with FromSeed and need to pass an explicit seed into Create.
Create with a seed
var fixture = new Fixture();
var result = fixture.Create("SeedPrefix");
Assert.StartsWith("SeedPrefix", result);
CreateMany with a seed
Without a count, AutoFixture uses RepeatCount:
var results = fixture.CreateMany("Item").ToList();
Assert.Equal(fixture.RepeatCount, results.Count);
Assert.All(results, item => Assert.StartsWith("Item", item));
Pass an explicit count when you need a fixed length:
var results = fixture.CreateMany("Item", 3).ToList();
Assert.Equal(3, results.Count);
Assert.All(results, item => Assert.StartsWith("Item", item));
Freeze with a seed
Freeze(seed) creates a seeded value and freezes it so later requests for that type reuse the same instance:
var frozen = fixture.Freeze("Frozen");
var again = fixture.Create("Something else");
Assert.Equal(frozen, again);
The seed shapes the first value. After that, Freeze pins that instance — a different seed on a later Create does not create a new string. To inject a known value without seeding, use Inject instead.
Seeds beyond strings
With Customizations FromSeed, an explicit seed drives non-string types too:
fixture.Customize<int>(composer => composer.FromSeed(seed => seed * 10));
var value = fixture.Create(5);
Assert.Equal(50, value);
Bare Create<int>() still uses default(int) as the seed (0). Seeded overloads only matter when generators honor the seed — by default that is mainly strings; for other types you customize with FromSeed.
How it works
Create(seed)— one specimen, potentially influenced by the seedCreateMany(seed)— seeded sequence of lengthRepeatCountCreateMany(seed, count)— seeded sequence of fixed lengthFreeze(seed)— create from seed, then reuse that instance- Seeds are
Tvalues; string seeds become readable prefixes by default
See also Customizations for FromSeed and Register, Freeze, and Inject for unseeded Freeze/Inject.