public async Task PublishAsync_AppendsEventsToStreamUsingStreamWriter(
            [Frozen] Mock<IEventStreamWriter> writerMock,
            JournaledEvent[] events,
            EventStreamProducer producer)
        {
            await producer.PublishAsync(events);

            writerMock.Verify(self => self.AppendEventsAsync(events));
        }
        public async Task PublishAsync_WhenWriterThrows_MovesItToTheEndOfStreamAndTriesAppendAgain(
            [Frozen] Mock<IEventStreamWriter> writerMock,
            [Frozen] RetryPolicyStub retryPolicy,
            JournaledEvent[] events,
            EventStreamProducer producer)
        {
            var expectedAttemptsCount = 5;

            retryPolicy.ConfigureMaxAttemptNumber(expectedAttemptsCount);

            writerMock
                .Setup(self => self.AppendEventsAsync(events))
                .Throws<EventStreamConcurrencyException>();

            await Assert.ThrowsAsync<EventStreamConcurrencyException>(() => producer.PublishAsync(events));

            writerMock.Verify(self => self.MoveToEndOfStreamAsync());
            writerMock.Verify(self => self.AppendEventsAsync(events), Times.Exactly(expectedAttemptsCount));
        }