/// <summary> /// Return the list of RateTypes /// </summary> /// <returns>RateTypeList</returns> public async Task <IActionResult> GetRateType() { BaseResult <List <RateTypeViewModel> > rateTypeResultFromCache = new BaseResult <List <RateTypeViewModel> >() { Result = RedisCacheHelper.Instance.Get <List <RateTypeViewModel> >(Constants.CacheKeys.RateTypeList) }; if (rateTypeResultFromCache.Result == null || rateTypeResultFromCache.Result.Count == 0) { BaseResult <List <RateType> > rateTypeResult = await iPayment.GetRateType().ConfigureAwait(false); if (rateTypeResult.IsError && rateTypeResult.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (rateTypeResult.Result == null || rateTypeResult.Result.Count == 0) { return(NoContent()); //204 } else { var result = PaymentDataResponseMapper.MapRateType(rateTypeResult); RedisCacheHelper.Instance.Set <List <RateTypeViewModel> >(Constants.CacheKeys.RateTypeList, result.Result); return(Ok(result)); //200 } } return(Ok(rateTypeResultFromCache)); //200 }
public async Task TestGetRateType_Positive_Predicate() { //Arrange var rateType = new RateType() { Id = 1, Name = "Net", IsActive = true, IsDeleted = false, NameItemId = 1 }; var baseResult = new BaseResult <List <RateType> >() { Result = new List <RateType>() { rateType } }; var pred = new Func <RateType, bool>(x => x.IsActive && !x.IsDeleted); iRateTypeLibrary.Setup(x => x.GetListByPredicate(It.Is <Func <RateType, bool> >(y => y.GetType() == pred.GetType()))).Returns(Task.FromResult(baseResult)); //Act Task <BaseResult <List <RateType> > > result = paymentDataRepository.GetRateType(); //Assert Assert.IsTrue(result.Result != null); Assert.IsTrue(result.Result is BaseResult <List <RateType> >); }