public async Task <ActionResult <MealType> > GetById(string id) { var mealType = await _mealTypeService.GetByIdAsync(id); if (mealType == null) { return(NotFound()); } return(Ok(mealType)); }
public async Task GetById_RetunsAMealType() { var mealType = GetSampleMealType(1); using (var context = new MSLunchesContext(GetDbOptions("GetById_RetunsAMealType"))) { context.MealTypes.Add(mealType); context.SaveChanges(); } MealType result; using (var context = new MSLunchesContext(GetDbOptions("GetById_RetunsAMealType"))) { var classUnderTest = new MealTypeService(context); result = await classUnderTest.GetByIdAsync(mealType.Id); } Assert.Equal(mealType.Id, result.Id); }