Esempio n. 1
0
        public void CouldAssingConsumerForTopicWatermark()
        {
            // Arrange
            var topicName = new TopicName("Test");
            var offset    = new WatermarkOffsets(new Offset(1), new Offset(2));
            var partition = new Partition(1);
            var watermark = new PartitionWatermark(topicName, offset, partition);

            var topicWatermark = new TopicWatermark(new[] { watermark });
            var consumerMock   = new Mock <IConsumer <object, object> >();
            var consumer       = consumerMock.Object;

            // Act
            var exception = Record.Exception(() => topicWatermark.AssignWithConsumer(consumer));

            // Assert
            exception.Should().BeNull();

            consumerMock.Verify(x => x.Assign(It.Is <IEnumerable <TopicPartitionOffset> >(value =>
                                                                                          value.Single().Topic == topicName.Value
                                                                                          &&
                                                                                          value.Single().Partition == partition
                                                                                          &&
                                                                                          value.Single().Offset == offset.High
                                                                                          &&
                                                                                          value.Single().TopicPartition.Topic == topicName.Value
                                                                                          &&
                                                                                          value.Single().TopicPartition.Partition == partition
                                                                                          )
                                              ), Times.Once);
        }
Esempio n. 2
0
        public void CouldNotAssingNullConsumerForTopicWatermark()
        {
            // Arrange
            var partitionWatermarks             = (new Mock <IEnumerable <PartitionWatermark> >()).Object;
            var watermark                       = new TopicWatermark(partitionWatermarks);
            IConsumer <object, object> consumer = null !;

            // Act
            var exception = Record.Exception(() => watermark.AssignWithConsumer(consumer));

            // Assert
            exception.Should().NotBeNull().And.BeOfType <ArgumentNullException>();
        }