Exemple #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();
            }   
Exemple #2
0
            public void GetMobileReportsCallsMethodsCorrectlyReturnsOnlyConfirmed()
            {
                // Arrange
                var reportDaoMock = MockRepository.GenerateMock<IReportBookingDao>();
                var dictMock = MockRepository.GenerateMock<IDictionaryManager>();

                var mockBookings = new List<Booking>
                {
                    new Booking
                    {
                        BusinessId = VALID_BUSINESS_ID,
                        CurrencyCode = UK_CURRENCY,
                        CurrencySymbol = UK_CURRENCY_SYMBOL,
                        BookingStatusCode = BookingStatusType.CONFIRMED
                    }
                };

                var mockReportRequest = new ReportingBookingRequest
                {
                    BusinessId = VALID_BUSINESS_ID,
                    CultureCode = UK_CULTURE,
                    StartDate = DateTime.Now.Date,
                    EndDate = DateTime.Now.Date,
                    ReportingBookingType = ReportingBookingTypeEnum.StayDate
                };
                
                reportDaoMock.Expect(rd => rd.GetBookingReport(Arg<ReportingBookingRequest>.Is.Anything)).Return(mockBookings)
                             .Repeat.Once();

                dictMock.Expect(
                    dm => dm.GetRootCultureForGivenCultureCode(Arg<string>.Is.Equal(mockReportRequest.CultureCode)))
                        .Return(ROOT_CULTURE)
                        .Repeat.Once();

                dictMock.Expect(
                    dm =>
                    dm.GetDictionaryItemByKeysAndCultures(
                        Arg<List<string>>.Matches(l => l.Contains(DictionaryConstants.NOT_KNOWN_KEY)),
                        Arg<List<string>>.Matches(lc => lc.Contains(ROOT_CULTURE)))).Return(new List<DictionaryDataItem>
                        {
                            new DictionaryDataItem
                            {
                                DictionaryInstances = new List<DictionaryInstance>
                                {
                                    new DictionaryInstance
                                    {
                                        Content = "translatedText",
                                        CultureCode = ROOT_CULTURE
                                    }
                                }
                            }
                        }).Repeat.Once();

                var reportManager = new ReportingManager
                {
                    DictionaryManager = dictMock,
                    ReportBookingDao = reportDaoMock
                };

                // Act
                var resultReport = reportManager.GetMobileBookingReports(mockReportRequest);

                // Assert
                Assert.IsNotNull(resultReport, "report was returned as null");
                Assert.IsNotNull(resultReport.Bookings, "Bookings were returned as null");
                Assert.AreEqual(1, resultReport.Bookings.Count, "Cancelled bookings were returned with report");
                Assert.IsNotNull(resultReport.BookingSummary, "Booking Summary was returned as null");
                Assert.AreNotEqual(string.Empty, resultReport.Bookings.First().NotKnownText,
                                   "Not known text was not set");

                dictMock.VerifyAllExpectations();
                reportDaoMock.VerifyAllExpectations();
            }