/// <summary>
 /// Start Hotel Reservation System for Miami
 /// </summary>
 public static void Start()
 {
     ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
     bool cont = true;
     do
     {
         Console.WriteLine("1. Add Hotel\n" +
             "2. Reserve hotel\n" +
             "0. Exit");
         Console.Write("Enter : ");
         string userChoice = Console.ReadLine();
         switch(userChoice)
         {
             case "1":
                 Console.WriteLine("Only Admin can add new hotel to the system\n");
                 break;
             case "2":
                 //TakeUserInputToReserveHotel(reservationSystem);
                 DefaultInputToReserveHotel(reservationSystem);
                 break;
             case "0":
                 cont = false;
                 Console.WriteLine("Thanks for using Hotel Reservation System");
                 break;
             default:
                 Console.WriteLine("Wrong Value Entered");
                 break;
         }
     } while (cont);
 }
Exemplo n.º 2
0
        public void GivenDateRange_ShouldReturn_BestRatedHotelDetails()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            //Act
            string hotelDetail = reservationSystem.FindBestRatedHotel("13Nov2020", "14Nov2020");

            //Assert
            Assert.AreEqual(hotelDetail, "Ridgewood, Total Rates: $370");
        }
Exemplo n.º 3
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");
        }
Exemplo n.º 4
0
        public void GivenDuration_ShouldReturnCheapestHotel()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            //Act
            Hotel hotel = reservationSystem.FindCheapestHotelForNormalCustomer(2, 0).First();

            //Assert
            Assert.AreEqual(hotel, MiamiHotels.HotelList["Lakewood"]);
        }
Exemplo n.º 5
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");
        }
Exemplo n.º 6
0
        public void ReservationSystemBuilder_WhenCalled_ShouldAddThreeHotelsToMiamiHotelList()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem;
            int expected = 3;

            //Act
            reservationSystem = new ReservationSystemBuilder();
            //Assert
            Assert.AreEqual(expected, MiamiHotels.HotelList.Count);
        }
Exemplo n.º 7
0
        public void ReservationSystemBuilder_ShouldAddProperSpecialRate()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem;
            Hotel hotel = new Hotel("Bridgewood", 150, 110, 50, 50, 4);

            //Act
            reservationSystem = new ReservationSystemBuilder();
            //Assert
            Assert.AreEqual(hotel.SpecialNormalRate, MiamiHotels.HotelList["Bridgewood"].SpecialNormalRate);
            Assert.AreEqual(hotel.SpecialWeekendRate, MiamiHotels.HotelList["Bridgewood"].SpecialWeekendRate);
        }
        /// <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");
        }
Exemplo n.º 9
0
        public void GivenWrongMonthValue_ShouldThrowCustomException()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            Exception exception = new Exception();

            //Act
            try
            {
                string hotelDetail = reservationSystem.FindBestRatedHotel("05Navember2020", "05November2020");
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "Incorrect month value");
        }
Exemplo n.º 10
0
        public void GivenIncorrectDateFormat_ShouldThrowCustomException()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            Exception exception = new Exception();

            //Act
            try
            {
                string hotelDetail = reservationSystem.FindBestRatedHotel("SevenNov2020", "NineNov2020");
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "Wrong date format");
        }
Exemplo n.º 11
0
        public void GivenEndDateBeforeStartDate_ShouldThrowCustomException()
        {
            //Arrange
            ReservationSystemBuilder reservationSystem = new ReservationSystemBuilder();
            Exception exception = new Exception();

            //Act
            try
            {
                string hotelDetail = reservationSystem.FindBestRatedHotel("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");
        }