aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.TelemetryTester.CLI/MockHistorySource.cs
blob: 6ecd7e637ce582b57b2327c190395874262bceb8 (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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Tango.Telemetry;

namespace Tango.TelemetryTester.CLI
{
    public class MockHistorySource : ITelemetryHistorySource
    {
        public string Name { get; }

        public int ProvidedCount { get; set; }

        public MockHistorySource(string name)
        {
            Name = name;
        }

        public Task<bool> CanRequestHistory(DateTime from) => Task.FromResult(true);

        public Task<IEnumerable<ITelemetry>> RequestHistory(DateTime from)
        {
            Logger.LogInfo($"[HistorySource] Providing historical telemetry at {DateTime.UtcNow}");

            ProvidedCount++;

            return Task.FromResult<IEnumerable<ITelemetry>>(new[]
            {
                new MockTelemetry { Time = DateTime.UtcNow.AddSeconds(-30) }
            });
        }

        public void Dispose() { }
    }
}