public EventConsumerGrainTests() { grainState.Value = new EventConsumerState { Position = initialPosition }; consumerName = eventConsumer.GetType().Name; A.CallTo(() => eventStore.CreateSubscription(A <IEventSubscriber> ._, A <string> ._, A <string> ._)) .Returns(eventSubscription); A.CallTo(() => eventConsumer.Name) .Returns(consumerName); A.CallTo(() => eventConsumer.Handles(A <StoredEvent> ._)) .Returns(true); A.CallTo(() => eventConsumer.On(A <IEnumerable <Envelope <IEvent> > > ._)) .Invokes((IEnumerable <Envelope <IEvent> > events) => { foreach (var @event in events) { eventConsumer.On(@event).Wait(); } }); A.CallTo(() => eventSubscription.Sender) .Returns(eventSubscription); storedEvent = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData); A.CallTo(() => formatter.ParseIfKnown(storedEvent)) .Returns(envelope); var log = A.Fake <ILogger <EventConsumerGrain> >(); sut = new MyEventConsumerGrain( x => eventConsumer, grainState, eventStore, formatter, log); }
public EventConsumerGrainTests() { grainState.Value = new EventConsumerState { Position = initialPosition }; consumerName = eventConsumer.GetType().Name; A.CallTo(() => eventStore.CreateSubscription(A <IEventSubscriber> ._, A <string> ._, A <string> ._)) .Returns(eventSubscription); A.CallTo(() => eventConsumer.Name) .Returns(consumerName); A.CallTo(() => eventConsumer.Handles(A <StoredEvent> ._)) .Returns(true); A.CallTo(() => eventConsumer.On(A <IEnumerable <Envelope <IEvent> > > ._)) .Invokes((IEnumerable <Envelope <IEvent> > events) => { foreach (var @event in events) { eventConsumer.On(@event).Wait(); } }); A.CallTo(() => eventSubscription.Sender) .Returns(eventSubscription); A.CallTo(() => formatter.ParseIfKnown(A <StoredEvent> .That.Matches(x => x.Data == eventData))) .Returns(envelope); sut = new MyEventConsumerGrain( x => eventConsumer, grainState, eventStore, formatter, log); }