Exemple #1
0
 public Room AssignGuestToRoom(Guest guest, string roomNumber)
 {
     VerifyGuest(guest);
     Room room = GetRoomByRoomNumber(roomNumber);
     room.Guest = guest;
     return room;
 }
        public void CheckinTo10X10_first()
        {
            // Arrange
            var resolver = new InterfaceResolver();
            resolver.Register<IRoomAccess, RoomAccess>();
            var roomAccess = resolver.Resolve<IRoomAccess>();

            roomAccess.GenerateBasicHotel(10, 10, 1);

            IReservingEngine service = new ReservingEngine(resolver);

            var newGuest = new Guest(fname: "New", lname: "Guest");

            // Act
            Room x = service.PerformAutoCheckin(newGuest);

            // Assert
            Assert.AreEqual("1,1,1", x.Location.ToString());
        }
Exemple #3
0
        public Room PerformAutoCheckin(Guest newGuest)
        {
            Room bestRoom = null;
            using (var transaction = new TransactionScope()) {
                using (var roomAccess = _ioc.Resolve<IRoomAccess>()) {
                    List<Room> emptyList = roomAccess.GetAllEmptyRooms();
                    if (emptyList.Count <= 0) {
                        throw new FaultException("No vacancy, cannot checkin guest");
                    }

                    List<Room> filledList = roomAccess.GetAllAssignedRooms();

                    if (filledList.Count == 0) {
                        bestRoom = GetPreferredInitialRoom(emptyList);
                    } else {
                        bestRoom = GetFurthestEmptyRoom(emptyList, filledList);
                    }

                    return roomAccess.AssignGuestToRoom(newGuest, bestRoom.RoomNumber);
                }
            }
        }
        public void PerformCheckinToFullHotel()
        {
            // Arrange
            var resolver = new InterfaceResolver();
            resolver.Register<IRoomAccess, RoomAccess>();
            var roomAccess = resolver.Resolve<IRoomAccess>();

            roomAccess.GenerateBasicHotel(1, 2, 1);

            var guest1 = new Guest(fname: "Some", lname: "Body");
            string roomNumber1 = roomAccess.GetRoomNumbers()[0];
            roomAccess.AssignGuestToRoom(guest1, roomNumber1);

            var guest2 = new Guest(fname: "Noone", lname: "Special");
            string roomNumber2 = roomAccess.GetRoomNumbers()[1];
            roomAccess.AssignGuestToRoom(guest2, roomNumber2);

            IReservingEngine service = new ReservingEngine(resolver);

            var newGuest = new Guest(fname: "New", lname: "Guest");

            // Act
            Room x = service.PerformAutoCheckin(newGuest);

            // Assert
            Assert.Fail("Expected Exception was not thrown");
        }
        public void PerformCheckin()
        {
            // Arrange
            var resolver = new InterfaceResolver();
            resolver.Register<IRoomAccess, RoomAccess>();
            var roomAccess = resolver.Resolve<IRoomAccess>();

            roomAccess.GenerateBasicHotel(8, 2, 4);

            var guest1 = new Guest(fname: "Some", lname: "Body");
            string roomNumber1 = roomAccess.GetRoomNumbers()[4];
            roomAccess.AssignGuestToRoom(guest1, roomNumber1);

            var guest2 = new Guest(fname: "Noone", lname: "Special");
            string roomNumber2 = roomAccess.GetRoomNumbers()[3];
            roomAccess.AssignGuestToRoom(guest2, roomNumber2);

            IReservingEngine service = new ReservingEngine(resolver);

            var newGuest = new Guest(fname: "New", lname: "Guest");

            // Act
            Room x = service.PerformAutoCheckin(newGuest);

            // Assert
            Assert.AreEqual("8,1,1", x.Location.ToString());
        }
Exemple #6
0
 public void UnassignGuestFromRoom(Guest guest, string roomNumber)
 {
     VerifyGuest(guest);
     Room room = GetRoomByRoomNumber(roomNumber);
     if (!IsSpecifiedGuestInRoom(guest, room)) {
         throw new FaultException("Guest is not checked into room");
     }
     room.Guest = null;
 }
Exemple #7
0
 protected void VerifyGuest(Guest guest)
 {
     if (guest == null) {
         throw new FaultException("No guest provided");
     }
     if (guest.FirstName.Trim() == "" && guest.LastName.Trim() == "") {
         throw new FaultException("Guests must have a name");
     }
 }
Exemple #8
0
 protected bool IsSpecifiedGuestInRoom(Guest guest, Room room)
 {
     if (guest.FirstName == room.Guest.FirstName && guest.LastName == room.Guest.LastName) {
         return true;
     }
     return false;
 }