public void ById_WithAchievement_ReturnsAchievement() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "Db_ForById_WithAchievement") .Options; using (var context = new GameInfoContext(options)) { var service = new AchievementsService(context, null); var achievementToAdd = new Achievement() { Name = "Achievement", AcquisitionConditions = "Redacted" }; context.Achievements.Add(achievementToAdd); context.SaveChanges(); var achievementFromDb = service.ById(1); Assert.Equal(achievementToAdd.Name, achievementFromDb.Name); Assert.Equal(achievementToAdd.AcquisitionConditions, achievementFromDb.AcquisitionConditions); } }
public void ById_WithNoAchievements_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoAchievements_Db_ForById") .Options; using (var context = new GameInfoContext(options)) { var service = new AchievementsService(context, null); Assert.Null(service.ById(1)); } }