コード例 #1
0
        ///<summary>
        /// Converts Room/CombinedRoom to RoomDto
        ///</summary>
        ///<param name="room">Room</param>
        ///<returns>RoomDto</returns>
        public static RoomDto ConvertRoomToDto(Room room)
        {
            if (room != null)
            {
                var roomDto = new RoomDto
                {
                    Id = room.Id,
                    Code = room.Code,
                    Name = room.Name,
                    DisplayOrder = room.DisplayOrder,
                    IsCombined = room.IsCombined,
                };

                // Check if the room is combined and populate the list of AssociatedRoomIds
                if (room.IsCombined)
                {
                    roomDto.AssociatedRoomIds = new List<int>();
                    foreach (Room associatedRoom in ((CombinedRoom)room).Rooms)
                    {
                        roomDto.AssociatedRoomIds.Add(associatedRoom.Id);
                    }
                }

                return roomDto;
            }
            return null;
        }
コード例 #2
0
ファイル: CloseoutManagerTest.cs プロジェクト: ognjenm/egle
            public void CreateCloseoutValidBusinessSuccess()
            {
                // Arrange
                var mockCloseoutDao = MockRepository.GenerateMock<ICloseoutDao>();
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();

                Closeout closeout = new Closeout()
                                        {
                                            BusinessId = 1,
                                            RoomId = 1,
                                            StartDate = DateTime.UtcNow,
                                            EndDate = DateTime.UtcNow.AddDays(1),
                                            Description = "Test Closeout",
                                            CloseoutReasonId = 1
                                        };
                mockCloseoutDao.Expect(x => x.Create(closeout)).WhenCalled(delegate { closeout.Id = 1; });
                closeoutManager.CloseoutDao = mockCloseoutDao;

                Room room = new Room()
                                {
                                    Id = 1,
                                    BusinessId = 1,
                                    IsCombined = false,
                                    RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE } 
                                };
                stubRoomDao.Stub(r => r.GetByKey(1, 1)).Return(room);
                closeoutManager.RoomDao = stubRoomDao;

                // Act
                closeoutManager.CreateCloseout(closeout);

                // Assert
                Assert.IsNotNull(closeout.Id, "Id attribute is not populated.");
                mockCloseoutDao.VerifyAllExpectations();
            }
コード例 #3
0
ファイル: RoomManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyRoomExpectSuccessUpdate()
            {
                // Arrange
                var updatedRoom = new Room { Name = "TestUserName", IsAvailableOnline = true, RoomStatusCode = "X", BusinessId = VALID_BUSINESS_ID, Id = VALID_ROOM_ID };
                var mockRoomDao = MockRepository.GenerateMock<IRoomDao>();
                mockRoomDao.Expect(
                    rd =>
                    rd.GetByName(Arg<string>.Is.Equal(updatedRoom.Name), Arg<long>.Is.Equal(updatedRoom.BusinessId)))
                           .Return(new Room {Id = updatedRoom.Id});

                var mockBusinessEventDao = MockRepository.GenerateMock<IEventTrackingManager>();
                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              // booking in past
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(-5),
                                                  StartDate = DateTime.UtcNow.AddDays(-15)
                                              }
                                          });

                mockRoomDao.Expect(rt => rt.Modify(updatedRoom)).Return(true);
                mockBusinessEventDao.Expect(be => be.CreateBusinessEventAsync(VALID_BUSINESS_ID, BusinessEventTypesEnum.RoomModified, updatedRoom.Id.ToString(CultureInfo.DefaultThreadCurrentCulture)));

                var roomManager = new RoomManager
                {
                    RoomDao = mockRoomDao,
                    EventTrackingManager = mockBusinessEventDao,
                    BookingManager = bookingManager
                };

                // Act
                roomManager.Modify(updatedRoom);

                // Assert
                mockRoomDao.VerifyAllExpectations();
                mockBusinessEventDao.VerifyAllExpectations();
                bookingManager.VerifyAllExpectations();
            }
