Created
June 7, 2012 14:36
-
-
Save SlyNet/2889138 to your computer and use it in GitHub Desktop.
Unit testing friendly datetime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Core.Utils | |
{ | |
public static class SystemTime | |
{ | |
public static Func<DateTime> Engine { private get; set; } | |
static SystemTime() | |
{ | |
SetDefaultEngine(); | |
} | |
public static void SetDefaultEngine() | |
{ | |
Engine = () => DateTime.Now; | |
} | |
public static DateTime Now | |
{ | |
get | |
{ | |
return Engine(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment