public void WhenJoinerOnFirstDay_ThenDailyHistoramIsOneAtFirstDay()
        {
            var baseDate = new DateTime(2020, 1, 1);

            var joiners = new[]
            {
                baseDate
            };

            var leavers = new[]
            {
                baseDate.AddDays(4).AddMinutes(30)
            };

            var histogram = TimeseriesUtil.DailyHistogram(joiners, leavers).ToList();

            Assert.AreEqual(1, histogram[0].Value);
            Assert.AreEqual(1, histogram[1].Value);
            Assert.AreEqual(1, histogram[2].Value);
            Assert.AreEqual(1, histogram[3].Value);
            Assert.AreEqual(1, histogram[4].Value);
        }
        public void WhenJoinersAndLeaversOverlap_ThenDailyHistogramUsesTotal()
        {
            var baseDate = new DateTime(2020, 1, 1);

            var joiners = new[]
            {
                baseDate.AddDays(1),
                baseDate.AddDays(2).AddHours(1),
                baseDate.AddDays(3),
                baseDate.AddDays(7).AddSeconds(1)
            };

            var leavers = new[]
            {
                baseDate.AddDays(4).AddMinutes(30),
                baseDate.AddDays(5),
                baseDate.AddDays(6),
                baseDate.AddDays(10)
            };

            var histogram = TimeseriesUtil.DailyHistogram(joiners, leavers).ToList();

            Assert.AreEqual(1, histogram[0].Value);
            Assert.AreEqual(2, histogram[1].Value);
            Assert.AreEqual(3, histogram[2].Value);
            Assert.AreEqual(3, histogram[3].Value);
            Assert.AreEqual(2, histogram[4].Value);
            Assert.AreEqual(1, histogram[5].Value);
            Assert.AreEqual(1, histogram[6].Value);
            Assert.AreEqual(1, histogram[7].Value);
            Assert.AreEqual(1, histogram[8].Value);
            Assert.AreEqual(1, histogram[9].Value);

            Assert.AreEqual(baseDate.AddDays(1), histogram[0].Timestamp);
            Assert.AreEqual(baseDate.AddDays(10), histogram[9].Timestamp);
        }
        public void WhenBalanceChagesThroughoutDay_ThenDailyHistoramReportsMaxButRepeatsLast()
        {
            var baseDate = new DateTime(2020, 1, 1);

            var joiners = new[]
            {
                baseDate.AddMinutes(1),
                baseDate.AddMinutes(2),
                baseDate.AddMinutes(3),
            };

            var leavers = new[]
            {
                baseDate.AddMinutes(4),
                baseDate.AddMinutes(5),
                baseDate.AddDays(2)
            };

            var histogram = TimeseriesUtil.DailyHistogram(joiners, leavers).ToList();

            Assert.AreEqual(3, histogram[0].Value);
            Assert.AreEqual(1, histogram[1].Value);
            Assert.AreEqual(1, histogram[2].Value);
        }