Пример #1
0
        public override void Given()
        {
            var expectedStage2Response = new List <AssessmentCsvRecordResponse>
            {
                new AssessmentCsvRecordResponse {
                    RowNum = 1, Uln = 1111111111, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022"
                },
                new AssessmentCsvRecordResponse {
                    RowNum = 2, Uln = 1111111112, SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023"
                },
                new AssessmentCsvRecordResponse {
                    RowNum = 3, Uln = 1111111113, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022", SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023"
                }
            };

            expectedStage3Response = new List <AssessmentRecordResponse>
            {
                new AssessmentRecordResponse {
                    TqRegistrationPathwayId = 1, PathwayAssessmentSeriesId = 11
                },
                new AssessmentRecordResponse {
                    TqRegistrationSpecialismId = 2, SpecialismAssessmentSeriesId = 22
                },
                new AssessmentRecordResponse {
                    TqRegistrationPathwayId = 3, PathwayAssessmentSeriesId = 33, TqRegistrationSpecialismId = 333, SpecialismAssessmentSeriesId = 3333
                }
            };

            var csvResponse = new CsvResponseModel <AssessmentCsvRecordResponse> {
                Rows = expectedStage2Response
            };
            var expectedWriteFileBytes = new byte[5];

            BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File")));
            CsvService.ReadAndParseFileAsync(Arg.Any <AssessmentCsvRecordRequest>()).Returns(csvResponse);
            AssessmentService.ValidateAssessmentsAsync(AoUkprn, Arg.Any <IEnumerable <AssessmentCsvRecordResponse> >()).Returns(expectedStage3Response);
            CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes);

            var transformationResponse = GetTransformAssessmentsModel();

            AssessmentService.TransformAssessmentsModel(expectedStage3Response, Arg.Any <string>()).Returns(transformationResponse);

            var assessmentsProcessResult = new AssessmentProcessResponse {
                IsSuccess = true
            };

            AssessmentService.CompareAndProcessAssessmentsAsync(transformationResponse.Item1, transformationResponse.Item2).
            Returns(assessmentsProcessResult);
        }
        public async Task <AssessmentProcessResponse> CompareAndProcessAssessmentsAsync(IList <TqPathwayAssessment> pathwayAssessmentsToProcess, IList <TqSpecialismAssessment> specialismAssessmentsToProcess)
        {
            var response = new AssessmentProcessResponse();

            // Prepare Pathway Assessments
            var newOrAmendedPathwayAssessmentRecords = await PrepareNewAndAmendedPathwayAssessments(pathwayAssessmentsToProcess);

            // Prepare Specialism Assessments
            var newOrAmendedSpecialismAssessmentRecords = await PrepareNewAndAmendedSpecialismAssessments(specialismAssessmentsToProcess);

            // Process Assessments
            response.IsSuccess = await _assessmentRepository.BulkInsertOrUpdateAssessments(newOrAmendedPathwayAssessmentRecords, newOrAmendedSpecialismAssessmentRecords);

            return(response);
        }
        public async Task Then_Expected_Assessments_Are_Created()
        {
            // when
            await _bulkAssessmentsTestFixture.WhenAsync();

            // then
            _result = _bulkAssessmentsTestFixture.Result;
            _result.Should().NotBeNull();
            _result.IsSuccess.Should().BeTrue();

            foreach (var uln in _bulkAssessmentsTestFixture.Ulns)
            {
                var expectedRegistrationProfile = _bulkAssessmentsTestFixture.TqRegistrationProfilesData.FirstOrDefault(p => p.UniqueLearnerNumber == uln);
                var registrationPathway         = expectedRegistrationProfile.TqRegistrationPathways.First();
                var expectedPathwayAssessment   = _bulkAssessmentsTestFixture.TqPathwayAssessmentsData.FirstOrDefault(p => p.TqRegistrationPathwayId == registrationPathway.Id);

                var actualPathwayAssessment = _bulkAssessmentsTestFixture.DbContext.TqPathwayAssessment.FirstOrDefault(x => x.TqRegistrationPathwayId == registrationPathway.Id && x.IsOptedin && x.EndDate == null);

                // assert registration profile data
                actualPathwayAssessment.Should().NotBeNull();
                actualPathwayAssessment.TqRegistrationPathwayId.Should().Be(expectedPathwayAssessment.TqRegistrationPathwayId);
                actualPathwayAssessment.AssessmentSeriesId.Should().Be(expectedPathwayAssessment.AssessmentSeriesId);
                actualPathwayAssessment.IsOptedin.Should().Be(expectedPathwayAssessment.IsOptedin);
                actualPathwayAssessment.IsBulkUpload.Should().Be(expectedPathwayAssessment.IsBulkUpload);
                actualPathwayAssessment.StartDate.ToShortDateString().Should().Be(expectedPathwayAssessment.StartDate.ToShortDateString());
                actualPathwayAssessment.CreatedBy.Should().Be(expectedPathwayAssessment.CreatedBy);

                var registrationSpecialism       = registrationPathway.TqRegistrationSpecialisms.First();
                var expectedSpecialismAssessment = _bulkAssessmentsTestFixture.TqSpecialismAssessmentsData.FirstOrDefault(p => p.TqRegistrationSpecialismId == registrationSpecialism.Id);
                var actualSpecialismAssessment   = _bulkAssessmentsTestFixture.DbContext.TqSpecialismAssessment.FirstOrDefault(x => x.TqRegistrationSpecialismId == registrationSpecialism.Id && x.IsOptedin && x.EndDate == null);

                // assert registration profile data
                actualSpecialismAssessment.Should().NotBeNull();
                actualSpecialismAssessment.TqRegistrationSpecialismId.Should().Be(expectedSpecialismAssessment.TqRegistrationSpecialismId);
                actualSpecialismAssessment.AssessmentSeriesId.Should().Be(expectedSpecialismAssessment.AssessmentSeriesId);
                actualSpecialismAssessment.IsOptedin.Should().Be(expectedSpecialismAssessment.IsOptedin);
                actualSpecialismAssessment.IsBulkUpload.Should().Be(expectedSpecialismAssessment.IsBulkUpload);
                actualSpecialismAssessment.StartDate.ToShortDateString().Should().Be(expectedSpecialismAssessment.StartDate.ToShortDateString());
                actualSpecialismAssessment.CreatedBy.Should().Be(expectedSpecialismAssessment.CreatedBy);
            }
        }
 public async Task WhenAsync()
 {
     Result = await AssessmentService.CompareAndProcessAssessmentsAsync(TqPathwayAssessmentsData, TqSpecialismAssessmentsData);
 }
Пример #5
0
        private async Task <BulkAssessmentResponse> ProcessAssessmentsResponse(BulkProcessRequest request, BulkAssessmentResponse response, AssessmentProcessResponse assessmentsProcessResult)
        {
            _ = assessmentsProcessResult.IsSuccess ? await MoveFileFromProcessingToProcessedAsync(request) : await MoveFileFromProcessingToFailedAsync(request);
            await CreateDocumentUploadHistory(request, assessmentsProcessResult.IsSuccess?DocumentUploadStatus.Processed : DocumentUploadStatus.Failed);

            response.IsSuccess = assessmentsProcessResult.IsSuccess;
            response.Stats     = assessmentsProcessResult.BulkUploadStats;
            return(response);
        }