Exemple #1
0
        public async Task GetAsync_FilterReplacesReturnValue()
        {
            var replacementEntity = new MyEntity2(Guid.NewGuid(), 5);

            repositoryFilter1.FilterResult <IEventSourcedAggregateRoot>(null)
            .ReturnsForAnyArgs(replacementEntity);

            sut = new EventSourcedAggregateRepository(eventStore, entityTypeManager, publishEventBuffer,
                                                      new[] { repositoryFilter1 }, eventMessageFactory, new EntityFactory());

            Assert.Equal(replacementEntity, await sut.GetAsync <MyEntity2>(entity2Id));
        }
Exemple #2
0
        public async Task GetAsync_FilterGetsCalled()
        {
            repositoryFilter1.FilterResult <IEventSourcedAggregateRoot>(null)
            .ReturnsForAnyArgs(ci => ci.ArgAt <IEventSourcedAggregateRoot>(0));

            sut = new EventSourcedAggregateRepository(eventStore, entityTypeManager, publishEventBuffer,
                                                      new[] { repositoryFilter1 }, eventMessageFactory, new EntityFactory());

            await sut.GetAsync <MyEntity2>(entity2Id);

            repositoryFilter1.Received(1).FilterResult <IEventSourcedAggregateRoot>(Arg.Is <IEventSourcedAggregateRoot>(x => x.Id == entity2Id));
        }