Exemplo n.º 1
0
        public void Store_updates_all_supported_historical_periods()
        {
            var store = new VariableHistoryIntervalStore <int>();

            var entries = EntriesBuilder.Build(new Dictionary <DateTime, long>
            {
                { now, 5L }
            });

            store.Store(0, entries);

            foreach (var period in HistoryPeriod.All)
            {
                var reportDelay = TimeSpan.FromTicks(period.IntervalSize.Ticks * period.DelayedIntervals);

                var intervals = store.GetIntervals(period, now.Add(reportDelay));

                Assert.AreEqual(1, intervals.Length);
                Assert.AreEqual(5L, intervals[0].TotalValue);
                Assert.AreEqual(1L, intervals[0].TotalMeasurements);
            }
        }
        public void Delayed_intervals_are_not_reported()
        {
            const int delayedIntervals = 5;
            var       intervalSize     = TimeSpan.FromSeconds(1);
            var       delay            = TimeSpan.FromTicks(delayedIntervals * intervalSize.Ticks);

            var entries = EntriesBuilder.Build(new Dictionary <DateTime, long>
            {
                { now.AddSeconds(-4), 1L },
                { now.AddSeconds(-3), 1L },
                { now, 1L }
            });

            var store = new IntervalsStore <int>(intervalSize, 10, delayedIntervals);

            store.Store(0, entries);

            var timings        = store.GetIntervals(now);
            var delayedTimings = store.GetIntervals(now.Add(delay));

            Assert.AreEqual(0, timings[0].TotalMeasurements);
            Assert.AreEqual(3, delayedTimings[0].TotalMeasurements);
        }