示例#1
0
        public EventConsumerGrainTests()
        {
            state.Position = initialPosition;

            consumerName = eventConsumer.GetType().Name;

            A.CallTo(() => eventStore.CreateSubscription(A <IEventSubscriber> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .Returns(eventSubscription);

            A.CallTo(() => eventConsumer.Name).
            Returns(consumerName);

            A.CallTo(() => stateHolder.State)
            .ReturnsLazily(() => state);

            A.CallToSet(() => stateHolder.State)
            .Invokes(new Action <EventConsumerState>(s => state = s));

            A.CallTo(() => formatter.Parse(eventData, true)).Returns(envelope);

            sut           = new MyEventConsumerGrain(formatter, eventStore, log);
            sutSubscriber = sut;

            sut.ActivateAsync(stateHolder).Wait();
        }
示例#2
0
        public void Should_not_subscribe_to_event_store_when_stopped_in_db()
        {
            state = state.Stopped();

            sut.Activate(eventConsumer);
            sut.Dispose();

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

            A.CallTo(() => eventStore.CreateSubscription(A <IEventSubscriber> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .MustNotHaveHappened();
        }