{"id":8297,"date":"2020-06-25T21:25:26","date_gmt":"2020-06-25T21:25:26","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8297"},"modified":"2020-06-25T21:27:03","modified_gmt":"2020-06-25T21:27:03","slug":"tests-are-failing-with-datetime-formatting","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/tests-are-failing-with-datetime-formatting\/","title":{"rendered":"Tests are failing with DateTime expected format"},"content":{"rendered":"<p>I&#8217;m creating some builds on appveyor for some of my GitHub projects and hit a small snag. All of the DateTime&#8217;s in my tests have test data in the en-GB format, i.e. dd\/MM\/yyyy.<\/p>\n<p><em>Note: Whilst I haven&#8217;t checked, I suspect appveyor is hosted on en-US machines.<\/em><\/p>\n<p>A simple way to resolve this is, just add a NUnit SetUp that converts the current culture to the expected culture, i.e.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nSetUp]\r\npublic void SetUp()\r\n{\r\n   var culture = new CultureInfo(&quot;en-GB&quot;);\r\n   Thread.CurrentThread.CurrentCulture = culture;\r\n   Thread.CurrentThread.CurrentUICulture = culture;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m creating some builds on appveyor for some of my GitHub projects and hit a small snag. All of the DateTime&#8217;s in my tests have test data in the en-GB format, i.e. dd\/MM\/yyyy. Note: Whilst I haven&#8217;t checked, I suspect appveyor is hosted on en-US machines. A simple way to resolve this is, just add [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-8297","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8297"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8297\/revisions"}],"predecessor-version":[{"id":8301,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8297\/revisions\/8301"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}