コード例 #1
0
        public void GivenDateRange_FindCheapestHotelInAGivenDateRangeMethod_ShouldReturnCheapestHotelForRegularcustomer()
        {
            DateTime start    = DateTime.Parse("12Nov2020");
            DateTime end      = DateTime.Parse("14Nov2020");
            string   expected = "Lakewood";

            ManageHotels hotelManager = new ManageHotels(CustomerType.REGULAR);

            hotelManager.AddHotel(new Hotel("Lakewood", 110, 90, 80, 80, 3));
            hotelManager.AddHotel(new Hotel("Bridgewood", 160, 60, 110, 150, 4));
            hotelManager.AddHotel(new Hotel("Ridgewood", 220, 150, 100, 40, 5));
            List <Hotel> cheapestHotels = hotelManager.FindCheapestHotelInAGivenDateRange(start, end);

            Assert.AreEqual(expected, cheapestHotels[0].name);
        }
コード例 #2
0
        public void GivenDateRange_FindCheapestHotelInAGivenDateRangeMethod_ShouldReturnAllAvailableCheapestHotelsForRegularcustomer()
        {
            DateTime start = DateTime.Parse("12Nov2020");
            DateTime end   = DateTime.Parse("14Nov2020");

            string[] expected = { "Lakewood", "Ridgewood" };

            ManageHotels hotelManager = new ManageHotels(CustomerType.REGULAR);

            hotelManager.AddHotel(new Hotel("Lakewood", 110, 90, 80, 80, 3));
            hotelManager.AddHotel(new Hotel("Bridgewood", 160, 60, 110, 150, 4));
            hotelManager.AddHotel(new Hotel("Ridgewood", 110, 90, 100, 40, 5));
            List <Hotel> cheapestHotelsList = hotelManager.FindCheapestHotelInAGivenDateRange(start, end);

            string[] cheapestHotelsArray = cheapestHotelsList.Select(hotel => hotel.name).ToArray();

            CollectionAssert.AreEqual(expected, cheapestHotelsArray);
        }