public async Task Then_Expected_Registrations_Are_Created() { // when await _bulkRegistrationTestFixture.WhenAsync(); // then _result = _bulkRegistrationTestFixture.Result; _result.Should().NotBeNull(); _result.IsSuccess.Should().BeTrue(); _result.BulkUploadStats.Should().NotBeNull(); _result.BulkUploadStats.TotalRecordsCount.Should().Be(_bulkRegistrationTestFixture.TqRegistrationProfilesData.Count); _result.BulkUploadStats.NewRecordsCount.Should().Be(1); _result.BulkUploadStats.AmendedRecordsCount.Should().Be(0); _result.BulkUploadStats.UnchangedRecordsCount.Should().Be(0); _result.ValidationErrors.Should().BeNullOrEmpty(); var expectedRegistrationProfile = _bulkRegistrationTestFixture.TqRegistrationProfilesData.FirstOrDefault(p => p.UniqueLearnerNumber == _bulkRegistrationTestFixture.Uln); var actualRegistrationProfile = await _bulkRegistrationTestFixture.DbContext.TqRegistrationProfile.Where(x => x.UniqueLearnerNumber == _bulkRegistrationTestFixture.Uln) .Include(x => x.TqRegistrationPathways) .ThenInclude(x => x.TqRegistrationSpecialisms) .Include(x => x.TqRegistrationPathways).FirstOrDefaultAsync(); // assert registration profile data actualRegistrationProfile.Should().NotBeNull(); actualRegistrationProfile.UniqueLearnerNumber.Should().Be(expectedRegistrationProfile.UniqueLearnerNumber); actualRegistrationProfile.Firstname.Should().Be(expectedRegistrationProfile.Firstname); actualRegistrationProfile.Lastname.Should().Be(expectedRegistrationProfile.Lastname); actualRegistrationProfile.DateofBirth.Should().Be(expectedRegistrationProfile.DateofBirth); actualRegistrationProfile.UniqueLearnerNumber.Should().Be(expectedRegistrationProfile.UniqueLearnerNumber); // assert registration pathway data actualRegistrationProfile.TqRegistrationPathways.Count.Should().Be(expectedRegistrationProfile.TqRegistrationPathways.Count); foreach (var expectedPathway in actualRegistrationProfile.TqRegistrationPathways) { var actualPathway = actualRegistrationProfile.TqRegistrationPathways.FirstOrDefault(p => p.TqProviderId == expectedPathway.TqProviderId && p.Status == expectedPathway.Status); actualPathway.Should().NotBeNull(); actualPathway.TqProviderId.Should().Be(expectedPathway.TqProviderId); actualPathway.AcademicYear.Should().Be(expectedPathway.AcademicYear); actualPathway.Status.Should().Be(expectedPathway.Status); actualPathway.IsBulkUpload.Should().Be(expectedPathway.IsBulkUpload); // assert specialisms actualPathway.TqRegistrationSpecialisms.Count.Should().Be(expectedPathway.TqRegistrationSpecialisms.Count); foreach (var expectedSpecialism in expectedPathway.TqRegistrationSpecialisms) { var actualSpecialism = actualPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.TlSpecialismId == expectedSpecialism.TlSpecialismId); actualSpecialism.Should().NotBeNull(); actualSpecialism.TlSpecialismId.Should().Be(expectedSpecialism.TlSpecialismId); actualSpecialism.IsOptedin.Should().Be(expectedSpecialism.IsOptedin); actualSpecialism.IsBulkUpload.Should().Be(expectedSpecialism.IsBulkUpload); } } }
public async Task Then_Expected_Registrations_Are_Amended() { // when await _bulkRegistrationTestFixture.WhenAsync(); // then _result = _bulkRegistrationTestFixture.Result; _result.Should().NotBeNull(); _result.IsSuccess.Should().BeTrue(); _result.BulkUploadStats.Should().NotBeNull(); _result.BulkUploadStats.TotalRecordsCount.Should().Be(_bulkRegistrationTestFixture.TqRegistrationProfilesData.Count); _result.BulkUploadStats.NewRecordsCount.Should().Be(0); _result.BulkUploadStats.AmendedRecordsCount.Should().Be(1); _result.BulkUploadStats.UnchangedRecordsCount.Should().Be(0); _result.ValidationErrors.Should().BeNullOrEmpty(); var expectedRegistrationProfile = _bulkRegistrationTestFixture.TqRegistrationProfilesData.FirstOrDefault(p => p.UniqueLearnerNumber == _bulkRegistrationTestFixture.Uln); var actualRegistrationProfile = _bulkRegistrationTestFixture.DbContext.TqRegistrationProfile.AsNoTracking().Where(x => x.UniqueLearnerNumber == _bulkRegistrationTestFixture.Uln) .Include(x => x.TqRegistrationPathways) .ThenInclude(x => x.TqRegistrationSpecialisms) .Include(x => x.TqRegistrationPathways).FirstOrDefault(); // assert registration profile data actualRegistrationProfile.Should().NotBeNull(); actualRegistrationProfile.UniqueLearnerNumber.Should().Be(expectedRegistrationProfile.UniqueLearnerNumber); actualRegistrationProfile.Firstname.Should().Be(expectedRegistrationProfile.Firstname); actualRegistrationProfile.Lastname.Should().Be(expectedRegistrationProfile.Lastname); actualRegistrationProfile.DateofBirth.Should().Be(expectedRegistrationProfile.DateofBirth); actualRegistrationProfile.UniqueLearnerNumber.Should().Be(expectedRegistrationProfile.UniqueLearnerNumber); // assert registration pathway data actualRegistrationProfile.TqRegistrationPathways.Where(x => x.Status == Common.Enum.RegistrationPathwayStatus.Active).ToList().Count.Should().Be(expectedRegistrationProfile.TqRegistrationPathways.Count); actualRegistrationProfile.TqRegistrationPathways.Where(x => x.Status == Common.Enum.RegistrationPathwayStatus.Transferred).ToList().Count.Should().Be(1); foreach (var expectedPathway in expectedRegistrationProfile.TqRegistrationPathways) { var actualActivePathway = actualRegistrationProfile.TqRegistrationPathways.FirstOrDefault(p => p.TqProviderId == expectedPathway.TqProviderId && p.Status == expectedPathway.Status); // Assert Active Registration AssertRegistrations(actualActivePathway, expectedPathway); var actualTransferredPathway = actualRegistrationProfile.TqRegistrationPathways.FirstOrDefault(p => p.TqProviderId == expectedPathway.TqProviderId && p.Status == Common.Enum.RegistrationPathwayStatus.Transferred); // Assert Transferred Registration AssertRegistrations(actualActivePathway, expectedPathway); } }
public async Task Then_Expected_Registrations_Are_Unchanged() { // when await _bulkRegistrationTestFixture.WhenAsync(); // then _result = _bulkRegistrationTestFixture.Result; _result.Should().NotBeNull(); _result.IsSuccess.Should().BeTrue(); _result.BulkUploadStats.Should().NotBeNull(); _result.BulkUploadStats.TotalRecordsCount.Should().Be(_bulkRegistrationTestFixture.TqRegistrationProfilesData.Count); _result.BulkUploadStats.NewRecordsCount.Should().Be(0); _result.BulkUploadStats.AmendedRecordsCount.Should().Be(0); _result.BulkUploadStats.UnchangedRecordsCount.Should().Be(1); _result.ValidationErrors.Should().BeNullOrEmpty(); }
private async Task <BulkProcessResponse> ProcessRegistrationResponse(BulkProcessRequest request, BulkProcessResponse response, RegistrationProcessResponse registrationProcessResult) { _ = registrationProcessResult.IsSuccess ? await MoveFileFromProcessingToProcessedAsync(request) : await MoveFileFromProcessingToFailedAsync(request); await CreateDocumentUploadHistory(request, registrationProcessResult.IsSuccess?DocumentUploadStatus.Processed : DocumentUploadStatus.Failed); response.IsSuccess = registrationProcessResult.IsSuccess; response.Stats = registrationProcessResult.BulkUploadStats; 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 async Task WhenAsync() { Result = await RegistrationService.CompareAndProcessRegistrationsAsync(TqRegistrationProfilesData); }
public async Task Then_Expected_Registrations_Are_Amended() { // when await _bulkRegistrationTestFixture.WhenAsync(); // then _result = _bulkRegistrationTestFixture.Result; _result.Should().NotBeNull(); _result.IsSuccess.Should().BeTrue(); _result.BulkUploadStats.Should().NotBeNull(); _result.BulkUploadStats.TotalRecordsCount.Should().Be(_bulkRegistrationTestFixture.TqRegistrationProfilesData.Count); _result.BulkUploadStats.NewRecordsCount.Should().Be(0); _result.BulkUploadStats.AmendedRecordsCount.Should().Be(1); _result.BulkUploadStats.UnchangedRecordsCount.Should().Be(0); _result.ValidationErrors.Should().BeNullOrEmpty(); var expectedRegistrationProfile = _bulkRegistrationTestFixture.TqRegistrationProfilesData.FirstOrDefault(p => p.UniqueLearnerNumber == _bulkRegistrationTestFixture.Uln); var actualRegistrationProfile = _bulkRegistrationTestFixture.DbContext.TqRegistrationProfile.AsNoTracking().Where(x => x.UniqueLearnerNumber == _bulkRegistrationTestFixture.Uln) .Include(x => x.TqRegistrationPathways) .ThenInclude(x => x.TqRegistrationSpecialisms) .Include(x => x.TqRegistrationPathways) .ThenInclude(x => x.TqPathwayAssessments) .ThenInclude(x => x.TqPathwayResults) .Include(x => x.TqRegistrationPathways) .ThenInclude(x => x.IndustryPlacements) .FirstOrDefault(); // Assert registration profile data actualRegistrationProfile.Should().NotBeNull(); actualRegistrationProfile.UniqueLearnerNumber.Should().Be(expectedRegistrationProfile.UniqueLearnerNumber); actualRegistrationProfile.Firstname.Should().Be(expectedRegistrationProfile.Firstname); actualRegistrationProfile.Lastname.Should().Be(expectedRegistrationProfile.Lastname); actualRegistrationProfile.DateofBirth.Should().Be(expectedRegistrationProfile.DateofBirth); actualRegistrationProfile.UniqueLearnerNumber.Should().Be(expectedRegistrationProfile.UniqueLearnerNumber); // Assert registration pathway data actualRegistrationProfile.TqRegistrationPathways.Where(x => x.Status == Common.Enum.RegistrationPathwayStatus.Active).ToList().Count.Should().Be(1); actualRegistrationProfile.TqRegistrationPathways.Where(x => x.Status == Common.Enum.RegistrationPathwayStatus.Transferred).ToList().Count.Should().Be(1); // Assert Transferred Pathway var actualTransferredPathway = actualRegistrationProfile.TqRegistrationPathways.FirstOrDefault(x => _bulkRegistrationTestFixture.TqRegistrationProfileBeforeSeed.TqRegistrationPathways.Any(y => y.TqProviderId == x.TqProviderId)); var expectedTransferredPathway = _bulkRegistrationTestFixture.TqRegistrationProfileBeforeSeed.TqRegistrationPathways.FirstOrDefault(x => actualRegistrationProfile.TqRegistrationPathways.Any(y => y.TqProviderId == x.TqProviderId)); AssertRegistrationPathway(actualTransferredPathway, expectedTransferredPathway); // Assert Active Pathway var activePathway = actualRegistrationProfile.TqRegistrationPathways.FirstOrDefault(x => _bulkRegistrationTestFixture.TqRegistrationProfilesData.FirstOrDefault().TqRegistrationPathways.Any(y => y.TqProviderId == x.TqProviderId)); var expectedActivePathway = _bulkRegistrationTestFixture.TqRegistrationProfilesData.FirstOrDefault().TqRegistrationPathways.FirstOrDefault(x => actualRegistrationProfile.TqRegistrationPathways.Any(y => y.TqProviderId == x.TqProviderId)); AssertRegistrationPathway(activePathway, expectedActivePathway); // Assert Active PathwayAssessment var actualActiveAssessment = activePathway.TqPathwayAssessments.FirstOrDefault(x => x.EndDate == null); var expectedActiveAssessment = expectedActivePathway.TqPathwayAssessments.FirstOrDefault(x => x.EndDate == null); AssertPathwayAssessment(actualActiveAssessment, expectedActiveAssessment); // Assert Transferred PathwayAssessment var actualTransferredAssessment = actualTransferredPathway.TqPathwayAssessments.FirstOrDefault(x => x.EndDate != null); var expectedTransferredAssessment = expectedTransferredPathway.TqPathwayAssessments.FirstOrDefault(x => x.EndDate != null); AssertPathwayAssessment(actualTransferredAssessment, expectedTransferredAssessment); // Assert Active PathwayResult var actualActiveResult = actualActiveAssessment.TqPathwayResults.FirstOrDefault(x => x.EndDate == null); var expectedActiveResult = expectedActiveAssessment.TqPathwayResults.FirstOrDefault(x => x.EndDate == null); AssertPathwayResults(actualActiveResult, expectedActiveResult); // Assert Transferred PathwayResult var actualTransferredResult = actualTransferredAssessment.TqPathwayResults.FirstOrDefault(x => x.EndDate != null); var expectedTransferredResult = expectedTransferredAssessment.TqPathwayResults.FirstOrDefault(x => x.EndDate != null); AssertPathwayResults(actualTransferredResult, expectedTransferredResult); // Assert IndustryPlacement Data var actualActiveIndustryPlacement = activePathway.IndustryPlacements.FirstOrDefault(); var expectedPreviousIndustryPlacement = expectedTransferredPathway.IndustryPlacements.FirstOrDefault(); actualActiveIndustryPlacement.Status.Should().Be(expectedPreviousIndustryPlacement.Status); }
public async override Task When() { _result = await RegistrationService.CompareAndProcessRegistrationsAsync(_tqRegistrationProfilesData); }