public async Task FindAllTenantEntities_Test() // TODO: move to own test class + mocks { // 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.FindAllAsync().AnyContext(); // assert Assert.False(result.IsNullOrEmpty()); Assert.Equal(20, result.Count()); }
public async Task FindAllTenantEntities_Test() // TODO: move to own test class + mocks { // arrange var sut = new RepositorySpecificationDecorator <StubEntityString>( new Specification <StubEntityString>(t => t.TenantId == this.tenantId), new InMemoryRepository <StubEntityString>(o => o .Mediator(Substitute.For <IMediator>()) .Context(new InMemoryContext <StubEntityString>(this.entities)))); // act var result = await sut.FindAllAsync().AnyContext(); // assert Assert.False(result.IsNullOrEmpty()); Assert.Equal(20, result.Count()); }
public async Task FindAllTenantEntities2_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()); }