When we develop / QA, we often have to pretend that the current date / time is something different than now. For us, a fairly ordinary logic based on a date.
A simple example: let's say that the product in the store is available from December 15, 2010 to January 3, 2011. These two dates will be stored in the database, and the code will compare it with DateTime.Now. This obviously needs to be [unit] checked in some way. The question is how?
So far, we just added a custom object Dateand tried to force use Date.Nowinstead DateTime.Now, which does not cover any third-party code that can rely on the current date, and also feels too weak.
I wonder if there is a more kosher way to handle date overrides without changing the system date in Windows.
source
share