blob: 7fa17fbe2dac47f471bcf92865930967d36e8894 (
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
 | using System;
using Timeline.Services;
namespace Timeline.Tests.Helpers
{
    public class TestClock : IClock
    {
        private DateTime? _currentTime;
        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 = _currentTime.Value + timeSpan;
            return _currentTime.Value;
        }
    }
}
 |