diff options
author | crupest <crupest@outlook.com> | 2020-06-18 18:14:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 18:14:18 +0800 |
commit | 5f57f6d3f9c7bd94929f3e50915d57da7c031538 (patch) | |
tree | 0f7dc1c0a58042c13f08b3d557e8c4226827ef56 /Timeline.Tests/Helpers/TestClock.cs | |
parent | 4a46206ea5f004ecb595de4bfd573b6263ac462b (diff) | |
parent | c5c50332aebd9a3e7d5d2c9163f0cad6c6ba241b (diff) | |
download | timeline-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.cs | 43 |
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;
+ }
+ }
+}
|