/// <summary>
 /// Returns the SearchResultDto containing the data of the given SearchResult
 /// </summary>
 /// <param name="searchResult">SearchResult to convert</param>
 /// <returns>Converted SearchResultDto</returns>
 public static SearchResultDto ConvertSearchResultToDto(SearchResult searchResult)
 {
     var resultDto = new SearchResultDto();
     resultDto.Customers = new List<CustomerDto>();
     resultDto.Bookings = new List<BookingDto>();
     if (searchResult.Customers != null)
     {
         resultDto.Customers = searchResult.Customers.ConvertAll(ConvertCustomerToDto);
     }
     if (searchResult.Bookings != null)
     {
         resultDto.Bookings = searchResult.Bookings.ConvertAll(ConvertBookingToDto);
     }
     return resultDto;
 }
Пример #2
0
            public void SearchBookingsCallsCorrectMethodsIsSuccessful()
            {
                //Arrange
                var searchManager = MockRepository.GenerateMock<ISearchManager>();
                pmsMobile.SearchManager = searchManager;

                var userManager = MockRepository.GenerateMock<IUserManager>();
                pmsMobile.UserManager = userManager;

                var searchResult = new SearchResult
                {
                    Bookings = new List<Booking>{ 
                                                                            new Booking{Id = 1}, 
                                                                            new Booking{Id = 2}
                                                                        },
                    Guests = new List<Guest>()
                };
                searchManager.Expect(s => s.FindGuestsAndBookings(Arg<long>.Is.Equal(BUSINESS_ID), Arg<string>.Is.Equal(SEARCH_CRITERIA),
                                                                  Arg<int>.Is.Equal(MAX_SEARCH_RESULTS), Arg<bool>.Is.Equal(false),
                                                                  Arg<bool>.Is.Equal(true), 
                                                                  Arg<string>.Is.Anything,
                                                                  Arg<string>.Is.Anything)).Repeat.Once().Return(searchResult);

                userManager.Expect(u => u.GetByUserName(Arg<string>.Is.Anything)).Return(new User { Extension = new UserExtension { PrimaryBusinessId = BUSINESS_ID, CultureCode = "en-GB" }, UserName = string.Empty });


                //Make sure business is present
                CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID);

                //Invalidate the cache so we make sure our business is loaded into the cache
                Cache.Business.Invalidate();

                //Act
                var results = pmsMobile.SearchBookings(BUSINESS_ID, SEARCH_CRITERIA);

                //Assert
                userManager.VerifyAllExpectations();
                searchManager.VerifyAllExpectations();
                Assert.AreEqual(searchResult.Bookings.Count, results.Bookings.Count, "Converted result count didn't match search result count");

                //Clear cached business
                CacheHelper.ReAssignBusinessDaoToBusinessCache();
            }