public async Task GetCorrectCountNumberDbContext() { var options = new DbContextOptionsBuilder <PhotographyAddictedContext>() .UseInMemoryDatabase(databaseName: "Find_User_Database") .Options; var dbContext = new PhotographyAddictedContext(options); dbContext.Add(new PhotographyAddictedUser() { Id = "blq" }); dbContext.Add(new PhotographyAddictedUser()); dbContext.Add(new PhotographyAddictedUser()); await dbContext.SaveChangesAsync(); dbContext.PhotographyAddictedUsers.Add(new PhotographyAddictedUser()); await dbContext.SaveChangesAsync(); var opit = dbContext.PhotographyAddictedUsers.FirstOrDefault(c => c.Id == "blq"); //dbContext.Remove(opit); //await dbContext.SaveChangesAsync(); var repository = new DbRepository <PhotographyAddictedUser>(dbContext); //PhotographyAddictedUser opitProba = new PhotographyAddictedUser() {Id = "veche" }; //repository.Update(opit,opitProba); //await repository.SaveChangesAsync(); var service = new UserService(repository); var count = service.GetUsersCount(); Assert.Equal(4, count); //Assert.Equal(2,service.GetSpecificUser(2).Count()); }
public DbRepository(PhotographyAddictedContext context) { this.context = context; this.dbSet = this.context.Set <TEntity>(); }