public void ThrottledMetthodIsCalledOnTimeout()
        {
            // arrange
            throttled = new Throttler<int>(Reseter, 100, TimeSpan.FromMilliseconds(200));

            // test
            throttled.Call(new int());
            throttled.Call(new List<int>());

            // assert
            Assert.IsTrue(waiter.WaitOne(2000));
            Assert.IsTrue(length == 1);
            Assert.IsFalse(waiter.WaitOne(2000));
        }
        public void ThrottledMetthodIsCalledOnQueueFull()
        {
            // arrange
            throttled = new Throttler<int>(Reseter, 100, TimeSpan.FromMinutes(5));
            throttled.Call(new Fixture().CreateMany<int>(99).ToList());

            // assert 1
            Assert.IsFalse(waiter.WaitOne(2000));

            // test
            throttled.Call(new int());

            // assert 2
            Assert.IsTrue(waiter.WaitOne(2000));
            Assert.IsTrue(length == 100);
        }
        public void ThrottledMetthodIsCalledOnFlush()
        {
            // arrange
            throttled = new Throttler<int>(Reseter, 100, TimeSpan.FromMinutes(5));

            // test
            throttled.Call(new int());
            throttled.Call(new int());
            throttled.Call(new int());
            throttled.Call(new List<int>());
            throttled.Flush();

            // assert
            Assert.IsTrue(waiter.WaitOne(2000));
            Assert.IsTrue(length == 3);
        }
        public void ThrottledMetthodThrows()
        {
            // arrange
            throttled = new Throttler<int>(list => { throw new Exception("ERROR"); }, 100, TimeSpan.FromMilliseconds(100))
            {
                OnError = (ex, list) => waiter.Set()
            };

            throttled.Call(new int());

            // assert 1
            Assert.IsTrue(waiter.WaitOne(2000));
        }
        public void ThrottledMetthodIsNotCalled()
        {
            // arrange
            throttled = new Throttler<int>(Reseter, 100, TimeSpan.FromMinutes(5));

            // test
            throttled.Call(new int());
            throttled.Call(new List<int>(5));

            // assert
            Assert.IsFalse(waiter.WaitOne(2000));
        }