public async Task PublishMultipleCloudEvent_WithBuilder_ValidParameters_Succeeds()
        {
            // Arrange
            const string eventSubject = "integration-test";
            const string licensePlate = "1-TOM-337";
            var          firstEventId = Guid.NewGuid().ToString();
            var          firstEvent   = new CloudEvent(CloudEventsSpecVersion.V1_0, "NewCarRegistered", new Uri("http://test-host"), eventSubject, firstEventId)
            {
                Data            = new CarEventData(licensePlate),
                DataContentType = new ContentType("application/json")
            };
            var secondEventId = Guid.NewGuid().ToString();
            var secondEvent   = new CloudEvent(CloudEventsSpecVersion.V1_0, "NewCarRegistered", new Uri("http://test-host"), eventSubject, secondEventId)
            {
                Data            = new CarEventData(licensePlate),
                DataContentType = new ContentType("application/json")
            };

            CloudEvent[] cloudEvents = { firstEvent, secondEvent };

            IEventGridPublisher publisher = EventPublisherFactory.CreateCloudEventPublisher(_config);

            // Act
            await publisher.PublishManyAsync(cloudEvents);

            // Assert
            Assert.All(cloudEvents, cloudEvent => AssertReceivedNewCarRegisteredEventWithTimeout(cloudEvent, licensePlate));
        }
        public async Task PublishMultipleEvents_WithBuilder_ValidParameters_SucceedsWithTimeout()
        {
            // Arrange
            var events =
                Enumerable
                .Repeat <Func <Guid> >(Guid.NewGuid, 2)
                .Select(newGuid => new NewCarRegistered(
                            newGuid().ToString(),
                            subject: "integration-test",
                            licensePlate: "1-TOM-337"))
                .ToArray();

            IEventGridPublisher publisher = EventPublisherFactory.CreateEventGridEventPublisher(_config);

            // Act
            await publisher.PublishManyAsync(events);

            // Assert
            Assert.All(events, @event => AssertReceivedNewCarRegisteredEventWithTimeout(@event, @event.GetPayload()?.LicensePlate));
        }
        public async Task PublishMultipleRawEvents_WithBuilder_ValidParameters_SucceedsWithTimeout()
        {
            // Arrange
            const string licensePlate = "1-TOM-1337";
            var          events       =
                Enumerable
                .Repeat <Func <Guid> >(Guid.NewGuid, 2)
                .Select(newGuid => new RawEvent(
                            newGuid().ToString(),
                            eventSubject: "integration-test",
                            eventData: $"{{\"licensePlate\": \"{licensePlate}\"}}",
                            eventType: "Arcus.Samples.Cars.NewCarRegistered",
                            eventVersion: "1.0",
                            eventTime: DateTimeOffset.Now))
                .ToArray();

            IEventGridPublisher publisher = EventPublisherFactory.CreateEventGridEventPublisher(_config);

            // Act
            await publisher.PublishManyAsync(events);

            // Assert
            Assert.All(events, rawEvent => AssertReceivedNewCarRegisteredEventWithTimeout(rawEvent, licensePlate));
        }