コード例 #1
0
        public async Task FindOneTenantEntity_Test()
        {
            // arrange
            var logger   = Substitute.For <ILogger <InMemoryRepository <StubEntity, StubDb> > >();
            var mediator = Substitute.For <IMediator>();
            var sut      = new RepositorySpecificationDecorator <StubEntity>(
                new InMemoryRepository <StubEntity, StubDb>( // decoratee
                    logger,
                    mediator,
                    e => e.Identifier,
                    new InMemoryContext <StubEntity>(this.entities),
                    options: new RepositoryOptions(
                        new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create())),
                    specificationMappers: new[]
            {
                new AutoMapperSpecificationMapper <StubEntity, StubDb>(StubEntityMapperConfiguration.Create())
            }),
                new Specification <StubEntity>(t => t.TenantId == this.tenantId));

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

            // assert
            Assert.NotNull(result);
            Assert.True(result.Id == "Id99");
        }
コード例 #2
0
        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");
        }