dotnet-testing-datetime-testing-timeprovider
✓使用 TimeProvider 測試時間相依邏輯的專門技能。 當需要測試 DateTime、控制時間流逝、處理時區轉換、測試過期邏輯時使用。 涵蓋 TimeProvider 抽象化、FakeTimeProvider 時間控制、時間凍結與快轉等。
Installation
SKILL.md
本技能指導如何使用 Microsoft.Bcl.TimeProvider 解決時間相依程式碼的測試問題。透過時間抽象化,讓「現在時間」變得可控制、可預測、可重現。
| SetUtcNow(DateTimeOffset) | 設定 UTC 時間 | 需要精確 UTC 時間時 | | SetLocalTimeZone(TimeZoneInfo) | 設定本地時區 | 測試時區相關邏輯 | | Advance(TimeSpan) | 時間快轉 | 測試過期、延遲邏輯 | | GetUtcNow() | 取得 UTC 時間 | 讀取當前模擬時間 | | GetLocalNow() | 取得本地時間 | 讀取本地模擬時間 |
關鍵:必須使用 [Frozen(Matching.DirectBaseType)],否則 AutoFixture 無法正確將 FakeTimeProvider 注入到需要 TimeProvider 的建構式中。
使用 TimeProvider 測試時間相依邏輯的專門技能。 當需要測試 DateTime、控制時間流逝、處理時區轉換、測試過期邏輯時使用。 涵蓋 TimeProvider 抽象化、FakeTimeProvider 時間控制、時間凍結與快轉等。 Source: kevintsengtw/dotnet-testing-agent-skills.
Facts (cite-ready)
Stable fields and commands for AI/search citations.
- Install command
npx skills add https://github.com/kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-datetime-testing-timeprovider- Category
- </>Dev Tools
- Verified
- ✓
- First Seen
- 2026-02-01
- Updated
- 2026-02-18
Quick answers
What is dotnet-testing-datetime-testing-timeprovider?
使用 TimeProvider 測試時間相依邏輯的專門技能。 當需要測試 DateTime、控制時間流逝、處理時區轉換、測試過期邏輯時使用。 涵蓋 TimeProvider 抽象化、FakeTimeProvider 時間控制、時間凍結與快轉等。 Source: kevintsengtw/dotnet-testing-agent-skills.
How do I install dotnet-testing-datetime-testing-timeprovider?
Open your terminal or command line tool (Terminal, iTerm, Windows Terminal, etc.) Copy and run this command: npx skills add https://github.com/kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-datetime-testing-timeprovider Once installed, the skill will be automatically configured in your AI coding environment and ready to use in Claude Code or Cursor
Where is the source repository?
https://github.com/kevintsengtw/dotnet-testing-agent-skills
Details
- Category
- </>Dev Tools
- Source
- skills.sh
- First Seen
- 2026-02-01