Exemplo n.º 1
0
        public void SslamSearchRequest_WhenMappedToPagedSearchRequest_CorrectlyAssignsSearchParameterValuesToSearchRequestParameterObjects()
        {
            // ARRANGE
            var settingsContainer = DIOptionsHelper.SetupOptionsContainerBuilder();
            var searchRequest     = MockSearchRequests.GetGoalsSearchRequestWithSlaRecordVolumeAndStateOfCalifornia();

            // ACT
            using (var scope = settingsContainer.BeginLifetimeScope())
            {
                var optionsSnapshot     = scope.Resolve <IOptions <SslamPagedSearchSettings> >();
                var sslamSearchSettings = optionsSnapshot.Value;

                var mappedSearchRequest = Mapper.Map <PagedSearchRequest>(sslamSearchSettings);

                // assign searchRequest values to the matching Parameter object Value properties
                MapSearchRequestToPagedSearchRequestParameters.MapSearchRequest(searchRequest, mappedSearchRequest);

                // ASSERT

                foreach (PropertyInfo propertyInfo in searchRequest.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var propertyName         = propertyInfo.Name;
                        var pagedSearchParameter = mappedSearchRequest.Parameters.Find(p =>
                                                                                       string.Equals(p.Name.ToLower(), propertyName.ToLower()));

                        if (pagedSearchParameter != null)
                        {
                            Assert.True(((IComparable)pagedSearchParameter.Value).CompareTo((IComparable)propertyInfo.GetValue(searchRequest)) == 0, "Search Request value and Paged Search Parameter value match.");
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private PagedSearchRequest MapSearchRequestToPagedSearchRequest(SslamPagedSearchSettings pagedSearchSettings, SslamSearchRequest searchRequest)
        {
            var mappedSearchRequest = AutoMapper.Mapper.Map <PagedSearchRequest>(pagedSearchSettings);

            // assign searchRequest values to the matching Parameter object Value properties
            MapSearchRequestToPagedSearchRequestParameters.MapSearchRequest(searchRequest, mappedSearchRequest);

            return(mappedSearchRequest);
        }