예제 #1
0
        public async Task TestGetRoomTypesAndRatePlans_InvalidHotel_InvalidHotelCodeResponse()
        {
            RoomTypeByHotelAndChannelManger request = new RoomTypeByHotelAndChannelManger
            {
                HotelCode        = "Test Code",
                ChannelManagerId = 1
            };
            //  mockChannelManagerRepository.Setup(c => c.GetRoomTypesAndRatePlans(request)).Returns(Task.FromResult(new BaseResult<List<RoomTypesRatePlan>>()));
            //mockChannelManagerRepository.Setup(a => a.ValidateRoomTypeRatePlanRequest(request)).Returns(Task.FromResult(new BaseResult<bool> { ErrorCode=101}));
            IActionResult actioResult = await channelManagerController.GetRoomTypesAndRatePlans(request);

            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, request.HotelCode), StringComparison.InvariantCultureIgnoreCase) == 0);
        }
예제 #2
0
        public async Task TestGetRoomTypesAndRatePlans_NullRequest_RequiredFieldMissingResponse()
        {
            RoomTypeByHotelAndChannelManger request = null;

            mockChannelManagerRepository.Setup(c => c.GetRoomTypesAndRatePlans(request)).Returns(Task.FromResult(new BaseResult <List <RoomTypeRatePlanResponse> >()));
            IActionResult actioResult = await mockChannelManagerController.GetRoomTypesAndRatePlans(request);

            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 Manager Id "));
        }