private static void RemovePeople() { IList <Person> peopleToDelete; using (var db = new AbsenceManagementContext()) { db.Database.Log = Console.WriteLine; var pplRepo = new EFDisconnectedPersonRepository(db); var peopleToDeleteIds = GetPeople().Select(p => p.DataSourceId); peopleToDelete = pplRepo.GetAll().Where(p => peopleToDeleteIds.Contains(p.DataSourceId)).ToList(); } using (var db = new AbsenceManagementContext()) { db.Database.Log = Console.WriteLine; var pplRepo = new EFDisconnectedPersonRepository(db); foreach (var personToDelete in peopleToDelete) { pplRepo.Delete(personToDelete); } } // NOTE: deleting could very well be done by going off to a stored procedure, // because retrieving and then doing another query for deletion // seems a bit much // Depends on the scenario }
public void Can_Delete_WithId() { using (var ctx = EFTestData.GetPersistentAbsenceManagentContext()) { // Arrange var sut = new EFDisconnectedPersonRepository(ctx); var userId = sut.GetAll().FirstOrDefault().Id; // Act sut.Delete(userId); var user = ctx.People.FirstOrDefault(p => p.Id.Equals(userId)); // Assert Assert.Null(user); } }