<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Testing on Dave Hogan</title>
    <link>https://davehogan.co.uk/tags/testing/</link>
    <description>Recent content in Testing on Dave Hogan</description>
    <generator>Hugo -- 0.155.2</generator>
    <language>en-gb</language>
    <lastBuildDate>Fri, 24 Jan 2025 20:55:21 +0100</lastBuildDate>
    <atom:link href="https://davehogan.co.uk/tags/testing/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Reflecting on the need for Abstracting DateTime.Now</title>
      <link>https://davehogan.co.uk/posts/development/reflecting-on-the-need-for-abstracting-datetime-now/</link>
      <pubDate>Fri, 24 Jan 2025 20:55:21 +0100</pubDate>
      <guid>https://davehogan.co.uk/posts/development/reflecting-on-the-need-for-abstracting-datetime-now/</guid>
      <description>&lt;h2 id=&#34;unit-testing-newbie&#34;&gt;Unit Testing Newbie&lt;/h2&gt;
&lt;p&gt;When I first started taking unit testing more seriously (it was 13+ years ago, don&amp;rsquo;t fight me!) I didn&amp;rsquo;t understand how to test something when I was using &lt;code&gt;DateTime.UtcNow&lt;/code&gt;. My tests worked then failed a while later.&lt;/p&gt;
&lt;p&gt;I asked, on reflection, an embarrassing question on &lt;a href=&#34;https://stackoverflow.com/questions/7661953/how-to-write-unit-test-for-time-sensitive-constant&#34;&gt;Stack Overflow&lt;/a&gt;. What made it embarrassing was that it showed my lack of understanding of non-deterministic values and testing code that used them. As I mentioned in this case it was usage of &lt;code&gt;DateTime&lt;/code&gt; in &lt;code&gt;C#&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
