public async Task FindAllTenantEntities_Test() // TODO: move to own test class + mocks
        {
            // arrange
            var sut = new RepositorySpecificationDecorator <StubPerson>(
                new Specification <StubPerson>(t => t.TenantId == this.tenantId),
                new InMemoryRepository <StubPerson, StubDb>(o => o
                                                            .Mediator(Substitute.For <IMediator>())
                                                            .Context(new InMemoryContext <StubPerson>(this.entities))
                                                            .Mapper(new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create())),
                                                            e => e.Identifier));

            // act
            var result = await sut.FindAllAsync().AnyContext();

            // assert
            Assert.False(result.IsNullOrEmpty());
            Assert.Equal(21, result.Count());
            Assert.NotNull(result.FirstOrDefault(e => e.Id == "Id99"));
        }
        public async Task FindOneTenantEntity_Test()
        {
            // arrange
            var sut = new RepositorySpecificationDecorator <StubPerson>(
                new Specification <StubPerson>(t => t.TenantId == this.tenantId),
                new InMemoryRepository <StubPerson, StubDb>(o => o
                                                            .Mediator(Substitute.For <IMediator>())
                                                            .Context(new InMemoryContext <StubPerson>(this.entities))
                                                            .Mapper(new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create())),
                                                            e => e.Identifier));

            // act
            var result = await sut.FindOneAsync("Id99").AnyContext();

            // assert
            Assert.NotNull(result);
            Assert.True(result.Id == "Id99");
        }
        public async Task FindAllEntities_Test()
        {
            // arrange
            var sut = new InMemoryRepository <StubPerson, StubDb>(o => o
                                                                  .Mediator(Substitute.For <IMediator>())
                                                                  .Context(new InMemoryContext <StubPerson>(this.entities))
                                                                  .Mapper(new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create())),
                                                                  e => e.Identifier);

            // act
            var result = await sut.FindAllAsync().AnyContext();

            // assert
            Assert.NotNull(result);
            Assert.True(result.All(e => !e.Id.IsNullOrEmpty() && !e.FirstName.IsNullOrEmpty() && !e.LastName.IsNullOrEmpty()));
            Assert.NotNull(result.FirstOrDefault(e => e.FirstName == "John" && e.LastName == "Doe"));
        }
        public async Task FindMappedEntitiesWithSpecification_Test()
        {
            // arrange
            var sut = new InMemoryRepository <StubPerson, StubDb>(o => o
                                                                  .Mediator(Substitute.For <IMediator>())
                                                                  .Context(new InMemoryContext <StubPerson>(this.entities))
                                                                  .Mapper(new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create())),
                                                                  e => e.Identifier);

            // act
            var result = await sut.FindAllAsync(
                new StubHasNameSpecification("John", "Doe"),
                new FindOptions <StubPerson>(orderExpression : e => e.Country)).AnyContext(); // domain layer

            //var result = await sut.FindAllAsync(
            //    new StubHasIdSpecification("Id99")).AnyContext(); // domain layer

            // assert
            Assert.NotNull(result);
            Assert.Single(result);
            Assert.NotNull(result.FirstOrDefault()?.Id);
            Assert.NotNull(result.FirstOrDefault(e => !e.FirstName.IsNullOrEmpty() && !e.LastName.IsNullOrEmpty()));
        }