Пример #1
0
        public HttpResponseMessage SearchHotels(SearchCriteria searchhotel)
        {
            //Checking whether the object searchhotel is null
            if (searchhotel == null)
            {
                //if the searchhotel is null ArgumentNullException will be thrown
                return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "Search Fields Values Cannot be Null"));
            }

            //Calling GetHotelDetails method in Business Layer by passing searchhotel parameter which returns list

            List <Output> output = bookMyRoomManager.GetHotelDetails(searchhotel);

            //Checking whether the output is null
            if (output.Count > -1)
            {
                return(new HttpResponseMessage {
                    Content = new ObjectContent(typeof(List <Output>), output, GlobalConfiguration.Configuration.Formatters.JsonFormatter)
                });
            }
            else
            {
                // If the output is negative It will be InternalServerError
                throw new DivideByZeroException("InternalServerError");
            }
        }
Пример #2
0
        public void BookMyRoom_RoomSearch_CorrectDetails()
        {
            //Arrange
            BookMyRoomManager booking = new BookMyRoomManager();
            SearchCriteria    search  = new SearchCriteria();

            search.hotelCity     = "Kolkata";
            search.hotelFromDate = DateTime.Now;
            search.hotelToDate   = Convert.ToDateTime("09/09/ 2018");
            search.hotelRoomType = "Single";

            //Act
            List <Output> response = booking.GetHotelDetails(search);

            //Assert
            Assert.AreEqual(0, response.Count);
        }