public void TestDelete() { var expectDate = DateTime.UtcNow; var entities = CreateMockedListExposureKeys(expectDate, 2); using DigNDB_SmittestopContext context = CreatePopulatedContext(entities); var genericRepository = new GenericRepository <TemporaryExposureKey>(context); var firstEntity = entities.First(); context.Entry(firstEntity).State = EntityState.Detached; context.SaveChanges(); genericRepository.Delete(firstEntity); context.SaveChanges(); var retrievedEntity = genericRepository.GetById(firstEntity.Id); Assert.AreEqual(retrievedEntity, null); }
public void Edit(T entity) { _dbSet.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }