1using System.Threading.Tasks;
23 context.Regions.Add(
new Region() { Country =
"NOR", Area =
"OSLO" });
24 context.Regions.Add(
new Region() { Country =
"NOR", Area =
"BERGEN" });
25 await
context.SaveChangesAsync();
41 var res = regionService.GetAllRegions();
44 Assert.NotEmpty(res.Result);
56 var reg =
context.Regions.FindAsync(1).Result.Area;
59 var res = await regionService.GetAllRegions();
62 Assert.Equal(reg, res[0].Area);
63 Assert.Equal(
"BERGEN", res[1].Area);
75 var findIdOne =
context.Regions.FindAsync(1).Result;
78 var res = await regionService.GetAllRegions();
81 Assert.Equal(res[0].Area, findIdOne.Area);
83 findIdOne.Area =
"Tønsberg";
84 regionService.UpdateRegion(findIdOne);
86 var resUpdate = await regionService.GetAllRegions();
89 Assert.Equal(resUpdate[0].Area, findIdOne.Area);
91 Assert.NotEqual(
"BERGEN", resUpdate[0].Area);
RegionService class inserts and updates Region in the Database
RegionService Testing Environment
async void UpdateRegion_FindRegionByIdAndUpdateCity()
Passes if regionlist is notempty and region with id is found and the updated region has new expected ...
async void GetAllRegions_ContainingSameCountry()
Passes if regionlist is not empty after inserting
async void FindRegionById_CityEqualsOsloAndSecondEntryIsBergen()
Passes if retrieving regionlist is not empty and arenames of entries in regionlist is what is expecte...
async Task< DataContext > InsertData(DataContext context)
Inserts two regions into the context
static DataContext GetContext()
Creates a testcontext for testing