public void RemoveSetting() { var logger = new Mock <ILogger <RoleClaimRepository> >(); var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options; context.Database.EnsureDeleted(); using (var dbContext = new CacidbContext(options)) { dbContext.RoleClaim.Add(new RoleClaim { RoleClaimId = 1 }); dbContext.SaveChanges(); } using (var dbContext = new CacidbContext(options)) { RoleClaimRepository repository = new RoleClaimRepository(dbContext, logger.Object); var caseOne = repository.Get().ToList().Where(m => m.RoleClaimId == 1).FirstOrDefault(); bool result = repository.Delete(caseOne); Assert.AreEqual(true, result); List <RoleClaim> cases = repository.Get().ToList(); Assert.AreEqual(0, cases.Count); } }
public void GetRoleClaim() { var logger = new Mock <ILogger <RoleClaimRepository> >(); // test Get All RoleClaimRepository repository = new RoleClaimRepository(context, logger.Object); List <RoleClaim> cases = repository.Get().ToList(); Assert.AreEqual(3, cases.Count); }