title: Unit testing code that does date processing based on today's date
body: <p>When code processes dates based on the current date, testing should cover edge cases such as leap years as well as the more frequent month and year boundaries.</p>
  
  <p>In our code we always get the current date deep down in our classes using <code>DateTime.Now</code> (.NET, in our case).</p>
  
  <p>How can you unit test such code?</p>
  
  <p>Is this where <a href="http://martinfowler.com/articles/injection.html" rel="noreferrer">Dependency Injection</a> becomes very useful?</p>
  
  <h2>Edit</h2>
  
  <p>This is a slight aside, but apparently the next version of Typemock will allow faking of <code>DateTime.Now</code></p>
  
  <p><a href="https://blog.typemock.com/2009/05/mockingfaking-datetimenow-in-unit-tests.html" rel="noreferrer">https://blog.typemock.com/2009/05/mockingfaking-datetimenow-in-unit-tests.html</a></p>