public void ByName_WithAchievement_ReturnsAchievement() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "Db_ForByName_WithAchievement") .Options; using (var context = new GameInfoContext(options)) { var service = new AchievementsService(context, null); var achievementName = "Redacted"; var achievement = new Achievement() { Name = achievementName, AcquisitionConditions = "Achievement" }; context.Achievements.Add(achievement); context.SaveChanges(); var achievementFromDb = service.ByName(achievementName); Assert.Equal(achievement.Name, achievementFromDb.Name); Assert.Equal(achievement.AcquisitionConditions, achievementFromDb.AcquisitionConditions); } }
public void ByName_WithNoAchievements_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoAchievements_Db_ForByName") .Options; using (var context = new GameInfoContext(options)) { var service = new AchievementsService(context, null); Assert.Null(service.ByName("Non-existing")); } }