public async Task ReadStoreIsUpdatedWithRelevantEvents() { // Arrange var thingyId = Inject(ThingyId.New); Arrange_ReadModelStore_UpdateAsync(ReadModelEnvelope <TReadModel> .With( thingyId.Value, A <TReadModel>())); var events = new[] { ToDomainEvent(A <ThingyPingEvent>(), 1), ToDomainEvent(A <ThingyDomainErrorAfterFirstEvent>(), 2) }; // Act await Sut.UpdateReadStoresAsync(events, CancellationToken.None).ConfigureAwait(false); // Assert ReadModelStoreMock.Verify( s => s.UpdateAsync( It.Is <IReadOnlyCollection <ReadModelUpdate> >(l => l.Count == 1), It.IsAny <IReadModelContextFactory>(), It.IsAny <Func < IReadModelContext, IReadOnlyCollection <IDomainEvent>, ReadModelEnvelope <TReadModel>, CancellationToken, Task <ReadModelUpdateResult <TReadModel> > > >(), It.IsAny <CancellationToken>()), Times.Once); }
public async Task IfNoReadModelIdsAreReturned_ThenDontInvokeTheReadModelStore() { // Arrange _readModelLocator.Setup(l => l.GetReadModelIds(It.IsAny <IDomainEvent>())).Returns(Enumerable.Empty <string>()); var events = new[] { ToDomainEvent(A <ThingyPingEvent>()), }; // Act await Sut.UpdateReadStoresAsync(events, CancellationToken.None).ConfigureAwait(false); // Assert _readModelLocator.Verify(l => l.GetReadModelIds(It.IsAny <IDomainEvent>()), Times.Once); ReadModelStoreMock.Verify( s => s.UpdateAsync( It.IsAny <IReadOnlyCollection <ReadModelUpdate> >(), It.IsAny <IReadModelContext>(), It.IsAny <Func <IReadModelContext, IReadOnlyCollection <IDomainEvent>, ReadModelEnvelope <ReadStoreManagerTestReadModel>, CancellationToken, Task <ReadModelEnvelope <ReadStoreManagerTestReadModel> > > >(), It.IsAny <CancellationToken>()), Times.Never); }