public async Task Test_GetRestaurantsListByUserAndPostCodeAsync_When_justEatIntegrationService_FinishCorrect_RestarauntDataIsNotNull_Result_NoError()
        {
            //Arrange
            DeliveryDetailsInfoRequest input = new DeliveryDetailsInfoRequest {
                UserData = new UserCredentials()
            };

            _justEatRepositoryMock.Mock_GetSettings_CustomReturn(new JustEatIntegrationSettings
            {
                RestaurantsRequestType = "POST"
            });

            _justEatIntegrationServiceMock.Mock_GetRestaurantDetailsByUserAndPostcode_CustomReturn(new JustEatRestarauntResponseData
            {
                Restaurants = new List <RestaurantShortDetails>(),
                Errors      = null
            });

            //Act
            DeliveryDetailsInfoResponse result = await _restaurantService.GetRestaurantsListByUserAndPostCodeAsync(input);

            //Arrange
            Assert.NotNull(result);
            Assert.Null(result.Error);
            Assert.NotNull(result.Restaurants);
            Assert.IsType <DeliveryDetailsInfoResponse>(result);
        }
コード例 #2
0
        public async Task <IActionResult> GetRestaurantsDeliveryDataByPostCode(string username, string password, string postcode)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(postcode))
                {
                    //log
                    return(BadRequest(new ResponseWrapper <object>
                    {
                        Result = null,
                        Error = new ErrorData
                        {
                            Message = CommonConstants.ErrorMessage_CheckInputData,
                            Token = ErrorTokens.WrongInput.ToString()
                        }
                    }));
                }

                DeliveryDetailsInfoResponse result = await _restaurantService.GetRestaurantsListByUserAndPostCodeAsync(new DeliveryDetailsInfoRequest
                {
                    Postcode = postcode,
                    UserData = new UserCredentials
                    {
                        UserName = username,
                        Password = password
                    }
                });

                if (result != null)
                {
                    return(Ok(new ResponseWrapper <DeliveryDetailsResponse>
                    {
                        Result = new DeliveryDetailsResponse
                        {
                            Restaurants = result.Restaurants
                        },
                        Error = result.Error
                    }));
                }
                else
                {
                    //log
                    return(BadRequest(new ResponseWrapper <object>
                    {
                        Result = null,
                        Error = new ErrorData
                        {
                            Message = CommonConstants.ErrorMessage_UnsuccessfulFinish,
                            Token = ErrorTokens.NullResponse.ToString()
                        }
                    }));
                }
            }
            catch (Exception)
            {
                // log ex
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
コード例 #3
0
 public RestaurantServiceMock Mock_GetRestaurantsListByUserAndPostCodeAsyns_CustomReturn(DeliveryDetailsInfoResponse deliveryDetailsInfoResponse)
 {
     Setup(x => x.GetRestaurantsListByUserAndPostCodeAsync(It.IsAny <DeliveryDetailsInfoRequest>()))
     .ReturnsAsync(deliveryDetailsInfoResponse);
     return(this);
 }