public void Timer()
        {
            var mockConsumer = new Mock <IConsumer <int> >();
            var fakeTimer    = new FakeThreadingTimer();
            var consumer     = new TimedBufferingConsumer <int>(mockConsumer.Object, _waitTime, fakeTimer);

            var intArray = new[] { 1, 2, 3, 4, 5 };

            consumer.Receive(intArray);
            mockConsumer.Verify(c => c.Receive(It.IsAny <IEnumerable <int> >()), Times.Never());
            fakeTimer.FullTick();
            mockConsumer.Verify(c => c.Receive(intArray), Times.Once());

            var intArrayTwo = new[] { 10, 9, 8, 7, 6 };

            consumer.Receive(intArrayTwo);
            fakeTimer.FullTick();
            mockConsumer.Verify(c => c.Receive(intArrayTwo), Times.Once());
        }
        public void Timer_SwallowRpcException()
        {
            var mockConsumer = new Mock <IConsumer <int> >();
            var fakeTimer    = new FakeThreadingTimer();
            var consumer     = new TimedBufferingConsumer <int>(mockConsumer.Object, _waitTime, fakeTimer);

            mockConsumer.Setup(c => c.Receive(It.IsAny <IEnumerable <int> >())).Throws(new RpcException(Status.DefaultCancelled));
            consumer.Receive(new[] { 1, 2, 3, 4, 5 });
            fakeTimer.FullTick();
            mockConsumer.Verify(c => c.Receive(It.IsAny <IEnumerable <int> >()), Times.Once());
        }
        public void Timer_Exception()
        {
            var mockConsumer = new Mock <IConsumer <int> >();
            var fakeTimer    = new FakeThreadingTimer();
            var consumer     = new TimedBufferingConsumer <int>(mockConsumer.Object, _waitTime, fakeTimer);

            mockConsumer.Setup(c => c.Receive(It.IsAny <IEnumerable <int> >())).Throws(new DivideByZeroException());
            consumer.Receive(new[] { 1, 2, 3, 4, 5 });
            try
            {
                fakeTimer.FullTick();
                Assert.True(false);
            }
            catch (Exception e) when(!(e is Xunit.Sdk.XunitException))
            {
            }
            mockConsumer.Verify(c => c.Receive(It.IsAny <IEnumerable <int> >()), Times.Once());
        }