public void Delete_NoData_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoProfessions_ForDelete") .Options; using (var context = new GameInfoContext(options)) { var service = new ProfessionsService(context); Assert.False(service.Delete(2)); } }
public void Delete_WithData_DeletesProfession() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "WithProfession_ForDelete") .Options; using (var context = new GameInfoContext(options)) { context.Professions.Add(new Profession() { Name = "ToDelete" }); context.SaveChanges(); } using (var context = new GameInfoContext(options)) { var service = new ProfessionsService(context); var result = service.Delete(1); Assert.True(result); Assert.Equal(0, context.Professions.Count()); } }