public async Task Send_sets_partition_key_correctly()
        {
            var eventHubClient         = EventHubClient.CreateFromConnectionString(_connectionString);
            var eventSender            = new EventMessageSender(eventHubClient);
            var sut                    = new EventHubMessageBus(eventSender);
            PartitionedMessage message = new Fixture().Create <PartitionedMessage>();
            IEnumerable <PartitionReceiver> receivers = await GetReceivers(eventHubClient, _consumerGroupName);

            await sut.Send(new Envelope(message), CancellationToken.None);

            IEnumerable <EventData> received = await ReceiveAll(receivers);

            await eventHubClient.CloseAsync();

            EventData eventData = received.Single();

            eventData.SystemProperties.PartitionKey.Should().Be(message.PartitionKey);
        }
        public async Task Send_with_envelopes_sends_partitioned_messages_correctly()
        {
            // Arrange
            var eventHubClient = EventHubClient.CreateFromConnectionString(_connectionString);
            var eventSender    = new EventMessageSender(eventHubClient);
            var serializer     = new EventDataSerializer();
            var sut            = new EventHubMessageBus(eventSender);

            string partitionKey = Guid.NewGuid().ToString();
            var    envelopes    = new Fixture()
                                  .Build <PartitionedMessage>()
                                  .With(message => message.PartitionKey, partitionKey)
                                  .CreateMany()
                                  .Select(message => new Envelope(
                                              messageId: Guid.NewGuid(),
                                              message,
                                              operationId: $"{Guid.NewGuid()}",
                                              correlationId: Guid.NewGuid(),
                                              contributor: $"{Guid.NewGuid()}"))
                                  .ToList();

            IEnumerable <PartitionReceiver> receivers = await GetReceivers(eventHubClient, _consumerGroupName);

            // Act
            await sut.Send(envelopes, CancellationToken.None);

            // Assert
            IEnumerable <EventData> received = await ReceiveAll(receivers);

            await eventHubClient.CloseAsync();

            IEnumerable <Envelope> actual = from eventData in received
                                            select serializer.Deserialize(eventData);

            actual.Should().BeEquivalentTo(
                envelopes,
                opts =>
                opts.WithStrictOrdering()
                .RespectingRuntimeTypes());
        }