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 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 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 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);
        }