示例#1
0
            public void GetMobileAvailableRoomsReportCallsCorrectMethodsIsSuccessful()
            {
                // Arrange
                // set up some fake return to test the summary
                DateTime dateRunFor = DateTime.Now;
                List<RoomInventoryCacheAvailable> mockRoomsAvailable = new List<RoomInventoryCacheAvailable>
                                                                       {
                                                                           new RoomInventoryCacheAvailable
                                                                           {
                                                                               BusinessId = BUSINESS_ID,
                                                                               RoomId = FIRST_ROOM_ID,
                                                                               RoomTypeId = FIRST_ROOMTYPE_ID,
                                                                               RoomTypeName = FIRST_ROOMTYPE_NAME
                                                                           },
                                                                           new RoomInventoryCacheAvailable
                                                                           {
                                                                               BusinessId = BUSINESS_ID,
                                                                               RoomId = SECOND_ROOM_ID,
                                                                               RoomTypeId = FIRST_ROOMTYPE_ID,
                                                                               RoomTypeName = FIRST_ROOMTYPE_NAME
                                                                           },
                                                                           new RoomInventoryCacheAvailable
                                                                           {
                                                                               BusinessId = BUSINESS_ID,
                                                                               RoomId = THIRD_ROOM_ID,
                                                                               RoomTypeId = FIRST_ROOMTYPE_ID,
                                                                               RoomTypeName = FIRST_ROOMTYPE_NAME
                                                                           },
                                                                           new RoomInventoryCacheAvailable
                                                                           {
                                                                               BusinessId = BUSINESS_ID,
                                                                               RoomId = FOURTH_ROOM_ID,
                                                                               RoomTypeId = SECOND_ROOMTYPE_ID,
                                                                               RoomTypeName = SECOND_ROOMTYPE_NAME
                                                                           }
                                                                       };

                IRoomInventoryCacheDao mockRICDao = MockRepository.GenerateMock<IRoomInventoryCacheDao>();

                mockRICDao.Expect(
                    dao =>
                    dao.GetRoomInventoryCacheReportForBusinessAndDate(Arg<long>.Is.Equal(BUSINESS_ID),
                                                                      Arg<DateTime>.Is.Equal(dateRunFor),
                                                                      Arg<string>.Is.Equal(UK_CULTURE)))
                          .Return(mockRoomsAvailable)
                          .Repeat.Once();

                ReportingManager manager = new ReportingManager
                                               {
                                                   RoomInventoryCacheDao = mockRICDao
                                               };
                // Act
                MobileAvailableRoomsReport reportResult = manager.GetMobileAvailableRoomsReport(BUSINESS_ID, dateRunFor, UK_CULTURE);
                
                // Assert
                Assert.IsNotNull(reportResult.RoomsAvailable, "Rooms Available was null");
                Assert.IsNotNull(reportResult.Summary, "Summary object was null");
                Assert.IsTrue(reportResult.RoomsAvailable.TrueForAll(ra => ra.BusinessId == BUSINESS_ID),
                              "Business Id did not match that passed in");
                Assert.AreEqual(2, reportResult.Summary.RoomTypes.Count, "Number of room types was not correct");
                Assert.AreEqual(mockRoomsAvailable.Count, reportResult.Summary.TotalRoomsAvailable, "Number of rooms available was not correct");
                Assert.AreEqual(mockRoomsAvailable.Count(ra => ra.RoomTypeId == FIRST_ROOMTYPE_ID),
                                reportResult.Summary.RoomTypes.First(rt => rt.RoomTypeId == FIRST_ROOMTYPE_ID)
                                            .RoomTypeCount,
                                "Number of rooms for the room type did not match the summary for room type 1");
                Assert.AreEqual(mockRoomsAvailable.Count(ra => ra.RoomTypeId == SECOND_ROOMTYPE_ID),
                                reportResult.Summary.RoomTypes.First(rt => rt.RoomTypeId == SECOND_ROOMTYPE_ID)
                                            .RoomTypeCount,
                                "Number of rooms for the room type did not match the summary for room type 2");
                mockRICDao.VerifyAllExpectations();
            }