blob: ed2d65a61ba9061448d280b8b87d5bf0f1cf1ee7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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.UtcNow;
}
public void SetCurrentTime(DateTime? mockTime)
{
_currentTime = mockTime;
}
public DateTime SetMockCurrentTime()
{
var time = new DateTime(3000, 1, 1, 1, 1, 1, DateTimeKind.Utc);
_currentTime = time;
return time;
}
public DateTime ForwardCurrentTime()
{
return ForwardCurrentTime(TimeSpan.FromDays(1));
}
public DateTime ForwardCurrentTime(TimeSpan timeSpan)
{
if (_currentTime == null)
return SetMockCurrentTime();
_currentTime += timeSpan;
return _currentTime.Value;
}
}
}
|