blob: 0cbf236d7e25a8d6ea0828b92f2e752b2aee4097 (
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.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 += timeSpan;
return _currentTime.Value;
}
}
}
|