Unit testing a method that relies on DateTime.Now is generally a challenge. Take the below example, which was the first version of a method to get the Current Price of a Product. The business rule for GetCurrentPrice() is simple: find the most recent price where the effective date is not in the future.
For this scenario, imagine the user sets the Price of a product to $25,000 but that price doesn't take effect until the next year. Until that time, we must make sure that the system returns the previous (existing) price.
The poorly testable method
public decimal GetCurrentPrice()
var priceHistory = PriceHistories
.Where(ph.EffectiveDate.Date <= DateTime.Now.Date)
.OrderByDescending(ph => ph.EffectiveDate)
return (priceHistory != null) ? priceHistory.Price...