public async Task DefaultBehaviorDisabled()
        {
            var mockClient        = new MockEventHubClient(new EventHubsConnectionStringBuilder(connectionString));
            var partitionReceiver = mockClient.CreateReceiver("consumerGroup", targetPartitionId, EventPosition.FromStart());
            var partitionSender   = mockClient.CreateEventSender(targetPartitionId);

            await partitionSender.SendAsync(new EventData[] { new EventData(Encoding.UTF8.GetBytes("foo")) }, targetPartitionId);

            await ValidateDisabledBehavior(partitionReceiver);
        }
Exemple #2
0
 public MockPartitionReceiver(
     MockEventHubClient eventHubClient,
     string consumerGroupName    = "consumerGroup",
     string partitionId          = "1",
     EventPosition eventPosition = default,
     long?epoch = default,
     ReceiverOptions receiverOptions = default)
     : base(eventHubClient, consumerGroupName, partitionId, eventPosition ?? EventPosition.FromStart(), epoch, receiverOptions)
 {
     this.eventHubClient = eventHubClient;
 }
        public async Task BasicValidation()
        {
            var mockClient        = new MockEventHubClient(new EventHubsConnectionStringBuilder(connectionString));
            var partitionReceiver = mockClient.CreateReceiver("consumerGroup", targetPartitionId, EventPosition.FromStart(), new ReceiverOptions {
                EnableReceiverRuntimeMetric = true
            });
            var partitionSender = mockClient.CreateEventSender(targetPartitionId);

            await partitionSender.SendAsync(new EventData[] { new EventData(Encoding.UTF8.GetBytes("foo")) }, targetPartitionId);

            // Get the partition runtime info so we can compare with runtime metrics.
            var pInfo = await mockClient.GetPartitionRuntimeInformationAsync(targetPartitionId);

            await ValidateEnabledBehavior(partitionReceiver, pInfo);
        }
        public async Task ClientSettingInherited()
        {
            var mockClient = new MockEventHubClient(new EventHubsConnectionStringBuilder(connectionString));

            // Enable runtime metrics on the client.
            mockClient.EnableReceiverRuntimeMetric = true;

            var partitionReceiver1 = mockClient.CreateReceiver("consumerGroup", targetPartitionId, EventPosition.FromStart());
            var partitionReceiver2 = mockClient.CreateReceiver("consumerGroup", targetPartitionId, EventPosition.FromStart());
            var partitionSender    = mockClient.CreateEventSender(targetPartitionId);

            await partitionSender.SendAsync(
                Enumerable.Range(1, 10)
                .Select(number => new EventData(Encoding.UTF8.GetBytes(number.ToString()))
                        ), targetPartitionId);

            // Get the partition runtime info so we can compare with runtime metrics.
            var pInfo = await mockClient.GetPartitionRuntimeInformationAsync(targetPartitionId);

            await ValidateEnabledBehavior(partitionReceiver1, pInfo);
            await ValidateEnabledBehavior(partitionReceiver2, pInfo);
        }
 internal MockEventDataSender(MockEventHubClient eventHubClient, string partitionId)
     : base(eventHubClient, partitionId)
 {
     this.RetryPolicy    = eventHubClient.RetryPolicy.Clone();
     this.eventHubClient = eventHubClient;
 }