Skip to content
Matt Hidinger

Blog

Page 11 of 16 · Browse by topic

DateTime.Now is not [deterministically] testable

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.

3 min read

Have you tried Google to find that?

Researching strategies for unit testing view model mappers… It never occurred to try google.com to find that information…

1 min read

Rename namespaces intelligently with ReSharper

As is usually the case when I encounter a pain point while developing with Visual Studio, a quick google search reminds me that all along this problem has been solved for me. Today’s lesson is brought to you by the all-to-common namespace renaming. Earlier today I started cleaning up the file structure in the Solution Explorer, and up until now I would resort to a clumsy Solution Wide Find-Replace to fix up the namespaces after the files were moved into their more logical placement.

1 min read