コード例 #4
0
ファイル: AIGIntegratorService.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Create Inventory from Eagle room
        /// </summary>
        /// <param name="room">Room</param>
        /// <param name="roomType"></param>
        /// <returns>AIGInventory object</returns>
        private Inventory CreateInventoryFromRoom(Room room, RoomType roomType)
        {
            var visibility = Visibility.All;

            if (!room.IsAvailableOnline || room.RoomStatusCode != ACTIVE_ROOM_STATUS_CODE)
            {
                visibility = Visibility.Offline;
            }

            var interfaceRoom = new AIGInventory(room.Id.ToGuid(ROOM_PREFIX).ToString(), room.Name, visibility, null)
                                {
                                    InventoryAvailabilityDiaryDateRange = ExtractAndCreateInventoryAvailability(room.Id, roomType)
                                };

            return interfaceRoom;
        }
コード例 #5
0
ファイル: CloseoutManagerTest.cs プロジェクト: ognjenm/egle
            public void CheckCloseoutOver365DaysFails()
            {
                // Arrange
                // Stub the CloseoutDao
                var stubCloseoutDao = MockRepository.GenerateStub<ICloseoutDao>();
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();
                Room room = new Room { BusinessId = 1, Id = 1, RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE } };

                // Configure stubs
                closeoutManager.CloseoutDao = stubCloseoutDao;
                closeoutManager.RoomDao = stubRoomDao;                
                stubCloseoutDao.Stub(c => c.Create(Arg<Closeout>.Is.Anything)).WhenCalled(x => ((Closeout)x.Arguments[0]).Id = 1);
                stubRoomDao.Stub(r => r.GetByKey(Arg<int>.Is.Anything, Arg<long>.Is.Anything)).Return(room);

                // Create closeout longer than 365 days
                Closeout invalidCloseout = new Closeout()
                {
                    BusinessId = 1,
                    RoomId = 1,
                    StartDate = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2016, 1, 3, 0, 0, 0, DateTimeKind.Utc),
                    Description = "Test Closeout",
                    CloseoutReasonId = 1
                };

                try
                {
                    // Act
                    closeoutManager.CreateCloseout(invalidCloseout);

                    // Assert
                    Assert.Fail("Validation Exception SRVEX30029 expected and was not thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30029", ex.Code, "Check that the correct error code has been thrown");
                }
            }
コード例 #6
0
ファイル: CloseoutManagerTest.cs プロジェクト: ognjenm/egle
            public void CheckCloseoutOf365DaysIsValid()
            {
                // Arrange
                // Stub the CloseoutDao
                var stubCloseoutDao = MockRepository.GenerateStub<ICloseoutDao>();
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();
                Room room = new Room { BusinessId = 1, Id = 1, RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE } };

                // Configure stubs
                closeoutManager.CloseoutDao = stubCloseoutDao;
                closeoutManager.RoomDao = stubRoomDao;
                stubCloseoutDao.Stub(c => c.Create(Arg<Closeout>.Is.Anything)).WhenCalled(x => ((Closeout)x.Arguments[0]).Id = 1);
                stubRoomDao.Stub(r => r.GetByKey(Arg<int>.Is.Anything, Arg<long>.Is.Anything)).Return(room);
                                            
                // Create a 365 day closeout
                Closeout validCloseout = new Closeout()
                                             {
                                                 BusinessId = 1,
                                                 RoomId = 1,
                                                 StartDate = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                                                 EndDate = new DateTime(2015, 12, 31, 0, 0, 0, DateTimeKind.Utc),
                                                 Description = "Test Closeout",
                                                 CloseoutReasonId = 1
                                             };

                // Act
                closeoutManager.CreateCloseout(validCloseout);

                // Assert
                Assert.IsNotNull(validCloseout.Id, "Check that an id as been assigned to the closeout which would indicate it was created in the db");
            }
コード例 #7
0
ファイル: RoomManagerTest.cs プロジェクト: ognjenm/egle
            public void DeleteRoomWithForwardBookingsStartDateThrowsException()
            {
                // Arrange
                Room roomToDelete = new Room
                {
                    Id = VALID_ROOM_ID,
                    BusinessId = VALID_BUSINESS_ID,
                    Name = "Name"
                };

                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>
                                          {
                                              new Booking
                                              {
                                                  EndDate = DateTime.UtcNow.AddDays(15),
                                                  StartDate = DateTime.UtcNow.AddDays(5)
                                              }
                                          });

                RoomManager roomManager = new RoomManager
                {
                    BookingManager = bookingManager
                };

                try
                {
                    // Act
                    roomManager.Delete(roomToDelete.Id, roomToDelete.BusinessId);
                    Assert.Fail("Validation exception should have been thrown");
                }
                catch (ValidationException vex)
                {
                    // Assert
                    Assert.AreEqual(Errors.SRVEX30097.ToString(), vex.Code,
                                    "Validation exception SRVEX30097 should have been thrown because of bookings");
                    bookingManager.VerifyAllExpectations();
                }
            }
コード例 #8
0
ファイル: RoomManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyRoomWithExistingNameInBusinessThrowsException()
            {
                // Arrange
                const string EXISTING_ROOM_NAME = "Room A";

                var updatedRoom = new Room { Name = EXISTING_ROOM_NAME, IsAvailableOnline = true, RoomStatusCode = "X", BusinessId = VALID_BUSINESS_ID, Id = VALID_ROOM_ID };
                var mockRoomDao = MockRepository.GenerateMock<IRoomDao>();
                mockRoomDao.Stub(r => r.GetByName(EXISTING_ROOM_NAME, VALID_BUSINESS_ID)).Return(new Model.Room.Room
                    {
                        Id = VALID_ROOM_ID + 1,
                        BusinessId = VALID_BUSINESS_ID,
                        Name = EXISTING_ROOM_NAME,
                        RoomStatusCode = RoomStatusCodes.ACTIVE
                    });
                IBookingManager bookingManager = MockRepository.GenerateMock<IBookingManager>();
                //verify this isn't called
                bookingManager.Expect(bm => bm.GetByRoom(Arg<int>.Is.Equal(VALID_ROOM_ID), Arg<string>.Is.Anything))
                              .Return(new List<Booking>()).Repeat.Never();

                var roomManager = new RoomManager 
                { 
                    RoomDao = mockRoomDao, 
                    BookingManager = bookingManager
                };

                try
                {
                    // Act
                    roomManager.Modify(updatedRoom);

                    // Assert
                    Assert.Fail("An exception SRVEX30085 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30085", ex.Code, "The Validation exception is not returning the right error code");
                    mockRoomDao.VerifyAllExpectations();
                    bookingManager.VerifyAllExpectations();
                }
            }
コード例 #9
0
ファイル: RoomDaoTest.cs プロジェクト: ognjenm/egle
            public void CreateRoomInDatabase()
            {
                // Arrange
                var roomToCreate = new Room
                {
                    Name = "Room 1",
                    BusinessId = 1,
                    IsAvailableOnline = true,
                    IsCombined = false,
                    RoomStatusCode = RoomStatusCodes.ACTIVE,
                    RoomTypeId = 1
                };

                // Act
                roomDao.Create(roomToCreate);

                // Assert
                Room createdRoom = roomDao.GetByKey(roomToCreate.Id, roomToCreate.BusinessId);
                Assert.IsNotNull(createdRoom, "Room hasn't been created in the database");
            }
コード例 #10
0
ファイル: RoomDaoTest.cs プロジェクト: ognjenm/egle
            public void CreatePopulatesRoomId()
            {
                // Arrange
                var roomToCreate = new Room
                {
                    Name = "Room 1",
                    BusinessId = 1,
                    IsAvailableOnline = true,
                    IsCombined = false,
                    RoomStatusCode = RoomStatusCodes.ACTIVE,
                    RoomTypeId = 1
                };

                // Act
                roomDao.Create(roomToCreate);

                // Assert
                Assert.IsTrue(roomToCreate.Id > 0, "Room Id should be greater than 0");
            }