Ejemplo n.º 1
0
        public async Task WhenZeroStandardsAreRetrievedFromApprenticeshipsApi_UpsertApprenticeshipProgrammesReferencedataThrowInfrastuctureException()
        {
            _mockStandardsClient
            .Setup(x => x.GetAllAsync())
            .ReturnsAsync(Enumerable.Empty <StandardSummary>());

            _mockFrameworksClient
            .Setup(x => x.GetAllAsync())
            .ReturnsAsync(new [] { _frameworkOne });

            Func <Task> asyncFunction = async() => { await _sut.UpdateApprenticeshipProgrammesAsync(); };

            (await asyncFunction.Should().ThrowAsync <InfrastructureException>()).WithMessage("Retrieved 0 standards from the apprenticeships api.");
        }
        public async Task WhenZeroStandardsAreRetrievedFromApprenticeshipsApi_UpsertApprenticeshipProgrammesReferencedataThrowInfrastuctureException()
        {
            _mockOuterApiClient
            .Setup(x => x.Get <GetTrainingProgrammesResponse>(It.IsAny <GetTrainingProgrammesRequest>()))
            .ReturnsAsync(new GetTrainingProgrammesResponse
            {
                TrainingProgrammes = new List <GetTrainingProgrammesResponseItem> {
                    _frameworkOne
                }
            });


            Func <Task> asyncFunction = async() => { await _sut.UpdateApprenticeshipProgrammesAsync(); };

            (await asyncFunction.Should().ThrowAsync <InfrastructureException>()).WithMessage("Retrieved 0 standards from the apprenticeships api.");
        }
        public async Task Handle(UpdateApprenticeshipProgrammesCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Updating Apprenticeship Programmes Reference Data");

            await _updaterService.UpdateApprenticeshipProgrammesAsync();

            _logger.LogInformation("Updated Apprenticeship Programmes Reference Data");
        }
        public async Task WhenRemappingFromStandards_ShouldSetEducationLevelNumber(int level)
        {
            _standardOne.Level  = level;
            _frameworkOne.Level = level;

            _mockStandardsClient
            .Setup(x => x.GetAllAsync())
            .ReturnsAsync(new[] { _standardOne });

            _mockFrameworksClient
            .Setup(x => x.GetAllAsync())
            .ReturnsAsync(new[] { _frameworkOne });

            ApprenticeshipProgrammesReferenceData updatedData = null;

            _mockReferenceDataWriter
            .Setup(x => x.UpsertReferenceData(It.IsAny <ApprenticeshipProgrammesReferenceData>()))
            .Callback <ApprenticeshipProgrammesReferenceData>(x => updatedData = x)
            .Returns(Task.CompletedTask);

            await _sut.UpdateApprenticeshipProgrammesAsync();

            Assert.True(updatedData.Data.All(x => x.EducationLevelNumber == level));
        }