public void TestConsumerIteratorDeduplicationDeepIterator()
        {
            var messageStrings = Enumerable.Range(0, 10).Select(x => x.ToString()).ToList();
            var messages       = messageStrings.Select(s => new Message(Encoding.UTF8.GetBytes(s))).ToList();
            var messageSet     = new ByteBufferMessageSet(
                CompressionCodecs.DefaultCompressionCodec, new AtomicLong(0), messages);

            this.topicInfos[0].Enqueue(messageSet);
            Assert.Equal(1, this.queue.Count);

            this.queue.Add(ZookeeperConsumerConnector.ShutdownCommand);

            var iter = new ConsumerIterator <string, string>(this.queue, this.consumerConfig.ConsumerTimeoutMs, new StringDecoder(), new StringDecoder(), string.Empty);

            var receivedMessages = Enumerable.Range(0, 5).Select(_ => iter.Next().Message).ToList();

            Assert.False(iter.HasNext());

            Assert.Equal(1, this.queue.Count); // This is only shutdown comamnd
            Assert.Equal(5, receivedMessages.Count);
            var unconsumed =
                messageSet.Where(x => x.Offset >= this.consumedOffset).Select(m => Util.ReadString(m.Message.Payload));

            Assert.Equal(unconsumed, receivedMessages);
        }
        public void TestConsumerIteratorDecodingFailure()
        {
            var messageStrings = Enumerable.Range(0, 10).Select(x => x.ToString()).ToList();
            var messages       = messageStrings.Select(s => new Message(Encoding.UTF8.GetBytes(s))).ToList();
            var messageSet     = new ByteBufferMessageSet(
                CompressionCodecs.NoCompressionCodec, new AtomicLong(0), messages);

            this.topicInfos[0].Enqueue(messageSet);
            Assert.Equal(1, this.queue.Count);

            var iter = new ConsumerIterator <string, string>(
                this.queue, ConsumerConfig.DefaultConsumerTimeoutMs, new FailDecoder(), new FailDecoder(), string.Empty);

            for (var i = 0; i < 5; i++)
            {
                Assert.True(iter.HasNext());
                var message = iter.Next();

                Assert.Equal(message.Offset, i + this.consumedOffset);

                Assert.Throws <NotSupportedException>(() => message.Message);
            }
        }