public void ReturnPeriod()
        {
            // Arranje
            DateTime startDate = new DateTime(2020, 03, 15);
            DateTime endDate   = new DateTime(2020, 03, 18);

            // Act
            List <DateTime> dates = DateCommonService.GetPeriod(startDate, endDate);

            // Assert
            Assert.Equal(DateCommonService.GetPeriod(startDate, endDate), dates);
        }
Ejemplo n.º 2
0
 public void ReturnIfIsOrNotIsWeekend(bool isWeekend, string date)
 {
     // Assert
     Assert.Equal(isWeekend, DateCommonService.IsWeekend(DateTime.Parse(date)));
 }
Ejemplo n.º 3
0
        private static void StartHotelReservation()
        {
            try
            {
                // Welcome
                Console.WriteLine("Welcome to Hotel Reservation");
                Console.WriteLine();

                // Client type
                string inputClientType;
                do
                {
                    Console.WriteLine("Hello, what is your customer profile? (1 to REGULAR and 2 to FIDELIDADE)");
                    inputClientType = Console.ReadLine();
                } while (!inputClientType.Equals("1") && !inputClientType.Equals("2"));
                ClientType clientType = inputClientType.Equals("1") ? ClientType.Regular : ClientType.Fidelidade;

                // Period: start date
                string   inputStartDate;
                DateTime startDate;
                do
                {
                    Console.WriteLine("Enter the start date: (DD/MM/YYYY)");
                    inputStartDate = Console.ReadLine();
                } while (!inputStartDate.IsDateTime(out startDate));


                // Period: end date
                string   inputEndDate;
                DateTime endDate;
                do
                {
                    Console.WriteLine("Enter the end date: (DD/MM/YYYY)");
                    inputEndDate = Console.ReadLine();
                } while (!inputEndDate.IsDateTime(out endDate));

                // Verify best hotel
                ITariffService tariffService = Service.GetService <ITariffService>();
                Tariff         bestTariff    = tariffService.GetBestTariff(clientType, DateCommonService.GetPeriod(startDate, endDate));

                // Output
                Console.WriteLine($"The cheapest hotel is {bestTariff.Hotel.Name}");
                Console.WriteLine($"The price is R$ {bestTariff.Price}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message} - InnserException: {ex.InnerException.Message}");
            }
        }