public void MultipleGapsInData() { // Arrange var mockConfig = new Mock <IConfiguration>(); mockConfig .SetupGet(conf => conf["ServiceManager:DiscrepancyService:Gaps:MaxDifference"]) .Returns("60"); var discrepancyService = new DiscrepancyService( new Mock <ILogger <DiscrepancyService> >().Object, new Mock <IDataContext>().Object, new Mock <INotificationService>().Object, mockConfig.Object ); var input = new List <DateTime>() { DateTime.UtcNow - new TimeSpan(0, 0, 0), DateTime.UtcNow - new TimeSpan(0, 1, 0), DateTime.UtcNow - new TimeSpan(0, 4, 0), DateTime.UtcNow - new TimeSpan(0, 5, 0), DateTime.UtcNow - new TimeSpan(0, 7, 0) }; var expected = new List <Discrepancy> { new Discrepancy { DateFirstOffense = input[2], Type = DiscrepancyType.GapInData, MetricType = Metrics.CpuLoad, MetricSource = "the-source" }, new Discrepancy { DateFirstOffense = input[4], Type = DiscrepancyType.GapInData, MetricType = Metrics.CpuLoad, MetricSource = "the-source" } } .OrderBy(d => d.DateFirstOffense); // Act var actual = discrepancyService .FindGapsInDataPoints( input, new Metric { Type = Metrics.CpuLoad.AsInt(), Source = "the-source" } ) .OrderBy(d => d.DateFirstOffense); // Assert Assert.Equal(expected, actual); }
public void NoGapsInData() { // Arrange var mockConfig = new Mock <IConfiguration>(); mockConfig .SetupGet(conf => conf["ServiceManager:DiscrepancyService:Gaps:MaxDifference"]) .Returns("60"); var discrepancyService = new DiscrepancyService( new Mock <ILogger <DiscrepancyService> >().Object, new Mock <IDataContext>().Object, new Mock <INotificationService>().Object, mockConfig.Object ); var input = new List <DateTime>() { DateTime.UtcNow - new TimeSpan(0, 0, 0), DateTime.UtcNow - new TimeSpan(0, 1, 0), DateTime.UtcNow - new TimeSpan(0, 2, 0), DateTime.UtcNow - new TimeSpan(0, 3, 0), DateTime.UtcNow - new TimeSpan(0, 4, 0), DateTime.UtcNow - new TimeSpan(0, 5, 0) }; // Act var actual = discrepancyService .FindGapsInDataPoints( input, new Metric { Type = Metrics.CpuLoad.AsInt(), Source = "the-source" } ); // Assert Assert.Empty(actual); }
public void GapNoData() { // Arrange var discrepancyService = new DiscrepancyService( new Mock <ILogger <DiscrepancyService> >().Object, new Mock <IDataContext>().Object, new Mock <INotificationService>().Object, new Mock <IConfiguration>().Object ); // Act var actual = discrepancyService .FindGapsInDataPoints( new List <DateTime>(), new Metric { Type = Metrics.CpuLoad.AsInt(), Source = "the-source" } ); // Assert Assert.Empty(actual); }