public async Task Then_Expected_Results_Are_Created()
        {
            // when
            await _bulkResultsTestFixture.WhenAsync();

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

            foreach (var uln in _bulkResultsTestFixture.Ulns)
            {
                var expectedRegistrationProfile = _bulkResultsTestFixture.TqRegistrationProfilesData.FirstOrDefault(p => p.UniqueLearnerNumber == uln);
                var registrationPathway         = expectedRegistrationProfile.TqRegistrationPathways.First();

                var pathwayAssessment = _bulkResultsTestFixture.TqPathwayAssessmentsData.FirstOrDefault(p => p.TqRegistrationPathwayId == registrationPathway.Id);

                var expectedPathwayResult = _bulkResultsTestFixture.TqPathwayResultsData.FirstOrDefault(r => r.TqPathwayAssessmentId == pathwayAssessment.Id);

                var actualPathwayResult = _bulkResultsTestFixture.DbContext.TqPathwayResult.FirstOrDefault(x => x.TqPathwayAssessmentId == pathwayAssessment.Id && x.IsOptedin && x.EndDate == null);

                // assert registration profile data
                actualPathwayResult.Should().NotBeNull();
                actualPathwayResult.TqPathwayAssessmentId.Should().Be(expectedPathwayResult.TqPathwayAssessmentId);
                actualPathwayResult.TlLookupId.Should().Be(expectedPathwayResult.TlLookupId);
                actualPathwayResult.IsOptedin.Should().Be(expectedPathwayResult.IsOptedin);
                actualPathwayResult.IsBulkUpload.Should().Be(expectedPathwayResult.IsBulkUpload);
                actualPathwayResult.StartDate.ToShortDateString().Should().Be(expectedPathwayResult.StartDate.ToShortDateString());
                actualPathwayResult.CreatedBy.Should().Be(expectedPathwayResult.CreatedBy);
            }
        }
        public async Task <ResultProcessResponse> CompareAndProcessResultsAsync(IList <TqPathwayResult> pathwayResultsToProcess)
        {
            var response = new ResultProcessResponse();

            // Prepare Pathway Results
            var newOrAmendedPathwayResultRecords = await PrepareNewAndAmendedPathwayResults(pathwayResultsToProcess);

            // Process Results
            response.IsSuccess = await _resultRepository.BulkInsertOrUpdateResults(newOrAmendedPathwayResultRecords);

            return(response);
        }
Exemplo n.º 3
0
        public override void Given()
        {
            var expectedStage2Response = new List <ResultCsvRecordResponse>
            {
                new ResultCsvRecordResponse {
                    RowNum = 1, Uln = 1111111111,
                },
                new ResultCsvRecordResponse {
                    RowNum = 2, Uln = 1111111112,
                },
                new ResultCsvRecordResponse {
                    RowNum = 3, Uln = 1111111113,
                }
            };

            var expectedStage3Response = new List <ResultRecordResponse>
            {
                new ResultRecordResponse {
                    TqPathwayAssessmentId = 1, PathwayComponentGradeLookupId = 1
                },
                new ResultRecordResponse {
                    TqPathwayAssessmentId = 2, PathwayComponentGradeLookupId = 2
                },
                new ResultRecordResponse {
                    TqPathwayAssessmentId = 3, PathwayComponentGradeLookupId = 3
                }
            };

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

            BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File")));
            CsvService.ReadAndParseFileAsync(Arg.Any <ResultCsvRecordRequest>()).Returns(csvResponse);
            ResultService.ValidateResultsAsync(AoUkprn, Arg.Any <IEnumerable <ResultCsvRecordResponse> >()).Returns(expectedStage3Response);
            CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes);

            var transformationResponse = GetTransformResultsModel();

            ResultService.TransformResultsModel(expectedStage3Response, Arg.Any <string>()).Returns(transformationResponse);

            var resultsProcessResult = new ResultProcessResponse {
                IsSuccess = true
            };

            ResultService.CompareAndProcessResultsAsync(transformationResponse).Returns(resultsProcessResult);
        }
 public async Task WhenAsync()
 {
     Result = await ResultService.CompareAndProcessResultsAsync(TqPathwayResultsData);
 }
        private async Task <BulkResultResponse> ProcessResultsResponse(BulkProcessRequest request, BulkResultResponse response, ResultProcessResponse resultProcessResult)
        {
            _ = resultProcessResult.IsSuccess ? await MoveFileFromProcessingToProcessedAsync(request) : await MoveFileFromProcessingToFailedAsync(request);
            await CreateDocumentUploadHistory(request, resultProcessResult.IsSuccess?DocumentUploadStatus.Processed : DocumentUploadStatus.Failed);

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