---
title: Register, Freeze, and Inject
description: Three ways to supply known instances or factories to a fixture.
---

Use **Inject** when you already have the object. Use **Freeze** when AutoFixture should create it once and reuse it. Use **Register** when you control how each request is built.

## Example scenario

You are testing code that resolves the same `ClientDto` from multiple places in an object graph. You need one shared instance — or a factory that always returns a known string.

## Example

**Register** — factory for a type:

```csharp
var fixture = new Fixture();
fixture.Register(() => "registered");

Assert.Equal("registered", fixture.Create<string>());
```

**Freeze** — one shared instance:

```csharp
var frozen = fixture.Freeze<ClientDto>();

var resolved = fixture.Create<ClientDto>();

Assert.Same(frozen, resolved);
```

**Inject** — exact instance:

```csharp
var injected = new ClientDto { Name = "injected", Age = 1 };
fixture.Inject(injected);

Assert.Same(injected, fixture.Create<ClientDto>());
```

## How it works

- `Register<T>(Func<T>)` — replaces how `T` is created on every request
- `Freeze<T>()` — creates `T` once, then injects that instance so later requests on this fixture reuse it
- `Inject<T>(T)` — supplies a specific instance for all later requests of that type on this fixture

See [Customizations](/docs/fundamentals/customizations).

## Next steps

- [Customizations](/docs/fundamentals/customizations)
- [AutoMoq](/docs/integrations/automoq)
- [AutoNSubstitute](/docs/integrations/autonsubstitute)
- [AutoFakeItEasy](/docs/integrations/autofakeiteasy)
- [FAQ](/docs/reference/faq)
