Example #1
0
 /// <summary>
 /// Method to Assert that an AvaialabilitySearchResultDto has the expected Unavailability either for in the top level or in all of its returned room types
 /// </summary>
 /// <param name="actualAvailabilitySearchResult">Actual AvaialabilitySearchResultDto to check</param>
 /// <param name="expectedUnavailability">The expected UnavailibityReaseonDto to match</param>
 public static void AssertUnavailability(AvailabilitySearchResultDto actualAvailabilitySearchResult, UnavailabilityReasonCodeDto expectedUnavailability)
 {
     if (actualAvailabilitySearchResult.BusinessCandidates == null)
     {
         Assert.IsTrue(actualAvailabilitySearchResult.UnavailabilityReasonCode.HasValue, "No unavailability reason code returned");
         Assert.AreEqual(expectedUnavailability, actualAvailabilitySearchResult.UnavailabilityReasonCode.Value,
             "Unavailability reason code did not match expected");
     }
     else
     {
         foreach (AvailabilityResultBusinessDto business in actualAvailabilitySearchResult.BusinessCandidates)
         {
             foreach (AvailabilityResultRoomTypeDto roomType in business.RoomTypes)
             {
                 Assert.IsTrue(roomType.UnAvailabilityReasonCode.HasValue, "Reason code not set for roomType " + roomType.RoomTypeId);
                 Assert.AreEqual(expectedUnavailability, roomType.UnAvailabilityReasonCode.Value, "Unavailability reason code for roomType " +
                                 roomType.RoomTypeId + " was not set correctly");
             }
         }
     }
 }
        /// <summary>
        /// Convert the AvailabilitySearchResult Date Model to the Dto Object
        /// </summary>
        /// <param name="availabilitySearchResult">AvailabilitySearchResult to convert</param>
        /// <returns>AvailabilitySearchResultDto</returns>
        public static AvailabilitySearchResultDto ConvertAvailabilitySearchResultToDto(AvailabilitySearchResult availabilitySearchResult)
        {
            // Convert the main object
            var availabilitySearchResultDto = new AvailabilitySearchResultDto
            {
                StartDate = ConvertCalendarDateToDto(availabilitySearchResult.StartDate),
                EndDate = ConvertCalendarDateToDto(availabilitySearchResult.EndDate),
                NoOfAdults = availabilitySearchResult.NoOfAdults,
                NoOfChildren = availabilitySearchResult.NoOfChildren
            };

            if (availabilitySearchResult.BusinessCandidates != null)
            {
                // Convert the sub objects
                availabilitySearchResultDto.BusinessCandidates = availabilitySearchResult.BusinessCandidates.ConvertAll(ConvertAvailabilityResultBusinessToDto);
            }

            availabilitySearchResultDto.UnavailabilityReasonCode = (UnavailabilityReasonCodeDto?)availabilitySearchResult.UnavailabilityReasonCode;
            return availabilitySearchResultDto;
        }