Пример #1
0
        public async Task Should_subscribe_on_start()
        {
            var sut = new PollingSubscription(eventStore, eventNotifier, eventSubscriber, "^my-stream", position);

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventStore.GetEventsAsync(A <Func <StoredEvent, Task> > .Ignored, A <CancellationToken> .Ignored, "^my-stream", position))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #2
0
        public async Task Should_subscribe_on_start()
        {
            var sut = new PollingSubscription(eventStore, eventSubscriber, "^my-stream", position);

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventStore.QueryAllAsync("^my-stream", position, A <long> ._, A <CancellationToken> ._))
            .MustHaveHappenedOnceExactly();
        }
        public async Task Should_subscribe_on_start()
        {
            var sut = new PollingSubscription(eventStore, eventSubscriber, "^my-stream", position);

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventStore.QueryAsync(A <Func <StoredEvent, Task> > ._, "^my-stream", position, A <CancellationToken> ._))
            .MustHaveHappened(1, Times.Exactly);
        }
Пример #4
0
        public async Task Should_wake_up()
        {
            var sut = new PollingSubscription(eventStore, eventSubscriber, "^my-stream", position);

            sut.WakeUp();

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventStore.QueryAllAsync("^my-stream", position, A <long> ._, A <CancellationToken> ._))
            .MustHaveHappened(2, Times.Exactly);
        }
Пример #5
0
        public async Task Should_wake_up()
        {
            var sut = new PollingSubscription(eventStore, eventSubscriber, "^my-stream", position);

            sut.WakeUp();

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventStore.QueryAsync(A <Func <StoredEvent, Task> > .Ignored, "^my-stream", position, A <CancellationToken> .Ignored))
            .MustHaveHappened(Repeated.Exactly.Twice);
        }
Пример #6
0
        public async Task Should_subscribe_on_notify_when_stream_matches()
        {
            var sut = new PollingSubscription(eventStore, eventNotifier, eventSubscriber, "^my-stream", position);

            eventNotifier.NotifyEventsStored("my-stream-123");

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventStore.QueryAsync(A <Func <StoredEvent, Task> > .Ignored, "^my-stream", position, A <CancellationToken> .Ignored))
            .MustHaveHappened(Repeated.Exactly.Twice);
        }
Пример #7
0
        public async Task Should_propagate_aggregate_operation_cancelled_exception_to_subscriber()
        {
            var ex = new AggregateException(new OperationCanceledException());

            A.CallTo(() => eventStore.GetEventsAsync(A <Func <StoredEvent, Task> > .Ignored, A <CancellationToken> .Ignored, "^my-stream", position))
            .Throws(ex);

            var sut = new PollingSubscription(eventStore, eventNotifier, eventSubscriber, "^my-stream", position);

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventSubscriber.OnErrorAsync(sut, ex))
            .MustNotHaveHappened();
        }
Пример #8
0
        public async Task Should_propagate_aggregate_operation_cancelled_exception_to_subscriber()
        {
            var ex = new AggregateException(new OperationCanceledException());

            A.CallTo(() => eventStore.QueryAllAsync("^my-stream", position, A <long> ._, A <CancellationToken> ._))
            .Throws(ex);

            var sut = new PollingSubscription(eventStore, eventSubscriber, "^my-stream", position);

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventSubscriber.OnErrorAsync(sut, ex))
            .MustHaveHappened();
        }
Пример #9
0
        public async Task Should_propagate_exception_to_subscriber()
        {
            var ex = new InvalidOperationException();

            A.CallTo(() => eventStore.QueryAsync(A <Func <StoredEvent, Task> > ._, "^my-stream", position, A <CancellationToken> ._))
            .Throws(ex);

            var sut = new PollingSubscription(eventStore, eventSubscriber, "^my-stream", position);

            await WaitAndStopAsync(sut);

            A.CallTo(() => eventSubscriber.OnErrorAsync(sut, ex))
            .MustHaveHappened();
        }