Пример #1
0
        public void GivenStartAndEndDate_ShouldReturnAboutCheapestHotel()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            //Act
            string hotelDetail = reservationSystem.FindHotel("06Nov2020", "08Nov2020");

            //Assert
            Assert.AreEqual(hotelDetail, "Bridgewood, Total Rates: $250");
        }
Пример #2
0
        public void GivenCustomerTypeAsReward_ShouldUseSpecialRates()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            //Act
            string hotelDetail = reservationSystem.FindHotel("13Nov2020", "14Nov2020", "Reward");

            //Assert
            Assert.AreEqual(hotelDetail, "Ridgewood, Total Rates: $140");
        }
Пример #3
0
        public void GivenDateRange_ShouldReturnCheapestBestRatedHotel()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            //Act
            string hotelDetail = reservationSystem.FindHotel("13Nov2020", "14Nov2020");

            //Assert
            Assert.AreEqual(hotelDetail, "Bridgewood, Total Rates: $200");
        }
        /// <summary>
        /// Use default start date and end date
        /// as user input and find cheapest best rated hotel details
        /// </summary>
        private static void DefaultInputToReserveHotel(ReservationSystemBuilder reservationSystem)
        {
            string customerType = "Normal";
            string startDate = "04 December 2020";
            startDate = String.Concat(startDate.Where(c => !Char.IsWhiteSpace(c)));
            string endDate = "07 December 2020";
            endDate = String.Concat(endDate.Where(c => !Char.IsWhiteSpace(c)));

            string sysResponse = reservationSystem.FindHotel(startDate, endDate, customerType);
            Console.WriteLine(sysResponse);
            Console.WriteLine("Enter 'Y' for Confirmation, 'N' for Cancelation ");
            if (Console.ReadLine().ToUpper() == "Y")
                Console.WriteLine("Reservation Successfull :) ");
            else
                Console.WriteLine("Reservation Cancelled");
        }
Пример #5
0
        public void GivenWrongDateValue_ShouldThrowCustomException()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            Exception exception = new Exception();

            //Act
            try
            {
                string hotelDetail = reservationSystem.FindHotel("00Sept2020", "05Sept2020");
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "Incorrect date value");
        }
Пример #6
0
        public void GivenIncorrectDateFormat_ShouldThrowCustomException()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            Exception exception = new Exception();

            //Act
            try
            {
                string hotelDetail = reservationSystem.FindHotel("SevenSept2020", "NineSept2020");
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "Wrong date format");
        }
Пример #7
0
        public void GivenEndDateBeforeStartDate_ShouldThrowCustomException()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            Exception exception = new Exception();

            //Act
            try
            {
                string hotelDetail = reservationSystem.FindHotel("05Nov2020", "03Nov2020");
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "End date can not be before start date");
        }
        /// <summary>
        /// Take start date and end date as user input and find cheapest best rated hotel details
        /// </summary>
        private static void TakeUserInputToReserveHotel(ReservationSystemBuilder reservationSystem)
        {
            Console.WriteLine("Enter\n");

            Console.Write("Customer Type (Regular / Reward) : ");
            string customerType = Console.ReadLine();
            Console.Write("Starting Date : ");
            string startDate = Console.ReadLine();
            startDate = String.Concat(startDate.Where(c => !Char.IsWhiteSpace(c)));
            Console.Write("EndDate Date : ");
            string endDate = Console.ReadLine();
            endDate = String.Concat(endDate.Where(c => !Char.IsWhiteSpace(c)));

            string sysResponse = reservationSystem.FindHotel(startDate,endDate,customerType);
            Console.WriteLine(sysResponse);
            Console.WriteLine("Enter 'Y' for Confirmation, 'N' for Cancelation ");
            if (Console.ReadLine().ToUpper() == "Y")
                Console.WriteLine("Reservation Successfull :) ");
            else
                Console.WriteLine("Reservation Cancelled");
        }