public async Task ShouldRemovePendingApprovalFromTotalCount()
        {
            MockMediator.Setup(m => m.SendAsync(It.IsAny <GetApprenticeshipsRequest>()))
            .ReturnsAsync(new GetApprenticeshipsResponse {
                Apprenticeships = new List <Domain.Entities.Apprenticeship>
                {
                    new Domain.Entities.Apprenticeship {
                        PaymentStatus = PaymentStatus.Active
                    },
                    new Domain.Entities.Apprenticeship {
                        PaymentStatus = PaymentStatus.PendingApproval
                    }
                },
                TotalCount = 50
            });
            MockApprenticeshipFilter.Setup(m =>
                                           m.Filter(It.IsAny <IList <Types.Apprenticeship.Apprenticeship> >(), It.IsAny <ApprenticeshipSearchQuery>(), Originator.Employer))
            .Returns <IList <Types.Apprenticeship.Apprenticeship>, ApprenticeshipSearchQuery, Originator>((aps, q, o) => new FilterResult(2, aps.ToList(), 1, 25));

            var result = await Orchestrator.GetApprenticeships(1L, new ApprenticeshipSearchQuery());

            MockMediator.Verify(m => m.SendAsync(It.IsAny <GetApprenticeshipsRequest>()), Times.Once);
            MockFacetMapper.Verify(m => m.BuildFacets(It.IsAny <IList <Types.Apprenticeship.Apprenticeship> >(), It.IsAny <ApprenticeshipSearchQuery>(), Originator.Employer), Times.Once);
            MockApprenticeshipFilter.Verify(m => m.Filter(It.IsAny <IList <Types.Apprenticeship.Apprenticeship> >(), It.IsAny <ApprenticeshipSearchQuery>(), Originator.Employer), Times.Once);

            result.Apprenticeships.Count().Should().Be(1);
            result.TotalApprenticeships.Should().Be(2);
            result.TotalApprenticeshipsBeforeFilter.Should().Be(49);
        }
Beispiel #2
0
        public async Task ShouldCallGetFacetAndMapper()
        {
            MockMediator.Setup(m => m.SendAsync(It.IsAny <GetApprenticeshipsRequest>()))
            .ReturnsAsync(new GetApprenticeshipsResponse
            {
                Apprenticeships = new List <Domain.Entities.Apprenticeship>()
            });

            var result = await Orchestrator.GetApprenticeships(1L, new ApprenticeshipSearchQuery());

            MockMediator.Verify(m => m.SendAsync(It.IsAny <GetApprenticeshipsRequest>()), Times.Once);
            MockFacetMapper.Verify(m => m.BuildFacets(It.IsAny <IList <Types.Apprenticeship.Apprenticeship> >(), It.IsAny <ApprenticeshipSearchQuery>(), Originator.Provider), Times.Once);
            MockApprenticeshipFilter.Verify(m => m.Filter(It.IsAny <IList <Types.Apprenticeship.Apprenticeship> >(), It.IsAny <ApprenticeshipSearchQuery>(), Originator.Provider), Times.Once);

            result.Apprenticeships.Count().Should().Be(0);
        }