private IList <BulkProcessValidationError> ExtractAllValidationErrors(CsvResponseModel <RegistrationCsvRecordResponse> stage2RegistrationsResponse = null, IList <RegistrationRecordResponse> stage3RegistrationsResponse = null) { if (stage2RegistrationsResponse != null && stage2RegistrationsResponse.IsDirty) { return new List <BulkProcessValidationError> { new BulkProcessValidationError { ErrorMessage = stage2RegistrationsResponse.ErrorMessage } } } ; var errors = new List <BulkProcessValidationError>(); if (stage2RegistrationsResponse != null) { foreach (var invalidRegistration in stage2RegistrationsResponse.Rows?.Where(x => !x.IsValid)) { errors.AddRange(invalidRegistration.ValidationErrors); } } if (stage3RegistrationsResponse != null) { foreach (var invalidRegistration in stage3RegistrationsResponse.Where(x => !x.IsValid)) { errors.AddRange(invalidRegistration.ValidationErrors); } } return(errors); } }
public override void Given() { expectedStage2Response = new List <AssessmentCsvRecordResponse> { new AssessmentCsvRecordResponse { RowNum = 1, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "1", ErrorMessage = "TestErrorMessage1" } } }, new AssessmentCsvRecordResponse { RowNum = 2, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "2", ErrorMessage = "TestErrorMessage2" } } } }; var csvResponse = new CsvResponseModel <AssessmentCsvRecordResponse> { Rows = expectedStage2Response }; CsvService.ReadAndParseFileAsync(Arg.Any <AssessmentCsvRecordRequest>()).Returns(csvResponse); BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File"))); var expectedWriteFileBytes = new byte[5]; CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
public override void Given() { expectedStage2Response = new List <ResultCsvRecordResponse> { new ResultCsvRecordResponse { RowNum = 1, Uln = 1111111111, CoreCode = "1234567", CoreAssessmentSeries = "Summer 2021", CoreGrade = "A", ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "1", Uln = "1111111111", ErrorMessage = "Core component code must have 8 digits only" } } }, new ResultCsvRecordResponse { RowNum = 2, Uln = 1111111112, CoreCode = "", CoreAssessmentSeries = "Summer 2021", CoreGrade = "A", ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "2", Uln = "1111111112", ErrorMessage = "Core component code required when result is included" } } } }; var csvResponse = new CsvResponseModel <ResultCsvRecordResponse> { Rows = expectedStage2Response }; CsvService.ReadAndParseFileAsync(Arg.Any <ResultCsvRecordRequest>()).Returns(csvResponse); ResultService.ValidateResultsAsync(AoUkprn, Arg.Any <IEnumerable <ResultCsvRecordResponse> >()).Returns(new List <ResultRecordResponse>()); BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File"))); var expectedWriteFileBytes = new byte[5]; CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
private IList <BulkProcessValidationError> ExtractAllValidationErrors(CsvResponseModel <ResultCsvRecordResponse> stage2Response = null, IList <ResultRecordResponse> stage3Response = null) { if (stage2Response != null && stage2Response.IsDirty) { var errorMessage = stage2Response.ErrorCode == CsvFileErrorCode.NoRecordsFound ? ValidationMessages.AtleastOneEntryRequired : stage2Response.ErrorMessage; return(new List <BulkProcessValidationError> { new BulkProcessValidationError { ErrorMessage = errorMessage } }); } var errors = new List <BulkProcessValidationError>(); if (stage2Response != null) { foreach (var invalidRegistration in stage2Response.Rows?.Where(x => !x.IsValid)) { errors.AddRange(invalidRegistration.ValidationErrors); } } if (stage3Response != null) { foreach (var invalidResult in stage3Response.Where(x => !x.IsValid)) { errors.AddRange(invalidResult.ValidationErrors); } } return(errors); }
public async Task WhenAsync() { ValidatorOptions.Global.DisplayNameResolver = (type, memberInfo, expression) => { return(memberInfo.GetCustomAttribute <System.ComponentModel.DataAnnotations.DisplayAttribute>()?.GetName()); }; await using (var stream = File.Open(FilePath, FileMode.Open)) { ReadAndParseFileResponse = await Service.ReadAndParseFileAsync(new AssessmentCsvRecordRequest { FileStream = stream }); } }
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 override void Given() { var errorMessage = "InvalidHeader"; var csvResponse = new CsvResponseModel <AssessmentCsvRecordResponse> { IsDirty = true, ErrorMessage = errorMessage, }; 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); CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
public override void Given() { csvResponse = new CsvResponseModel <ResultCsvRecordResponse> { IsDirty = true, ErrorMessage = ValidationMessages.InvalidColumnFound, ErrorCode = CsvFileErrorCode.NoRecordsFound }; 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); CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
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 List <BulkProcessValidationError> ExtractExpectedErrors(CsvResponseModel <ResultCsvRecordResponse> csvResponse) { if (csvResponse.IsDirty) { return new List <BulkProcessValidationError> { new BulkProcessValidationError { ErrorMessage = csvResponse.ErrorMessage } } } ; var errors = new List <BulkProcessValidationError>(); var invalidReg = csvResponse.Rows?.Where(x => !x.IsValid).ToList(); invalidReg.ForEach(x => { errors.AddRange(x.ValidationErrors); }); return(errors); } }
public override void Given() { var expectedWriteFileRequest = new List <RegistrationCsvRecordResponse> { new RegistrationCsvRecordResponse { RowNum = 1, ProviderUkprn = 11 }, new RegistrationCsvRecordResponse { RowNum = 2, ProviderUkprn = 22, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "1", Uln = "11", ErrorMessage = "First name required" }, new BulkProcessValidationError { RowNum = "1", Uln = "11", ErrorMessage = "Core code required" } } }, new RegistrationCsvRecordResponse { RowNum = 3, ProviderUkprn = 33, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "3", Uln = "33", ErrorMessage = "Invalid Date" } } }, }; var csvResponse = new CsvResponseModel <RegistrationCsvRecordResponse> { Rows = expectedWriteFileRequest }; var expectedWriteFileBytes = new byte[5]; BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File"))); CsvService.ReadAndParseFileAsync(Arg.Any <RegistrationCsvRecordRequest>()).Returns(csvResponse); CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
public async Task <BulkProcessResponse> ProcessAsync(BulkProcessRequest request) { var response = new BulkProcessResponse(); try { CsvResponseModel <RegistrationCsvRecordResponse> stage2RegistrationsResponse = null; // Step: 1 Read file from Blob using (var fileStream = await _blobStorageService.DownloadFileAsync(new BlobStorageData { ContainerName = request.DocumentType.ToString(), BlobFileName = request.BlobFileName, SourceFilePath = $"{request.AoUkprn}/{BulkProcessStatus.Processing}", UserName = request.PerformedBy })) { if (fileStream == null) { var blobReadError = $"No FileStream found to process bluk registrations. Method: DownloadFileAsync(ContainerName: {request.DocumentType}, BlobFileName = {request.BlobFileName}, SourceFilePath = {request.AoUkprn}/{BulkProcessStatus.Processing}, UserName = {request.PerformedBy}), User: {request.PerformedBy}"; _logger.LogInformation(LogEvent.FileStreamNotFound, blobReadError); throw new Exception(blobReadError); } // Stage 2 validation stage2RegistrationsResponse = await _csvService.ReadAndParseFileAsync(new RegistrationCsvRecordRequest { FileStream = fileStream }); if (!stage2RegistrationsResponse.IsDirty) { CheckUlnDuplicates(stage2RegistrationsResponse.Rows); } } if (stage2RegistrationsResponse.IsDirty || !stage2RegistrationsResponse.Rows.Any(x => x.IsValid)) { var validationErrors = ExtractAllValidationErrors(stage2RegistrationsResponse); return(await SaveErrorsAndUpdateResponse(request, response, validationErrors)); } // Stage 3 valiation. var stage3RegistrationsResponse = await _registrationService.ValidateRegistrationTlevelsAsync(request.AoUkprn, stage2RegistrationsResponse.Rows.Where(x => x.IsValid)); if (stage2RegistrationsResponse.Rows.Any(x => !x.IsValid) || stage3RegistrationsResponse.Any(x => !x.IsValid)) { var validationErrors = ExtractAllValidationErrors(stage2RegistrationsResponse, stage3RegistrationsResponse); return(await SaveErrorsAndUpdateResponse(request, response, validationErrors)); } // Step: Map data to DB model type. var tqRegistrationProfiles = _registrationService.TransformRegistrationModel(stage3RegistrationsResponse, request.PerformedBy); // Step: Process Stage 4 validation and DB operation var registrationProcessResult = await _registrationService.CompareAndProcessRegistrationsAsync(tqRegistrationProfiles); return(registrationProcessResult.IsValid ? await ProcessRegistrationResponse(request, response, registrationProcessResult) : await SaveErrorsAndUpdateResponse(request, response, registrationProcessResult.ValidationErrors)); } catch (Exception ex) { var errorMessage = $"Something went wrong while processing bluk registrations. Method: ProcessBulkRegistrationsAsync(BulkRegistrationRequest : {JsonConvert.SerializeObject(request)}), User: {request.PerformedBy}"; _logger.LogError(LogEvent.BulkRegistrationProcessFailed, ex, errorMessage); await DeleteFileFromProcessingFolderAsync(request); } return(response); }
public override void Given() { var expectedStage2Response = new List <RegistrationCsvRecordResponse> { new RegistrationCsvRecordResponse { RowNum = 1, Uln = 1111111111, FirstName = "First 1", LastName = "Last 1", DateOfBirth = "01/10/1980".ToDateTime(), ProviderUkprn = 00000001, AcademicYear = DateTime.UtcNow.Year, CoreCode = "12333333", SpecialismCodes = new List <string> { "234567819" } } }; var expectedStage3Response = new List <RegistrationRecordResponse> { new RegistrationRecordResponse { Uln = 1111111111, FirstName = "First 1", LastName = "Last 1", DateOfBirth = "01/10/1980".ToDateTime(), AcademicYear = DateTime.UtcNow.Year, TqProviderId = 1, TlProviderId = 1, TqAwardingOrganisationId = 1, TlAwardingOrganisatonId = 1, TlPathwayId = 4, TlSpecialismLarIds = new List <KeyValuePair <int, string> > { new KeyValuePair <int, string>(5, "12345") } } }; var tqRegistrationProfiles = new List <TqRegistrationProfile> { new TqRegistrationProfile { Id = 1, UniqueLearnerNumber = 1111111111, Firstname = "First 1", Lastname = "Last 1", DateofBirth = "01/10/1980".ToDateTime(), CreatedBy = "System", CreatedOn = DateTime.UtcNow, TqRegistrationPathways = new List <TqRegistrationPathway> { new TqRegistrationPathway { Id = 1000, TqProviderId = 1, AcademicYear = "01/07/2020".ToDateTime().Year, StartDate = DateTime.UtcNow, Status = RegistrationPathwayStatus.Active, IsBulkUpload = true, TqRegistrationSpecialisms = new List <TqRegistrationSpecialism> { new TqRegistrationSpecialism { Id = 1, TlSpecialismId = 5, StartDate = DateTime.UtcNow, IsOptedin = true, IsBulkUpload = true, CreatedBy = "System", CreatedOn = DateTime.UtcNow, } }, TqProvider = new TqProvider { TqAwardingOrganisationId = 1, TlProviderId = 1, TqAwardingOrganisation = new TqAwardingOrganisation { Id = 1, TlAwardingOrganisatonId = 1, TlPathwayId = 4, } }, CreatedBy = "System", CreatedOn = DateTime.UtcNow } } } }; var expectedStage4Response = new RegistrationProcessResponse { IsSuccess = false, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { Uln = "1111111111", ErrorMessage = "Active ULN with a different awarding organisation" } } }; var csvResponse = new CsvResponseModel <RegistrationCsvRecordResponse> { Rows = expectedStage2Response }; var expectedWriteFileBytes = new byte[5]; BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File"))); CsvService.ReadAndParseFileAsync(Arg.Any <RegistrationCsvRecordRequest>()).Returns(csvResponse); RegistrationService.ValidateRegistrationTlevelsAsync(AoUkprn, Arg.Any <IEnumerable <RegistrationCsvRecordResponse> >()).Returns(expectedStage3Response); RegistrationService.TransformRegistrationModel(Arg.Any <IList <RegistrationRecordResponse> >(), Arg.Any <string>()).Returns(tqRegistrationProfiles); RegistrationService.CompareAndProcessRegistrationsAsync(Arg.Any <IList <TqRegistrationProfile> >()).Returns(expectedStage4Response); CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
public override void Given() { var expectedStage2Response = new List <RegistrationCsvRecordResponse> { new RegistrationCsvRecordResponse { RowNum = 1, Uln = 1111111111, FirstName = "", LastName = "Last3", DateOfBirth = "01/01/1990".ToDateTime(), ProviderUkprn = 33333333, AcademicYear = 2020, CoreCode = "12333333", SpecialismCodes = new List <string> { "234567819" }, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "1", Uln = "1111111111", ErrorMessage = "First name required" } } }, new RegistrationCsvRecordResponse { RowNum = 2, Uln = 1111111112, FirstName = "First2", LastName = "", DateOfBirth = "01/01/1990".ToDateTime(), ProviderUkprn = 33333333, AcademicYear = 2020, CoreCode = "12333333", SpecialismCodes = new List <string> { "234567819" }, ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "2", Uln = "1111111112", ErrorMessage = "Last name required" } } }, new RegistrationCsvRecordResponse { RowNum = 3, Uln = 1111111113, FirstName = "First3", LastName = "Last3", DateOfBirth = "01/01/1990".ToDateTime(), ProviderUkprn = 00000000, AcademicYear = 2020, CoreCode = "12333333", SpecialismCodes = new List <string> { "234567819" } }, new RegistrationCsvRecordResponse { RowNum = 4, Uln = 1111111114, FirstName = "First4", LastName = "Last4", DateOfBirth = "01/01/1990".ToDateTime(), ProviderUkprn = 33333333, AcademicYear = 2020, CoreCode = "00000000", SpecialismCodes = new List <string> { "234567819" } }, new RegistrationCsvRecordResponse { RowNum = 5, Uln = 1111111115, FirstName = "First5", LastName = "Last5", DateOfBirth = "01/01/1990".ToDateTime(), ProviderUkprn = 33333333, AcademicYear = 2020, CoreCode = "12333333", SpecialismCodes = new List <string> { "000000000" } }, }; var expectedStage3Response = new List <RegistrationRecordResponse> { new RegistrationRecordResponse { ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "3", Uln = "1111111113", ErrorMessage = "Provider not registered with awarding organisation" }, } }, new RegistrationRecordResponse { ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "4", Uln = "1111111114", ErrorMessage = "Core not registered with provider" } } }, new RegistrationRecordResponse { ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "5", Uln = "1111111115", ErrorMessage = "Specialism not valid with core" } } }, }; var csvResponse = new CsvResponseModel <RegistrationCsvRecordResponse> { Rows = expectedStage2Response }; var expectedWriteFileBytes = new byte[5]; BlobService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File"))); CsvService.ReadAndParseFileAsync(Arg.Any <RegistrationCsvRecordRequest>()).Returns(csvResponse); RegistrationService.ValidateRegistrationTlevelsAsync(AoUkprn, Arg.Any <IEnumerable <RegistrationCsvRecordResponse> >()).Returns(expectedStage3Response); CsvService.WriteFileAsync(Arg.Any <List <BulkProcessValidationError> >()).Returns(expectedWriteFileBytes); }
public override void Given() { expectedStage2Response = new List <AssessmentCsvRecordResponse> { new AssessmentCsvRecordResponse { RowNum = 1, Uln = 1111111111, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022", SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023", ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "1", Uln = "1111111111", ErrorMessage = "Core code must have 8 digits only" } } }, new AssessmentCsvRecordResponse { RowNum = 2, Uln = 1111111112, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022", SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023", ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "2", Uln = "1111111112", ErrorMessage = "Last name required" } } }, new AssessmentCsvRecordResponse { RowNum = 3, Uln = 1111111113, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022", SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023" }, new AssessmentCsvRecordResponse { RowNum = 4, Uln = 1111111114, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022", SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023" }, new AssessmentCsvRecordResponse { RowNum = 5, Uln = 1111111115, CoreCode = "12345678", CoreAssessmentEntry = "Summer 2022", SpecialismCode = "LAR12345", SpecialismAssessmentEntry = "Autumn 2023" } }; var expectedStage3Response = new List <AssessmentRecordResponse> { new AssessmentRecordResponse { ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "3", Uln = "1111111113", ErrorMessage = "Core code either not recognised or not registered for this ULN" }, } }, new AssessmentRecordResponse { ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "4", Uln = "1111111114", ErrorMessage = "Specialism code either not recognised or not registered for this ULN" } } }, new AssessmentRecordResponse { ValidationErrors = new List <BulkProcessValidationError> { new BulkProcessValidationError { RowNum = "5", Uln = "1111111115", ErrorMessage = "Specialism assessment entry must be the second series in the second academic year or the first series in the third academic year and be in the format detailed in the 'format rules' and 'example' columns in the technical specification" } } }, }; 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); }
public async override Task When() { Response = await Service.ReadAndParseFileAsync(new ResultCsvRecordRequest { FileStream = GetInputFileStream() }); }