From 14530efb0ff3e81eb5b83728e77cfdc927d661d1 Mon Sep 17 00:00:00 2001 From: Josh Creek Date: Thu, 2 Sep 2021 20:00:46 +0100 Subject: [PATCH] feat(*): Add SystemTime.Now method --- .../Creek.HelpfulExtensions.csproj | 4 ++-- Creek.HelpfulExtensions/SystemTime.cs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 Creek.HelpfulExtensions/SystemTime.cs diff --git a/Creek.HelpfulExtensions/Creek.HelpfulExtensions.csproj b/Creek.HelpfulExtensions/Creek.HelpfulExtensions.csproj index d8f6643..7319ab3 100644 --- a/Creek.HelpfulExtensions/Creek.HelpfulExtensions.csproj +++ b/Creek.HelpfulExtensions/Creek.HelpfulExtensions.csproj @@ -19,8 +19,8 @@ LICENSE git creek - 1.1.0 - 1.1.0.0 + 1.2.0 + 1.2.0.0 diff --git a/Creek.HelpfulExtensions/SystemTime.cs b/Creek.HelpfulExtensions/SystemTime.cs new file mode 100644 index 0000000..44ac2e8 --- /dev/null +++ b/Creek.HelpfulExtensions/SystemTime.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Creek.HelpfulExtensions +{ + public static class SystemTime + { + /// + /// This method exposes DateTime.Now as an instance of a function, that can be replaced in tests. + /// +#pragma warning disable S1104 // Fields should not have public accessibility +#pragma warning disable S2223 // Non-constant static fields should not be visible + public static Func Now = () => DateTime.Now; +#pragma warning restore S2223 // Non-constant static fields should not be visible +#pragma warning restore S1104 // Fields should not have public accessibility + } +}