예제 #1
0
        public void Test3()
        {
            HotelLogic hotel = new HotelLogic(3, 365);

            List <bool> results = new List <bool>();

            var dates = new List <Tuple <int, int> >(6);

            dates.Add(new Tuple <int, int>(1, 3));
            dates.Add(new Tuple <int, int>(2, 5));
            dates.Add(new Tuple <int, int>(1, 9));
            dates.Add(new Tuple <int, int>(0, 15));

            for (int i = 0; i < dates.Count; i++)
            {
                results.Add(hotel.addReservation(dates[i].Item1, dates[i].Item2));
            }
            List <bool> expected = new List <bool>();

            expected.Add(true);
            expected.Add(true);
            expected.Add(true);
            expected.Add(false);

            if (results.SequenceEqual(expected))
            {
                Assert.Pass("Not all reservations accepted");
            }
            else
            {
                Assert.Fail("All reservation accepted");
            }
        }
예제 #2
0
        public void Test2()
        {
            HotelLogic hotel = new HotelLogic(3, 15);

            bool result = true;

            var dates = new List <Tuple <int, int> >(6);

            dates.Add(new Tuple <int, int>(0, 5));
            dates.Add(new Tuple <int, int>(7, 13));
            dates.Add(new Tuple <int, int>(3, 9));
            dates.Add(new Tuple <int, int>(5, 7));
            dates.Add(new Tuple <int, int>(6, 6));
            dates.Add(new Tuple <int, int>(0, 4));

            for (int i = 0; i < dates.Count; i++)
            {
                result = hotel.addReservation(dates[i].Item1, dates[i].Item2);

                if (!result)
                {
                    break;
                }
            }

            if (result)
            {
                Assert.Pass("All reservation accepted");
            }
            else
            {
                Assert.Fail("Not all reservations accepted");
            }
        }
예제 #3
0
        public void Test1b()
        {
            HotelLogic hotel = new HotelLogic(1, 365);

            var result = hotel.addReservation(200, 400);

            if (!result)
            {
                Assert.Pass("Reservation declined");
            }
            else
            {
                Assert.Fail("Reservation accepted");
            }
        }
예제 #4
0
        public IActionResult Form(Reservation reservation)
        {
            Both both = new Both(2, 15);

            reservation.Accepted = hotelLogic.addReservation(reservation.StartDate, reservation.EndDate);

            hotel.Bookings = hotelLogic.bookings;
            hotel.Size     = hotelLogic.size;
            hotel.Days     = hotelLogic.days;

            both.Reservation = reservation;
            both.Hotel       = hotel;

            return(View("~/Views/Home/Index.cshtml", both));
        }