public void Delete_NoData_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoAchievements_Db_ForDelete") .Options; using (var context = new GameInfoContext(options)) { var service = new AchievementsService(context, null); Assert.False(service.Delete(2)); } }
public void Delete_WithData_DeletesAchievement() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "Db_WithAchievements_ForDelete") .Options; using (var context = new GameInfoContext(options)) { context.Achievements.Add(new Achievement() { Name = "ToDelete", AcquisitionConditions = "None" }); context.SaveChanges(); } using (var context = new GameInfoContext(options)) { var service = new AchievementsService(context, null); var result = service.Delete(1); Assert.True(result); Assert.Equal(0, context.Achievements.Count()); } }