public void Can_reset()
        {
            _reservoir.Update(1L);
            _reservoir.Reset();
            _reservoir.Update(2L);
            _reservoir.Update(3L);

            _reservoir.GetSnapshot().Values.Should().NotContain(1L);
            _reservoir.GetSnapshot().Values.Should().ContainInOrder(2L, 3L);
        }
Esempio n. 2
0
        public override void Setup()
        {
            _fixture = new MetricsCoreTestFixture();

            _reservoir = new DefaultSlidingWindowReservoir();

            _scheduler = new DefaultTaskScheduler();

            _scheduler.Interval(
                TimeSpan.FromMilliseconds(10),
                TaskCreationOptions.None,
                () =>
            {
                _reservoir.GetSnapshot();
                _reservoir.Reset();
            });
        }
        private Task Tick()
        {
            try
            {
                _reservoir.GetSnapshot();
                _reservoir.Reset();
            }
            catch (Exception)
            {
            }
            finally
            {
                lock (_syncLock)
                {
                    if (!_disposing)
                    {
                        SetScheduler();
                    }
                }
            }

            return(Task.CompletedTask);
        }