Example #1
0
        public async Task TestUpdateAllocations_NullRequest_RequiredFieldMissingResponse()
        {
            UpdateAllocationBaseRequest baseRequest = null;
            UpdateAllocationsRequest    request     = null;

            mockChannelManagerRepository.Setup(c => c.UpdateAllocations(request)).Returns(Task.FromResult(new BaseResult <bool>()));
            IActionResult actioResult = await mockChannelManagerController.UpdateAllocations(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 "));
        }
Example #2
0
        public async Task TestUpdateAllocationsRequestValidationResponse_Exception_InternalServerError()
        {
            UpdateAllocationBaseRequest baseRequest = new UpdateAllocationBaseRequest
            {
                UpdateAllocationsValidationRequest = new UpdateAllocationsValidationRequest(),
            };

            baseRequest.UpdateAllocationsRequest.Add(new UpdateAllocationsRequest());
            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.UpdateAllocations(baseRequest.UpdateAllocationsRequest[0])).Returns(Task.FromResult(new BaseResult<bool>()));
            IActionResult actioResult = await fakeChannelManagerController.UpdateAllocations(baseRequest);

            //IActionResult actioResult = await channelManagerController.UpdateAllocations(baseRequest);
            Assert.IsTrue(actioResult != null);
            Assert.AreEqual(((Microsoft.AspNetCore.Mvc.StatusCodeResult)actioResult).StatusCode, 500);
        }
Example #3
0
        public async Task TestUpdateAllocations_InvalidHotel_InvalidHotelCodeResponse()
        {
            UpdateAllocationBaseRequest baseRequest = new UpdateAllocationBaseRequest
            {
                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.UpdateAllocations(request)).Returns(Task.FromResult(new BaseResult<bool>()));
            //  IActionResult actioResult = await mockChannelManagerController.UpdateAllocations(baseRequest);
            IActionResult actioResult = await channelManagerController.UpdateAllocations(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);
        }