public async Task TestGetHotelMeal_positive_Predicate_sample() { //Arrange int hotelId = 5; var hotelMeal = new HotelMeal() { Id = 1, HotelId = 5, MealId = 1, Price = 1000, CurrencyId = 7, IsDeleted = false }; var baseResult = new BaseResult <List <HotelMeal> >() { Result = new List <HotelMeal>() { hotelMeal } }; var pred = new Func <HotelMeal, bool>(x => x.HotelId == hotelMeal.HotelId && !x.IsDeleted); iHotelMealConnectionLibrary.Setup(x => x.GetListByPredicate(It.Is <Func <HotelMeal, bool> >(y => y.GetType() == pred.GetType()))).Returns(Task.FromResult(baseResult)); //Act Task <BaseResult <List <HotelMeal> > > result = mealPlanRepository.GetHotelMeal(hotelId); //Assert Assert.IsTrue(result.Result != null); Assert.IsTrue(result.Result is BaseResult <List <HotelMeal> >); }
public async Task <IActionResult> GetIsMealPlanExist([FromBody] int hotelId) { if (hotelId > default(int)) { BaseResult <bool> isMealPlanExist = new BaseResult <bool>(); BaseResult <List <HotelMeal> > hotelMealResult = await iMealPlan.GetHotelMeal(hotelId).ConfigureAwait(false); if (hotelMealResult.IsError && hotelMealResult.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (hotelMealResult.Result == null || hotelMealResult.Result.Count == 0) { return(Ok(isMealPlanExist)); //204 } isMealPlanExist.Result = true; return(Ok(isMealPlanExist)); //200 } return(BadRequest()); //400 }