コード例 #1
0
 public void OnSubscriptionStarted_WhenSubscriptionWasStarted_Throws(
     StreamConsumingNotificationListenerStub listener,
     EventStreamUpdated notification,
     INotificationListenerSubscription subscription)
 {
     Assert.Throws <InvalidOperationException>(() => listener.OnSubscriptionStarted(subscription));
 }
コード例 #2
0
        public async Task nEventStreamUpdated_WhenSubscriptionWasStopped_Throws(
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification,
            INotificationListenerSubscription subscription)
        {
            listener.OnSubscriptionStopped();

            await Assert.ThrowsAsync <InvalidOperationException>(() => listener.On(notification));
        }
コード例 #3
0
        public async Task OnEventStreamUpdated_WhenListenerProcessingCompleted_ClosesConsumer(
            [Frozen] Mock <IEventStreamConsumer> consumerMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            await listener.On(notification);

            consumerMock.Verify(self => self.CloseAsync());
        }
コード例 #4
0
        public async Task OnEventStreamUpdated_WhenListenerProcessingCompleted_DoesNotDefereNotification(
            [Frozen] Mock <INotificationListenerSubscription> subscriptionMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            await listener.On(notification);

            subscriptionMock.Verify(self => self.RetryNotificationProcessingAsync(notification), Times.Never());
        }
コード例 #5
0
        public async Task OnEventStreamUpdated_WhenListenerProcessingCompleted_CommitsConsumedStreamVersion(
            [Frozen] Mock <IEventStreamConsumer> consumerMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            await listener.On(notification);

            consumerMock.Verify(self => self.CommitProcessedStreamVersionAsync(false));
        }
コード例 #6
0
        public async Task OnEventStreamUpdated_CreatesUpdatedStreamConsumer(
            [Frozen] Mock <INotificationListenerSubscription> subscriptionMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            await listener.On(notification);

            subscriptionMock.Verify(
                self => self.CreateSubscriptionConsumerAsync(notification.StreamName),
                Times.Once());
        }
コード例 #7
0
        public async Task OnEventStreamUpdated_WhenConsumerReceiveOperationFailed_ClosesConsumer(
            [Frozen] Mock <IEventStreamConsumer> consumerMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            consumerMock
            .Setup(self => self.ReceiveEventsAsync())
            .Returns(ReceivingResultCode.PromotionFailed.YieldTask());

            await listener.On(notification);

            consumerMock.Verify(self => self.CloseAsync(), Times.Once());
        }
コード例 #8
0
        public async Task OnEventStreamUpdated_WhenListenerProcessingFailed_DefersNotificationProcessing(
            [Frozen] Mock <INotificationListenerSubscription> subscriptionMock,
            [Frozen] Mock <IEventStreamConsumer> consumerMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            listener.ProcessingCompleted = false;

            await listener.On(notification);

            subscriptionMock.Verify(
                self => self.RetryNotificationProcessingAsync(notification),
                Times.Once());
        }
コード例 #9
0
        public async Task OnEventStreamUpdated_WhenConsumerReceiveOperationFailed_DefersNotificationProcessing(
            [Frozen] Mock <INotificationListenerSubscription> subscriptionMock,
            [Frozen] Mock <IEventStreamConsumer> consumerMock,
            StreamConsumingNotificationListenerStub listener,
            EventStreamUpdated notification)
        {
            consumerMock
            .Setup(self => self.ReceiveEventsAsync())
            .Returns(ReceivingResultCode.PromotionFailed.YieldTask());

            await listener.On(notification);

            subscriptionMock.Verify(
                self => self.RetryNotificationProcessingAsync(notification),
                Times.Once());
        }