public void NearestVacentRoomTestForFirstRoomVacant()
        {
            char[,] array =
            {
                { 'A', 'b', 'c', 'd', 'e' },
                { 'e', 'd', 'c', 'b', 'a' },
                { 'a', 'b', 'c', 'd', 'e' },
                { 'e', 'd', 'c', 'b', 'a' }
            };

            var result = new BoutiqueHotel().FindNearestVacantRoom(array);

            Assert.AreEqual("1-A", $"{result.floor}-{result.room}");
        }
        public void NearestVacentRoomTestForDiffrentFloorAndRooms()
        {
            char[,] array =
            {
                { 'a', 'b', 'c', 'd', 'e', 'f' },
                { 'f', 'e', 'd', 'c', 'b', 'a' },
                { 'a', 'b', 'c', 'd', 'e', 'F' },
                { 'f', 'e', 'd', 'c', 'b', 'A' },
                { 'a', 'b', 'C', 'D', 'e', 'f' },
                { 'f', 'E', 'd', 'c', 'b', 'A' }
            };

            var result = new BoutiqueHotel().FindNearestVacantRoom(array);

            Assert.AreEqual("3-F", $"{result.floor}-{result.room}");
        }
Esempio n. 3
0
        public void CheckRoomAvailabilityTestForAlreadyOccupy()
        {
            char[,] array =
            {
                { 'A', 'b', 'C', 'd', 'e' },
                { 'e', 'D', 'c', 'b', 'a' },
                { 'a', 'b', 'c', 'd', 'e' },
                { 'E', 'd', 'c', 'b', 'A' }
            };

            var hotel = new BoutiqueHotel();
            var room  = new RoomNumber()
            {
                floor = 3, room = 'E'
            };
            var isCheckIn = hotel.CheckRoomAvailability(array, room);

            Assert.AreEqual(false, isCheckIn);
        }
        public void FindAllAvailableRoomTestForSomeVacantRooms()
        {
            char[,] array =
            {
                { 'A', 'b', 'c', 'd', 'e' },
                { 'e', 'D', 'c', 'b', 'A' },
                { 'a', 'B', 'c', 'd', 'e' },
                { 'e', 'd', 'c', 'B', 'a' }
            };

            //char[,] array = {
            //    { 'a', 'b', 'c', 'd', 'e','f' },
            //    { 'f', 'e', 'd', 'c', 'b','a' },
            //    { 'a', 'b', 'c', 'd', 'e','F' },
            //    { 'f', 'e', 'd', 'c', 'b','A' },
            //    { 'a', 'b', 'c', 'D', 'e','f' },
            //    { 'f', 'E', 'd', 'c', 'b','A' }};
            var hotel  = new BoutiqueHotel();
            var result = hotel.FindAllAvailableRoom(array).ToList();

            Assert.AreEqual(5, result.Count);
        }
        public void BoutiqueHotelTestForMultipleCheckInOut()
        {
            char[,] array =
            {
                { 'a', 'b', 'c', 'd', 'e' },
                { 'e', 'D', 'c', 'b', 'A' },
                { 'a', 'B', 'c', 'd', 'e' },
                { 'e', 'd', 'c', 'B', 'a' }
            };

            //char[,] array = {
            //    { 'a', 'b', 'c', 'd', 'e','f' },
            //    { 'f', 'e', 'd', 'c', 'b','a' },
            //    { 'a', 'b', 'c', 'd', 'e','F' },
            //    { 'f', 'e', 'd', 'c', 'b','A' },
            //    { 'a', 'b', 'c', 'D', 'e','f' },
            //    { 'f', 'E', 'd', 'c', 'b','A' }};
            var hotel    = new BoutiqueHotel();
            var roomOut1 = new RoomNumber()
            {
                floor = 1, room = 'D'
            };

            // CheckOut the guest.
            hotel.RoomCheckOut(array, roomOut1);
            //when the guest checkout verify the room availability.
            var isAvailableOut1 = hotel.CheckRoomAvailability(array, roomOut1);

            Assert.AreEqual(true, isAvailableOut1);

            //Get the nearest available room
            var nearestRoom1 = hotel.FindNearestVacantRoom(array);

            // checkIn the guest.
            hotel.RoomCheckIn(array, nearestRoom1);
            //when the guestcheckIn verify the room availability.
            var isAvailable1 = hotel.CheckRoomAvailability(array, nearestRoom1);

            Assert.AreEqual(false, isAvailable1);

            var roomOut2 = new RoomNumber()
            {
                floor = 4, room = 'A'
            };

            hotel.RoomCheckOut(array, roomOut2);
            var isAvailableOut2 = hotel.CheckRoomAvailability(array, roomOut2);

            Assert.AreEqual(true, isAvailableOut2);


            var nearestRoom2 = hotel.FindNearestVacantRoom(array);

            hotel.RoomCheckIn(array, nearestRoom2);
            var isAvailable2 = hotel.CheckRoomAvailability(array, nearestRoom2);

            Assert.AreEqual(false, isAvailable2);

            //After all the guest checkout ,check all the available rooms.
            var result = hotel.FindAllAvailableRoom(array).ToList();

            Assert.AreEqual(4, result.Count);
        }