Skip to content

feat: Add Fake Time Provider extension generator - #478

Merged
Keboo merged 1 commit into
masterfrom
time-provider
May 28, 2026
Merged

Keboo merged 1 commit into
masterfrom
time-provider

Conversation

@Keboo

@Keboo Keboo commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Introduces a source generator that creates a WithFakeTimeProvider() extension method for AutoMocker.

This streamlines deterministic testing of time-sensitive components by automatically registering FakeTimeProvider from Microsoft.Extensions.TimeProvider.Testing. It registers the fake provider as both TimeProvider (for injection) and FakeTimeProvider (for test control).

Includes new documentation and example tests across various test frameworks.

@Keboo
Keboo enabled auto-merge (squash) May 28, 2026 21:01
Introduces a source generator that creates a `WithFakeTimeProvider()` extension method for `AutoMocker`.

This streamlines deterministic testing of time-sensitive components by automatically registering `FakeTimeProvider` from `Microsoft.Extensions.TimeProvider.Testing`. It registers the fake provider as both `TimeProvider` (for injection) and `FakeTimeProvider` (for test control).

Includes new documentation and example tests across various test frameworks.
@Keboo
Keboo merged commit 9b43cd5 into master May 28, 2026
3 checks passed
@Keboo
Keboo deleted the time-provider branch May 28, 2026 21:18
github-actions Bot pushed a commit to BenjaminMichaelis/DotnetTemplates that referenced this pull request Sep 17, 2026
Updated [Moq.AutoMock](https://github.com/moq/Moq.AutoMocker) from 4.0.2
to 4.0.3.

<details>
<summary>Release notes</summary>

_Sourced from [Moq.AutoMock's
releases](https://github.com/moq/Moq.AutoMocker/releases)._

## 4.0.3

## What's Changed
* Upgrade core dependencies and align with Roslyn API changes by @​Keboo
in moq/Moq.AutoMocker#477
* feat: Add Fake Time Provider extension generator by @​Keboo in
moq/Moq.AutoMocker#478
* Automate analyzer release doc promotion by @​Keboo in
moq/Moq.AutoMocker#479
* Correct `AutoMocker.Use` instance check to use reference equality by
@​Keboo in moq/Moq.AutoMocker#503


**Full Changelog**:
moq/Moq.AutoMocker@v4.0.2...v4.0.3

Commits viewable in [compare
view](moq/Moq.AutoMocker@v4.0.2...v4.0.3).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Moq.AutoMock&package-manager=nuget&previous-version=4.0.2&new-version=4.0.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant