Exemplo n.º 1
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();
            }