public async void Insert_ValidateOk() { using (var context = new AuthDbContext(CreateNewContextOptions())) { TRepository repo = _baseRepository.GetNewRepository(context); TEntity entity = _baseRepository.GetNewValidEntity(); await repo.InsertAsync(entity); await context.SaveChangesAsync(); Assert.Equal(1, context.Set <TEntity>().Count()); _baseRepository.AssertAllProperties(entity, context.Set <TEntity>().First()); } }
public async void SelectById_ObtainOne() { using (var context = new AuthDbContext(CreateNewContextOptions())) { TRepository repo = _baseRepository.GetNewRepository(context); TEntity entity = _baseRepository.GetNewValidEntity(); await context.Set <TEntity>().AddAsync(entity); await context.SaveChangesAsync(); var entityById = await repo.SelectByIdAsync(entity.GetIds); Assert.NotNull(entityById); _baseRepository.AssertAllProperties(entity, context.Set <TEntity>().First()); } }
public async void Delete_ValidateOk() { using (var context = new AuthDbContext(CreateNewContextOptions())) { TRepository repo = _baseRepository.GetNewRepository(context); TEntity entity = _baseRepository.GetNewValidEntity(); await context.Set <TEntity>().AddAsync(entity); await context.SaveChangesAsync(); repo.Delete(entity); await context.SaveChangesAsync(); Assert.Empty(context.Systems); } }
public async void Update_ValidateOk() { using (var context = new AuthDbContext(CreateNewContextOptions())) { TRepository repo = _baseRepository.GetNewRepository(context); TEntity entity = _baseRepository.GetNewValidEntity(); await context.Set <TEntity>().AddAsync(entity); await context.SaveChangesAsync(); _baseRepository.ChangeNotIdProperties(ref entity); repo.Update(entity); await context.SaveChangesAsync(); _baseRepository.AssertAllProperties(entity, context.Set <TEntity>().First()); } }