public void ReadLastEnqueuedEventInformationRespectsTheTrackingEnabledFlag(bool trackingEnabled)
        {
            var receiver = new PartitionReceiver("group", "id", "name", trackingEnabled, TimeSpan.Zero, Mock.Of <TransportConsumer>());

            if (trackingEnabled)
            {
                var metrics = receiver.ReadLastEnqueuedEventInformation();
                Assert.That(metrics, Is.Not.Null, "The metrics should be present.");
            }
            else
            {
                Assert.That(() => receiver.ReadLastEnqueuedEventInformation(), Throws.TypeOf <InvalidOperationException>(), "Last enqueued event information cannot be read if tracking is not enabled.");
            }
        }
Exemplo n.º 2
0
        public void ReadLastEnqueuedEventInformationPopulatesFromTheLastReceivedEvent()
        {
            var lastEvent = new EventData
                            (
                eventBody: Array.Empty <byte>(),
                lastPartitionSequenceNumber: 12345,
                lastPartitionOffset: 89101,
                lastPartitionEnqueuedTime: DateTimeOffset.Parse("2015-10-27T00:00:00Z"),
                lastPartitionInformationRetrievalTime: DateTimeOffset.Parse("2012-03-04T08:49:00Z")
                            );

            var eventHub      = "someHub";
            var partition     = "PART";
            var transportMock = new ObservableTransportConsumerMock {
                LastReceivedEvent = lastEvent
            };
            var receiver = new PartitionReceiver("group", partition, eventHub, true, TimeSpan.Zero, transportMock);
            var metrics  = receiver.ReadLastEnqueuedEventInformation();

            Assert.That(metrics.EventHubName, Is.EqualTo(eventHub), "The Event Hub name should match.");
            Assert.That(metrics.PartitionId, Is.EqualTo(partition), "The partition id should match.");
            Assert.That(metrics.LastEnqueuedSequenceNumber, Is.EqualTo(lastEvent.LastPartitionSequenceNumber), "The sequence number should match.");
            Assert.That(metrics.LastEnqueuedOffset, Is.EqualTo(lastEvent.LastPartitionOffset), "The offset should match.");
            Assert.That(metrics.LastEnqueuedTime, Is.EqualTo(lastEvent.LastPartitionEnqueuedTime), "The enqueue time should match.");
            Assert.That(metrics.InformationReceived, Is.EqualTo(lastEvent.LastPartitionInformationRetrievalTime), "The retrieval time should match.");
        }