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
commit5f57f6d3f9c7bd94929f3e50915d57da7c031538 (patch)
tree0f7dc1c0a58042c13f08b3d557e8c4226827ef56 /Timeline.Tests/Helpers/TestClock.cs
parent4a46206ea5f004ecb595de4bfd573b6263ac462b (diff)
parentc5c50332aebd9a3e7d5d2c9163f0cad6c6ba241b (diff)
downloadtimeline-5f57f6d3f9c7bd94929f3e50915d57da7c031538.tar.gz
timeline-5f57f6d3f9c7bd94929f3e50915d57da7c031538.tar.bz2
timeline-5f57f6d3f9c7bd94929f3e50915d57da7c031538.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;
+ }
+ }
+}