public async Task TestUpdateAllocationRatesRates_NullRequest_RequiredFieldMissingResponse() { UpdateAllocationRatesBaseRequest baseRequest = null; UpdateAllocationRatesRequest request = null; mockChannelManagerRepository.Setup(c => c.UpdateAllocationRates(request)).Returns(Task.FromResult(new BaseResult <bool>())); IActionResult actioResult = await mockChannelManagerController.UpdateAllocationRates(baseRequest); Assert.IsTrue(actioResult is BadRequestObjectResult); var result = actioResult as BadRequestObjectResult; BaseResult <bool> response = result.Value as BaseResult <bool>; Assert.AreEqual(response.ErrorCode, (int)Constants.ErrorCodes.RequiredFieldMissing); Assert.AreEqual(response.Message, string.Format(Constants.ErrorMessage.RequiredFieldMissing, "Hotel Code, Channe manger Id, Room Types and Rate Plans ")); }
public async Task TestUpdateAllocationRatesRatesRequestValidationResponse_Exception_InternalServerError() { UpdateAllocationRatesBaseRequest baseRequest = new UpdateAllocationRatesBaseRequest { UpdateAllocationsValidationRequest = new UpdateAllocationsValidationRequest(), }; baseRequest.UpdateAllocationsRateRequest.Add(new UpdateAllocationRatesRequest()); baseRequest.UpdateAllocationsValidationRequest.HotelCode = "TestCaseForException"; baseRequest.UpdateAllocationsValidationRequest.ChannelManagerId = 1; baseRequest.UpdateAllocationsValidationRequest.RoomTypeRatePlanList.Add(new RoomTypeRatePlan { RatePlanCode = "Test Rate Plan Code", RoomTypeCode = "Test Room Type Code" }); //mockChannelManagerRepository.Setup(m => m.ValidateUpdateAllocationRequest(baseRequest.UpdateAllocationsValidationRequest)).Returns(Task.FromResult(new BaseResult<bool> {Result = false,ExceptionMessage =Common.GetMockException(),IsError = true })); //mockChannelManagerRepository.Setup(c => c.UpdateAllocationRates(baseRequest.UpdateAllocationRatesRequest[0])).Returns(Task.FromResult(new BaseResult<bool>())); IActionResult actioResult = await fakeChannelManagerController.UpdateAllocationRates(baseRequest); //IActionResult actioResult = await channelManagerController.UpdateAllocationRates(baseRequest); Assert.IsTrue(actioResult != null); Assert.AreEqual(((Microsoft.AspNetCore.Mvc.StatusCodeResult)actioResult).StatusCode, 500); }
public async Task TestUpdateAllocationRatesRates_InvalidHotel_InvalidHotelCodeResponse() { UpdateAllocationRatesBaseRequest baseRequest = new UpdateAllocationRatesBaseRequest { UpdateAllocationsValidationRequest = new UpdateAllocationsValidationRequest() }; baseRequest.UpdateAllocationsValidationRequest.HotelCode = "Test Code"; baseRequest.UpdateAllocationsValidationRequest.ChannelManagerId = 1; baseRequest.UpdateAllocationsValidationRequest.RoomTypeRatePlanList.Add(new RoomTypeRatePlan { RatePlanCode = "Test Rate Plan Code", RoomTypeCode = "Test Room Type Code" }); // mockChannelManagerRepository.Setup(c => c.UpdateAllocationRates(request)).Returns(Task.FromResult(new BaseResult<bool>())); // IActionResult actioResult = await mockChannelManagerController.UpdateAllocationRates(baseRequest); IActionResult actioResult = await channelManagerController.UpdateAllocationRates(baseRequest); Assert.IsTrue(actioResult is BadRequestObjectResult); var result = actioResult as BadRequestObjectResult; BaseResult <bool> response = result.Value as BaseResult <bool>; Assert.AreEqual(response.ErrorCode, (int)Constants.ErrorCodes.InvalidHotelCode); Assert.IsTrue(String.Compare(response.Message, string.Format(Constants.ErrorMessage.InvalidHotelCode, baseRequest.UpdateAllocationsValidationRequest.HotelCode), StringComparison.InvariantCultureIgnoreCase) == 0); }