aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Helpers/TestClock.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-06-18 18:14:18 +0800
committerGitHub <noreply@github.com>2020-06-18 18:14:18 +0800
commit135f47e7477bb2a72c423145dcd286ae494fd3ed (patch)
treec4e27cac4b2057c645f031be12eda896b96aa435 /Timeline.Tests/Helpers/TestClock.cs
parent3dc9460798798e5ba155fae7b6afe84522c2c619 (diff)
parent2f91cce1c29ac4b9b49ca389b565c66199985f2d (diff)
downloadtimeline-135f47e7477bb2a72c423145dcd286ae494fd3ed.tar.gz
timeline-135f47e7477bb2a72c423145dcd286ae494fd3ed.tar.bz2
timeline-135f47e7477bb2a72c423145dcd286ae494fd3ed.zip
Merge pull request #111 from crupest/timeline-last-modified
Timeline last modified property.
Diffstat (limited to 'Timeline.Tests/Helpers/TestClock.cs')
-rw-r--r--Timeline.Tests/Helpers/TestClock.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Timeline.Tests/Helpers/TestClock.cs b/Timeline.Tests/Helpers/TestClock.cs
new file mode 100644
index 00000000..de7d0eb7
--- /dev/null
+++ b/Timeline.Tests/Helpers/TestClock.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Timeline.Services;
+
+namespace Timeline.Tests.Helpers
+{
+ public class TestClock : IClock
+ {
+ private DateTime? _currentTime = null;
+
+ public DateTime GetCurrentTime()
+ {
+ return _currentTime ?? DateTime.Now;
+ }
+
+ public void SetCurrentTime(DateTime? mockTime)
+ {
+ _currentTime = mockTime;
+ }
+
+ public DateTime SetMockCurrentTime()
+ {
+ var time = new DateTime(2000, 1, 1, 1, 1, 1);
+ _currentTime = time;
+ return time;
+ }
+
+ public DateTime ForwardCurrentTime()
+ {
+ return ForwardCurrentTime(TimeSpan.FromDays(1));
+ }
+
+ public DateTime ForwardCurrentTime(TimeSpan timeSpan)
+ {
+ if (_currentTime == null)
+ return SetMockCurrentTime();
+ _currentTime.Value.Add(timeSpan);
+ return _currentTime.Value;
+ }
+ }
+}