public void ByName_WithProfession_ReturnsProfession() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "ForByName_WithProfession") .Options; using (var context = new GameInfoContext(options)) { var service = new ProfessionsService(context); var professionName = "Prof Name"; var profession = new Profession() { Name = professionName }; context.Professions.Add(profession); context.SaveChanges(); var professionFromDb = service.ByName(professionName); Assert.Equal(profession.Name, professionFromDb.Name); } }
public void ByName_WithNoProfessions_ReturnsNull() { var options = new DbContextOptionsBuilder <GameInfoContext>() .UseInMemoryDatabase(databaseName: "NoProfessions_ForByName") .Options; using (var context = new GameInfoContext(options)) { var service = new ProfessionsService(context); Assert.Null(service.ByName("Non-existing")); } }