dotnet-testing-datetime-testing-timeprovider
Installation
SKILL.md
DateTime 與時間相依性測試指南
核心原則
原則一:時間抽象化 - 以 TimeProvider 取代 DateTime
傳統問題程式碼:
// ❌ 無法測試 - 直接使用靜態時間
public class OrderService
{
public bool CanPlaceOrder()
{
var now = DateTime.Now;
return now.Hour >= 9 && now.Hour < 17;
}
}
Related skills