public async Task ThenWillReturnCurrentSelectedPage(
            [Frozen] GetApprenticeshipsQuery query,
            List <Apprenticeship> apprenticeships,
            ApprenticeshipSearchResult searchResult,
            [Frozen] Mock <IProviderCommitmentsDbContext> mockContext,
            [Frozen] Mock <IApprenticeshipSearch> mockSearch,
            [Frozen] Mock <IMapper <Apprenticeship, GetApprenticeshipsQueryResult.ApprenticeshipDetails> > mockMapper,
            GetApprenticeshipsQueryHandler handler)
        {
            query.SortField   = "test";
            query.ReverseSort = true;
            query.ProviderId  = null;

            apprenticeships[1].Cohort.EmployerAccountId = query.EmployerAccountId.Value;

            mockSearch.Setup(x => x.Find(It.IsAny <ReverseOrderedApprenticeshipSearchParameters>()))
            .ReturnsAsync(new ApprenticeshipSearchResult
            {
                Apprenticeships = apprenticeships
            });

            mockContext
            .Setup(context => context.Apprenticeships)
            .ReturnsDbSet(new List <Apprenticeship>());

            mockSearch.Setup(x => x.Find(It.IsAny <ReverseOrderedApprenticeshipSearchParameters>()))
            .ReturnsAsync(searchResult);

            var result = await handler.Handle(query, CancellationToken.None);

            Assert.AreEqual(searchResult.PageNumber, result.PageNumber);
        }
Exemplo n.º 2
0
 private ApprenticeshipSummary GetApprenticeshipSummary(ApprenticeshipSearchResult result)
 {
     return(new ApprenticeshipSummary
     {
         DistanceInMiles = result.Distance,
         AnonymousEmployerName = result.AnonymousEmployerName,
         ApprenticeshipLevel = result.ApprenticeshipLevel.ToString(),
         Category = result.Category,
         CategoryCode = result.CategoryCode,
         ClosingDate = result.ClosingDate,
         Description = result.Description,
         EmployerName = result.EmployerName,
         FrameworkLarsCode = result.FrameworkLarsCode,
         HoursPerWeek = result.HoursPerWeek,
         Id = result.Id,
         IsDisabilityConfident = result.IsDisabilityConfident,
         IsEmployerAnonymous = result.IsEmployerAnonymous,
         IsPositiveAboutDisability = result.IsPositiveAboutDisability,
         Location = new Domain.Entities.GeoPoint {
             Lat = result.Location.lat, Lon = result.Location.lon
         },
         NumberOfPositions = result.NumberOfPositions,
         PostedDate = result.PostedDate,
         ProviderName = result.ProviderName,
         Ukprn = result.Ukprn,
         StandardLarsCode = result.StandardLarsCode,
         StartDate = result.StartDate,
         SubCategory = result.SubCategory,
         SubCategoryCode = result.SubCategoryCode,
         Title = result.Title,
         VacancyLocationType = result.VacancyLocationType.ToString(),
         VacancyReference = result.VacancyReference,
         WageAmount = result.WageAmount,
         WageAmountLowerBound = result.WageAmountLowerBound,
         WageAmountUpperBound = result.WageAmountUpperBound,
         WageText = result.WageText,
         WageType = result.WageType,
         WageUnit = result.WageUnit,
         WorkingWeek = result.WorkingWeek
     });
 }
        public async Task ThenWillGetSearchHandler(
            [Frozen] Mock <IApprenticeshipSearchService <ApprenticeshipSearchParameters> > service,
            [Frozen] Mock <IServiceProvider> serviceProvider,
            ApprenticeshipSearchParameters searchParameters,
            ApprenticeshipSearch search)
        {
            //Arrange
            var expectedResult = new ApprenticeshipSearchResult();

            serviceProvider.Setup(x =>
                                  x.GetService(It.IsAny <Type>()))
            .Returns(service.Object);

            service.Setup(x => x.Find(searchParameters))
            .ReturnsAsync(expectedResult);

            //Act
            var result = await search.Find(searchParameters);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 4
0
        public async Task ThenReturnsPageNumber(
            [Frozen] GetApprenticeshipsQuery query,
            List <Apprenticeship> apprenticeships,
            ApprenticeshipSearchResult searchResult,
            [Frozen] Mock <IProviderCommitmentsDbContext> mockContext,
            [Frozen] Mock <IApprenticeshipSearch> search,
            GetApprenticeshipsQueryHandler handler)
        {
            query.SortField         = "";
            query.EmployerAccountId = null;

            apprenticeships[1].Cohort.ProviderId = query.ProviderId ?? 0;

            search.Setup(x => x.Find(It.IsAny <ApprenticeshipSearchParameters>()))
            .ReturnsAsync(searchResult);

            mockContext
            .Setup(context => context.Apprenticeships)
            .ReturnsDbSet(apprenticeships);

            var result = await handler.Handle(query, CancellationToken.None);

            result.PageNumber.Should().Be(searchResult.PageNumber);
        }