dotnet-testing-datetime-testing-timeprovider
CommunityControl time in tests with TimeProvider.
Authorkevintsengtw
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Time-dependent code is hard to test because it relies on the system clock. This Skill provides a TimeProvider abstraction so time can be controlled in tests.
Core Features & Use Cases
- Time abstraction via TimeProvider and GetLocalNow/GetUtcNow to replace DateTime.Now/DateTime.UtcNow.
- FakeTimeProvider for precise control over time, time freezing, and time advancement in tests.
- Scenarios include business hours checks, expiry logic, caching, and scheduled tasks, all with deterministic tests.
Quick Start
Install Microsoft.Bcl.TimeProvider and Microsoft.Extensions.TimeProvider.Testing; inject TimeProvider.System in production and FakeTimeProvider in tests, then use SetLocalNow and Advance to simulate time.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: dotnet-testing-datetime-testing-timeprovider Download link: https://github.com/kevintsengtw/dotnet-testing-agent-skills/archive/main.zip#dotnet-testing-datetime-testing-timeprovider Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.