public void ReturnsEmptyCollection() { var cache = new LoadMetricsCache(); cache.Add(new LoadMetrics("server-3", 20.2, 30.3)); Assert.Equal(0, cache.Get("server-1").Count); }
public void ServerNameIsEmpty() { var cache = new LoadMetricsCache(); var controller = new LoadMetricsController(cache); var result = controller.PostLoadMetrics("", null); Assert.IsType<BadRequestResult>(result); }
public void SeverNameIsEmpty() { var cache = new LoadMetricsCache(); var controller = new LoadMetricsSummaryController(new LoadMetricsSummaryQuery(cache)); var result = controller.GetLoadMetricsSummary("", "monthly"); Assert.IsType<BadRequestResult>(result); }
public void AddMultipleMetricsToCache() { var cache = new LoadMetricsCache(); cache.Add(new LoadMetrics("server-1", 20.2, 30.3)); cache.Add(new LoadMetrics("server-1", 20.4, 30.6)); Assert.Equal(2, cache.Get("server-1").Count); }
public void CheckIsNotFound() { var cache = new LoadMetricsCache(); var controller = new LoadMetricsSummaryController(new LoadMetricsSummaryQuery(cache)); var result = controller.GetLoadMetricsSummary("server-1", "daily"); Assert.IsType<NotFoundResult>(result); }
public void IntervalIsWrong() { var cache = new LoadMetricsCache(); var controller = new LoadMetricsSummaryController(new LoadMetricsSummaryQuery(cache)); var result = controller.GetLoadMetricsSummary("server", "monthly"); Assert.IsType<BadRequestResult>(result); }
public void CheckIfCreated() { var cache = new LoadMetricsCache(); var controller = new LoadMetricsController(cache); var result = controller.PostLoadMetrics("server-1", new LoadMetrics("server-1", 20.2, 54.8)); Assert.IsType<CreatedNegotiatedContentResult<LoadMetrics>>(result); Assert.Equal(1, cache.Get("server-1").Count); }
public void CheckOkStatus() { var cache = new LoadMetricsCache(); cache.Add(new LoadMetrics("server-1", 20.2, 30.3)); var controller = new LoadMetricsSummaryController(new LoadMetricsSummaryQuery(cache)); var result = controller.GetLoadMetricsSummary("server-1", "daily"); Assert.IsType<OkNegotiatedContentResult<IReadOnlyCollection<LoadMetricsSummary>>>(result); }
public void CheckDailySummaryHsaMultiplePerids() { var cache = new LoadMetricsCache(); cache.Add(new LoadMetrics("server-1", 20.0, 40.0)); cache.Add(new LoadMetrics("server-1", 40.0, 80.0, DateTimeOffset.UtcNow.AddMinutes(-80))); var query = new LoadMetricsSummaryQuery(cache); var summary = query.GetDailySummary("server-1"); Assert.Equal(2, summary.Count); }
public void CheckHourlySummaryOnlyGetsLast60Minutes() { var cache = new LoadMetricsCache(); cache.Add(new LoadMetrics("server-1", 20.0, 40.0)); cache.Add(new LoadMetrics("server-1", 40.0, 80.0, DateTimeOffset.UtcNow.AddMinutes(-65))); var query = new LoadMetricsSummaryQuery(cache); var summary = query.GetHourlySummary("server-1"); Assert.Equal(1, summary.Count); Assert.Equal(20.0, summary.First().AvgCpuLoad); Assert.Equal(40.0, summary.First().AvgRamLoad); }
public void CheckCorrectHourlySummary() { var cache = new LoadMetricsCache(); cache.Add(new LoadMetrics("server-1", 20.0, 40.0)); cache.Add(new LoadMetrics("server-1", 60.0, 60.0)); var query = new LoadMetricsSummaryQuery(cache); var summary = query.GetHourlySummary("server-1"); Assert.NotNull(summary); Assert.Equal(1, summary.Count); Assert.Equal(40.0, summary.First().AvgCpuLoad); Assert.Equal(50.0, summary.First().AvgRamLoad); }
public void SummaryIsEmpty() { var cache = new LoadMetricsCache(); var query = new LoadMetricsSummaryQuery(cache); var hourlySummary = query.GetHourlySummary("server-1"); var dailySummary = query.GetDailySummary("server-1"); Assert.Equal(0, hourlySummary.Count); Assert.Equal(0, dailySummary.Count); }