public void ShouldOnlyCreateOneFacetPerStatus()
        {
            _data.Add(new Apprenticeship
            {
                FirstName     = "Pending approval",
                PaymentStatus = PaymentStatus.Active,
                StartDate     = _currentDateTime.Object.Now.AddMonths(1)
            });

            _data.Add(new Apprenticeship
            {
                FirstName     = "Pending approval",
                PaymentStatus = PaymentStatus.Active,
                StartDate     = _currentDateTime.Object.Now.AddMonths(1)
            });

            var result = _sut.BuildFacets(_data, _userQuery, Originator.Provider);

            result.ApprenticeshipStatuses.Count.Should().Be(1);
            AssertStatus(result, ApprenticeshipStatus.WaitingToStart, 1);
            AssertStatus(result, ApprenticeshipStatus.Live, 0);
            AssertStatus(result, ApprenticeshipStatus.Paused, 0);
            AssertStatus(result, ApprenticeshipStatus.Stopped, 0);
            AssertStatus(result, ApprenticeshipStatus.Finished, 0);
        }
Exemple #2
0
        public void ShouldHaveTransferFundedFacetIfAnyApprenticeshipIsTransferFunded(Originator originator)
        {
            _data.Add(new Apprenticeship
            {
                TransferSenderId = 123L
            });

            var result = _sut.BuildFacets(_data, _userQuery, originator);

            Assert.IsNotNull(result.FundingStatuses);
            Assert.AreEqual(1, result.FundingStatuses.Count);
            Assert.AreEqual(FundingStatus.TransferFunded, result.FundingStatuses[0].Data);
        }
Exemple #3
0
        public void ShouldHave3UniqueProviders()
        {
            _data.Add(new Apprenticeship {
                ProviderName = "Abba 365", ProviderId = 006
            });
            _data.Add(new Apprenticeship {
                ProviderName = "Valtech LTD", ProviderId = 007
            });
            _data.Add(new Apprenticeship {
                ProviderName = "Valtech LTD", ProviderId = 007
            });
            _data.Add(new Apprenticeship {
                ProviderName = "Command & Conquer", ProviderId = 008
            });

            var result = _sut.BuildFacets(_data, _userQuery, Originator.Employer);

            result.TrainingProviders.Count.Should().Be(3);
            result.TrainingProviders.Count(m => m.Selected).Should().Be(0);

            result.TrainingProviders.Single(m => m.Data.Id == 006).Data.Name.Should().Be("Abba 365");
            result.TrainingProviders.Single(m => m.Data.Id == 007).Data.Name.Should().Be("Valtech LTD");
            result.TrainingProviders.Single(m => m.Data.Id == 008).Data.Name.Should().Be("Command & Conquer");
        }
        public void ShouldHave2UniqueCourses()
        {
            _data.Add(new Apprenticeship {
                TrainingCode = "2", TrainingName = "Software tester", TrainingType = TrainingType.Standard
            });
            _data.Add(new Apprenticeship {
                TrainingCode = "2", TrainingName = "Software tester", TrainingType = TrainingType.Standard
            });
            _data.Add(new Apprenticeship {
                TrainingCode = "22-166-0", TrainingName = "Fake framework", TrainingType = TrainingType.Framework
            });

            var result = _sut.BuildFacets(_data, _userQuery, Originator.Employer);

            result.TrainingCourses.Count.Should().Be(2);
            result.TrainingCourses.Count(m => m.Selected).Should().Be(0);

            result.TrainingCourses[0]?.Data.Id.Should().Be("2");
            result.TrainingCourses[0]?.Data.Name.Should().Be("Software tester");
            result.TrainingCourses[0]?.Data.TrainingType.Should().Be(TrainingType.Standard);
            result.TrainingCourses[1]?.Data.Id.Should().Be("22-166-0");
            result.TrainingCourses[1]?.Data.Name.Should().Be("Fake framework");
            result.TrainingCourses[1]?.Data.TrainingType.Should().Be(TrainingType.Framework);
        }
        public void ShouldMapChangesPendingIfCallerHasUpdated(Originator caller)
        {
            _data.Add(new Apprenticeship {
                PendingUpdateOriginator = caller
            });
            _data.Add(new Apprenticeship {
                PendingUpdateOriginator = caller
            });

            var result = _sut.BuildFacets(_data, _userQuery, caller);

            AssertStatuses(result, RecordStatus.ChangesPending, 1);
            AssertStatuses(result, RecordStatus.ChangesForReview, 0);
        }
Exemple #6
0
        public async Task <Apprenticeship.ApprenticeshipSearchResponse> GetApprenticeships(long accountId, Apprenticeship.ApprenticeshipSearchQuery query)
        {
            _logger.Trace($"Getting apprenticeships with filter query for employer {accountId}. Page: {query.PageNumber}, PageSize: {query.PageSize}", accountId: accountId);

            var response = await _mediator.SendAsync(new GetApprenticeshipsRequest
            {
                SearchKeyword = query.SearchKeyword,
                Caller        = new Caller
                {
                    CallerType = CallerType.Employer,
                    Id         = accountId
                }
            });

            var apiApprenticeships = _apprenticeshipMapper.MapFrom(response.Apprenticeships, CallerType.Employer).ToList();

            var totalApprenticeshipsBeforeFilter = response.TotalCount - apiApprenticeships.Count(m => m.PaymentStatus == PaymentStatus.PendingApproval);

            var approvedApprenticeships = apiApprenticeships
                                          .Where(m => m.PaymentStatus != PaymentStatus.PendingApproval).ToList();

            _logger.Info($"Searching for {query.SearchKeyword} by Employer {accountId}", accountId: accountId);

            var facets = _facetMapper.BuildFacets(approvedApprenticeships, query, Originator.Employer);
            var filteredApprenticeships = _apprenticeshipFilterService.Filter(approvedApprenticeships, query, Originator.Employer);

            _logger.Info($"Retrieved {approvedApprenticeships.Count} apprenticeships with filter query for employer {accountId}. Page: {query.PageNumber}, PageSize: {query.PageSize}", accountId: accountId);

            return(new Apprenticeship.ApprenticeshipSearchResponse
            {
                Apprenticeships = filteredApprenticeships.PageOfResults,
                SearchKeyword = query.SearchKeyword,
                Facets = facets,
                TotalApprenticeships = filteredApprenticeships.TotalResults,
                TotalApprenticeshipsBeforeFilter = totalApprenticeshipsBeforeFilter,
                PageNumber = filteredApprenticeships.PageNumber,
                PageSize = filteredApprenticeships.PageSize
            });
        }