private void HandleEvents(IEnumerable <IEvent> events, IQueryDataStore queryDataStore) { var mockIdempotencyChecker = new Mock <IIdempotencyChecker>(); var mockDatabaseLayer = new Mock <IDatabaseLayer>(); mockDatabaseLayer.Setup(x => x.ExecuteInTransaction(It.IsAny <Action>())).Callback <Action>(x => x()); var eventHandler = new EventHandlerFactory(queryDataStore, mockIdempotencyChecker.Object, mockDatabaseLayer.Object); foreach (IEvent e in events) { eventHandler.HandleEvent(e); } }
public void ProcessDuplicateEvent() { var testEvent = new GameCreatedEvent(); var mockIdempotencyChecker = new Mock <IIdempotencyChecker>(); var mockQueryDataStore = new Mock <IQueryDataStore>(); mockIdempotencyChecker.Setup(x => x.CheckIdempotency(testEvent.EventId)).Returns(true); var sut = new EventHandlerFactory(mockQueryDataStore.Object, mockIdempotencyChecker.Object, null); sut.HandleEvent(testEvent); mockQueryDataStore.Verify(x => x.Insert(It.IsAny <GetGameCountByDateDto>()), Times.Never()); }
public void ProcessDuplicateEvent() { var testEvent = new GameCreatedEvent(); var mockIdempotencyChecker = new Mock<IIdempotencyChecker>(); var mockQueryDataStore = new Mock<IQueryDataStore>(); mockIdempotencyChecker.Setup(x => x.CheckIdempotency(testEvent.EventId)).Returns(true); var sut = new EventHandlerFactory(mockQueryDataStore.Object, mockIdempotencyChecker.Object, null); sut.HandleEvent(testEvent); mockQueryDataStore.Verify(x => x.Insert(It.IsAny<GetGameCountByDateDto>()), Times.Never()); }
public void ProcessNewEvent() { var testEvent = new GameCreatedEvent(); var mockIdempotencyChecker = new Mock <IIdempotencyChecker>(); var mockQueryDataStore = new Mock <IQueryDataStore>(); var mockDatabaseLayer = new Mock <IDatabaseLayer>(); mockDatabaseLayer.Setup(x => x.ExecuteInTransaction(It.IsAny <Action>())).Callback <Action>(x => x()); mockIdempotencyChecker.Setup(x => x.CheckIdempotency(testEvent.EventId)).Returns(false); var sut = new EventHandlerFactory(mockQueryDataStore.Object, mockIdempotencyChecker.Object, mockDatabaseLayer.Object); sut.HandleEvent(testEvent); mockQueryDataStore.Verify(x => x.Insert(It.IsAny <GetGameCountByDateDto>())); }
public void ProcessNewEvent() { var testEvent = new GameCreatedEvent(); var mockIdempotencyChecker = new Mock<IIdempotencyChecker>(); var mockQueryDataStore = new Mock<IQueryDataStore>(); var mockDatabaseLayer = new Mock<IDatabaseLayer>(); mockDatabaseLayer.Setup(x => x.ExecuteInTransaction(It.IsAny<Action>())).Callback<Action>(x => x()); mockIdempotencyChecker.Setup(x => x.CheckIdempotency(testEvent.EventId)).Returns(false); var sut = new EventHandlerFactory(mockQueryDataStore.Object, mockIdempotencyChecker.Object, mockDatabaseLayer.Object); sut.HandleEvent(testEvent); mockQueryDataStore.Verify(x => x.Insert(It.IsAny<GetGameCountByDateDto>())); }
private void HandleEvents(IEnumerable<IEvent> events, IQueryDataStore queryDataStore) { var mockIdempotencyChecker = new Mock<IIdempotencyChecker>(); var mockDatabaseLayer = new Mock<IDatabaseLayer>(); mockDatabaseLayer.Setup(x => x.ExecuteInTransaction(It.IsAny<Action>())).Callback<Action>(x => x()); var eventHandler = new EventHandlerFactory(queryDataStore, mockIdempotencyChecker.Object, mockDatabaseLayer.Object); foreach (IEvent e in events) { eventHandler.HandleEvent(e); } }