public void Update_Country_By_Id() { var countryToSave = new Country(); countryToSave.Name = "sarasa"; countryToSave.Id = 1; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Update_Country") .Options; using (var context = new ApplicationDbContext(options)) { var service = new CountriesService(context); service.AddCountry(countryToSave); var countrySaved = service.GetCountryById(1); countrySaved.Name = "updatedName"; service.UpdateCountry(countrySaved); Assert.Equal("updatedName", service.GetCountryById(1).Name); } }
public void Get_Country_By_Id() { var countryToSave = new Country(); countryToSave.Name = "sarasa"; countryToSave.Id = 1; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Delete_Country_By_Id") .Options; using (var context = new ApplicationDbContext(options)) { var service = new CountriesService(context); service.AddCountry(countryToSave); Assert.NotNull(service.GetCountryById(1)); } }