Пример #1
0
        public void WhenMappingLevelAggregation()
        {
            MappingService mappingService    = new MappingService(null);
            var            searchResultItem1 = new ApprenticeshipSearchResultsItem
            {
                StandardId = "101",
                Title      = "Standard 1"
            };

            var resultList = new List <ApprenticeshipSearchResultsItem> {
                searchResultItem1
            };
            var levels = new Dictionary <int, long?> {
                { 2, 3L }, { 3, 38L }, { 4, 380L }
            };
            var model = new ApprenticeshipSearchResponse {
                TotalResults = 1234L, SearchTerm = "apprenticeship", Results = resultList, AggregationLevel = levels, SelectedLevels = new List <int> {
                    2
                }
            };

            var mappedResult = mappingService.Map <ApprenticeshipSearchResponse, ApprenticeshipSearchResultViewModel>(model);

            mappedResult.AggregationLevel.Count().Should().Be(3);
            mappedResult.AggregationLevel.FirstOrDefault(m => m.Value == "2")?.Checked.Should().BeTrue();
            mappedResult.AggregationLevel.FirstOrDefault(m => m.Value == "3")?.Checked.Should().BeFalse();

            mappedResult.AggregationLevel.FirstOrDefault(m => m.Value == "4")?.Count.Should().Be(380);
        }
Пример #2
0
        public ApprenticeshipSearchResultsItem Map(SFADASApprenticeshipsApiTypesV3ApprenticeshipSearchResultsItem document)
        {
            if (document != null)
            {
                var item = new ApprenticeshipSearchResultsItem
                {
                    Id            = document.Id,
                    FrameworkName = document.FrameworkName,
                    Duration      = document.Duration,
                    EffectiveFrom = document.EffectiveFrom,
                    EffectiveTo   = document.EffectiveTo,
                    Level         = document.Level,
                    Published     = document.Published,
                    PathwayName   = document.PathwayName,
                    Title         = document.Title,
                    Keywords      = document.Keywords?.Any() == true?document.Keywords.ToList() : null,

                                        JobRoles = document.JobRoles?.Any() == true?document.JobRoles.ToList() : null,
                                                       ApprenticeshipType = document.ProgrammeType == SFADASApprenticeshipsApiTypesV3ApprenticeshipSearchResultsItem.ProgrammeTypeEnum.NUMBER_0 ? ApprenticeshipType.Framework : ApprenticeshipType.Standard
                };
                return(item);
            }

            return(null);
        }
Пример #3
0
        public ApprenticeshipItemViewModel Map(ApprenticeshipSearchResultsItem source)
        {
            var item = new ApprenticeshipItemViewModel()
            {
                Id                 = source.Id,
                Title              = source.Title,
                Level              = source.Level,
                Duration           = source.Duration,
                EffectiveTo        = source.EffectiveTo,
                ApprenticeshipType = source.ApprenticeshipType
            };

            return(item);
        }
Пример #4
0
        public void Setup()
        {
            _sut = new ApprenticeshipItemViewModelMapper();

            _cssClassMock = new Mock <ICssViewModel>();

            _itemToMap = new ApprenticeshipSearchResultsItem()
            {
                Duration             = 24,
                Id                   = "123-30-20",
                Title                = "Apprenticeship Title",
                Level                = 4,
                LastDateForNewStarts = DateTime.Today.AddYears(1),
                EffectiveTo          = DateTime.Today.AddYears(1),
                ApprenticeshipType   = ApprenticeshipType.Framework
            };
        }
Пример #5
0
        public void WhenMappingLevelAggregationIsNull()
        {
            MappingService mappingService    = new MappingService(null);
            var            searchResultItem1 = new ApprenticeshipSearchResultsItem
            {
                StandardId = "101",
                Title      = "Standard 1"
            };

            var resultList = new List <ApprenticeshipSearchResultsItem> {
                searchResultItem1
            };
            var model = new ApprenticeshipSearchResponse {
                TotalResults = 1234L, SearchTerm = "apprenticeship", Results = resultList, AggregationLevel = null, SelectedLevels = new List <int> {
                    2
                }
            };

            var mappedResult = mappingService.Map <ApprenticeshipSearchResponse, ApprenticeshipSearchResultViewModel>(model);

            mappedResult.AggregationLevel.Count().Should().Be(0);
        }
        public void WhenLevelIsMapped(int level, string expected)
        {
            MappingService mappingService = new MappingService(null);

            var apprenticeshipResult = new ApprenticeshipSearchResultsItem
            {
                FrameworkId   = "1",
                Level         = level,
                FrameworkName = "Framework name",
                PathwayName   = "Pathway name",
                JobRoles      = new List <string> {
                    "Job role"
                },
                Keywords = new List <string> {
                    "Keyword"
                },
                Title = "Title"
            };

            var viewModel = mappingService.Map <ApprenticeshipSearchResultsItem, ApprenticeshipSearchResultItemViewModel>(apprenticeshipResult);

            viewModel.Level.Should().Be(expected);
        }