Example #1
0
        public async Task Should_start_after_stop_when_handling_failed()
        {
            sut.Activate(eventConsumer);

            var exception = new InvalidOperationException();

            A.CallTo(() => eventConsumer.On(envelope))
            .Throws(exception);

            var @event = new StoredEvent(Guid.NewGuid().ToString(), 123, eventData);

            await OnEventAsync(eventSubscription, @event);

            sut.Start();
            sut.Start();
            sut.Dispose();

            state.ShouldBeEquivalentTo(new EventConsumerState {
                IsStopped = false, Position = initialPosition, Error = null
            });

            A.CallTo(() => eventConsumer.On(envelope))
            .MustHaveHappened();

            A.CallTo(() => stateHolder.WriteAsync())
            .MustHaveHappened(Repeated.Exactly.Twice);

            A.CallTo(() => eventSubscription.StopAsync())
            .MustHaveHappened(Repeated.Exactly.Once);

            A.CallTo(() => eventStore.CreateSubscription(A <IEventSubscriber> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .MustHaveHappened(Repeated.Exactly.Twice);
        }
Example #2
0
        public void Should_start_correct_actor()
        {
            sut.Connect();

            pubSub.Publish(new StartConsumerMessage {
                ConsumerName = consumerName1
            }, true);

            A.CallTo(() => actor1.Start())
            .MustHaveHappened();

            A.CallTo(() => actor2.Start())
            .MustNotHaveHappened();
        }