Reflecting on the need for Abstracting DateTime.Now

Unit Testing Newbie When I first started taking unit testing more seriously (it was 13+ years ago, don’t fight me!) I didn’t understand how to test something when I was using DateTime.UtcNow. My tests worked then failed a while later. I asked, on reflection, an embarrassing question on Stack Overflow. What made it embarrassing was that it showed my lack of understanding of non-deterministic values and testing code that used them....

January 24, 2025 · 3 min · 508 words · Dave Hogan