Exemplo n.º 1
0
        public static void AssertRegistrationPathway(TqRegistrationPathway actualPathway, TqRegistrationPathway expectedPathway, bool assertStatus = true)
        {
            actualPathway.Should().NotBeNull();
            actualPathway.TqProviderId.Should().Be(expectedPathway.TqProviderId);
            actualPathway.AcademicYear.Should().Be(expectedPathway.AcademicYear);
            if (assertStatus)
            {
                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_Results_Are_Returned(long aoUkprn, long uln, int profileId, RegistrationPathwayStatus status, bool expectedResponse)
        {
            await WhenAsync(aoUkprn, profileId);

            if (_result == null)
            {
                expectedResponse.Should().BeFalse();
                return;
            }

            var expectedRegistration = _registrations.SingleOrDefault(x => x.UniqueLearnerNumber == uln);

            expectedRegistration.Should().NotBeNull();

            TqRegistrationPathway expectedPathway = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathway = expectedRegistration.TqRegistrationPathways.FirstOrDefault(p => p.Status == status && p.EndDate != null);
            }
            else
            {
                expectedPathway = expectedRegistration.TqRegistrationPathways.FirstOrDefault(p => p.Status == status && p.EndDate == null);
            }

            expectedPathway.Should().NotBeNull();

            TqRegistrationSpecialism expectedSpecialim = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedSpecialim = expectedPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.IsOptedin && s.EndDate != null);
            }
            else
            {
                expectedSpecialim = expectedPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.IsOptedin && s.EndDate == null);
            }

            TqPathwayAssessment expectedPathwayAssessment = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathwayAssessment = _pathwayAssessments.FirstOrDefault(x => x.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber == uln && x.IsOptedin && x.EndDate != null);
            }
            else
            {
                expectedPathwayAssessment = _pathwayAssessments.FirstOrDefault(x => x.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber == uln && x.IsOptedin && x.EndDate == null);
            }

            var expectedAssessmentDetails = new ResultDetails
            {
                ProfileId     = expectedRegistration.Id,
                Uln           = expectedRegistration.UniqueLearnerNumber,
                Firstname     = expectedRegistration.Firstname,
                Lastname      = expectedRegistration.Lastname,
                ProviderUkprn = expectedPathway.TqProvider.TlProvider.UkPrn,
                ProviderName  = expectedPathway.TqProvider.TlProvider.Name,
                Status        = expectedPathway.Status
            };

            // Assert
            _result.ProfileId.Should().Be(expectedAssessmentDetails.ProfileId);
            _result.Uln.Should().Be(expectedAssessmentDetails.Uln);
            _result.Firstname.Should().Be(expectedAssessmentDetails.Firstname);
            _result.Lastname.Should().Be(expectedAssessmentDetails.Lastname);
            _result.ProviderUkprn.Should().Be(expectedAssessmentDetails.ProviderUkprn);
            _result.ProviderName.Should().Be(expectedAssessmentDetails.ProviderName);
            _result.Status.Should().Be(expectedAssessmentDetails.Status);
        }
        public async Task Then_Expected_Results_Are_Returned(long aoUkprn, long uln, int profileId, RegistrationPathwayStatus status, bool hasAssessments, bool expectedResponse)
        {
            await WhenAsync(aoUkprn, profileId);

            if (_result == null)
            {
                expectedResponse.Should().BeFalse();
                return;
            }

            // Expected result
            var expectedRegistration = _registrations.SingleOrDefault(x => x.UniqueLearnerNumber == uln);

            expectedRegistration.Should().NotBeNull();

            TqRegistrationPathway expectedPathway = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathway = expectedRegistration.TqRegistrationPathways.FirstOrDefault(p => p.Status == status && p.EndDate != null);
            }
            else
            {
                expectedPathway = expectedRegistration.TqRegistrationPathways.FirstOrDefault(p => p.Status == status && p.EndDate == null);
            }

            expectedPathway.Should().NotBeNull();

            TqRegistrationSpecialism expectedSpecialim = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedSpecialim = expectedPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.IsOptedin && s.EndDate != null);
            }
            else
            {
                expectedSpecialim = expectedPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.IsOptedin && s.EndDate == null);
            }

            TqPathwayAssessment expectedPathwayAssessment = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathwayAssessment = _pathwayAssessments.FirstOrDefault(x => x.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber == uln && x.IsOptedin && x.EndDate != null);
            }
            else
            {
                expectedPathwayAssessment = _pathwayAssessments.FirstOrDefault(x => x.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber == uln && x.IsOptedin && x.EndDate == null);
            }

            TqPathwayResult expectedPathwayResult = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathwayResult = _pathwayResults.FirstOrDefault(x => expectedPathwayAssessment != null && x.TqPathwayAssessmentId == expectedPathwayAssessment.Id && x.IsOptedin && x.EndDate != null);
            }
            else
            {
                expectedPathwayResult = _pathwayResults.FirstOrDefault(x => expectedPathwayAssessment != null && x.TqPathwayAssessmentId == expectedPathwayAssessment.Id && x.IsOptedin && x.EndDate == null);
            }

            _result.Should().NotBeNull();

            // Actual result
            var actualPathway           = _result;
            var actualSpecialism        = actualPathway.TqRegistrationSpecialisms.FirstOrDefault();
            var actualPathwayAssessment = actualPathway.TqPathwayAssessments.FirstOrDefault();

            // Assert Registration Pathway
            actualPathway.TqRegistrationProfileId.Should().Be(expectedPathway.TqRegistrationProfileId);
            actualPathway.TqProviderId.Should().Be(expectedPathway.TqProviderId);
            actualPathway.AcademicYear.Should().Be(expectedPathway.AcademicYear);
            actualPathway.StartDate.Should().Be(expectedPathway.StartDate);
            actualPathway.EndDate.Should().Be(expectedPathway.EndDate);
            actualPathway.Status.Should().Be(expectedPathway.Status);

            // Assert Registration Specialism
            actualSpecialism.TqRegistrationPathwayId.Should().Be(expectedSpecialim.TqRegistrationPathwayId);
            actualSpecialism.TlSpecialismId.Should().Be(expectedSpecialim.TlSpecialismId);
            actualSpecialism.StartDate.Should().Be(expectedSpecialim.StartDate);
            actualSpecialism.EndDate.Should().Be(expectedSpecialim.EndDate);
            actualSpecialism.IsOptedin.Should().Be(expectedSpecialim.IsOptedin);

            // Assert Assessments
            if (hasAssessments)
            {
                AssertPathwayAssessment(actualPathwayAssessment, expectedPathwayAssessment);
                AssertPathwayResult(expectedPathwayResult, expectedPathwayResult);
            }
        }
Exemplo n.º 4
0
        public async Task Then_Expected_Results_Are_Returned(long aoUkprn, long uln, int profileId, RegistrationPathwayStatus status, bool expectedResponse)
        {
            await WhenAsync(aoUkprn, profileId);

            if (_result == null)
            {
                expectedResponse.Should().BeFalse();
                return;
            }

            var expectedRegistration = _registrations.SingleOrDefault(x => x.UniqueLearnerNumber == uln);

            expectedRegistration.Should().NotBeNull();

            TqRegistrationPathway expectedPathway = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathway = expectedRegistration.TqRegistrationPathways.FirstOrDefault(p => p.Status == status && p.EndDate != null);
            }
            else
            {
                expectedPathway = expectedRegistration.TqRegistrationPathways.FirstOrDefault(p => p.Status == status && p.EndDate == null);
            }

            expectedPathway.Should().NotBeNull();

            TqRegistrationSpecialism expectedSpecialim = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedSpecialim = expectedPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.IsOptedin && s.EndDate != null);
            }
            else
            {
                expectedSpecialim = expectedPathway.TqRegistrationSpecialisms.FirstOrDefault(s => s.IsOptedin && s.EndDate == null);
            }

            TqPathwayAssessment expectedPathwayAssessment = null;
            TqPathwayResult     expectedPathwayResult     = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedPathwayAssessment = _pathwayAssessments.FirstOrDefault(x => x.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber == uln && x.IsOptedin && x.EndDate != null);
                expectedPathwayResult     = expectedPathwayAssessment?.TqPathwayResults.FirstOrDefault(x => x.IsOptedin && x.EndDate != null);
            }
            else
            {
                expectedPathwayAssessment = _pathwayAssessments.FirstOrDefault(x => x.TqRegistrationPathway.TqRegistrationProfile.UniqueLearnerNumber == uln && x.IsOptedin && x.EndDate == null);
                expectedPathwayResult     = expectedPathwayAssessment?.TqPathwayResults.FirstOrDefault(x => x.IsOptedin && x.EndDate == null);
            }

            TqSpecialismAssessment expectedSpecialismAssessment = null;

            if (status == RegistrationPathwayStatus.Withdrawn)
            {
                expectedSpecialismAssessment = _specialismAssessments.FirstOrDefault(x => x.TqRegistrationSpecialismId == expectedSpecialim.Id && x.IsOptedin && x.EndDate != null);
            }
            else
            {
                expectedSpecialismAssessment = _specialismAssessments.FirstOrDefault(x => x.TqRegistrationSpecialismId == expectedSpecialim.Id && x.IsOptedin && x.EndDate == null);
            }

            var expectedAssessmentDetails = new AssessmentDetails
            {
                ProfileId               = expectedRegistration.Id,
                Uln                     = expectedRegistration.UniqueLearnerNumber,
                Firstname               = expectedRegistration.Firstname,
                Lastname                = expectedRegistration.Lastname,
                ProviderUkprn           = expectedPathway.TqProvider.TlProvider.UkPrn,
                ProviderName            = expectedPathway.TqProvider.TlProvider.Name,
                PathwayLarId            = expectedPathway.TqProvider.TqAwardingOrganisation.TlPathway.LarId,
                PathwayName             = expectedPathway.TqProvider.TqAwardingOrganisation.TlPathway.Name,
                PathwayAssessmentSeries = expectedPathwayAssessment?.AssessmentSeries.Name,
                PathwayAssessmentId     = expectedPathwayAssessment != null ? expectedPathwayAssessment.Id : (int?)null,

                SpecialismLarId            = expectedSpecialim?.TlSpecialism.LarId,
                SpecialismName             = expectedSpecialim?.TlSpecialism.Name,
                SpecialismAssessmentSeries = expectedSpecialismAssessment?.AssessmentSeries.Name,
                SpecialismAssessmentId     = expectedSpecialismAssessment != null ? expectedSpecialismAssessment.Id : (int?)null,
                Status = expectedPathway.Status,

                PathwayResultId = expectedPathwayResult?.Id
            };

            var expectedIsIndustryPlacementExist = expectedRegistration.TqRegistrationPathways.FirstOrDefault().IndustryPlacements.Any();

            // Assert
            _result.ProfileId.Should().Be(expectedAssessmentDetails.ProfileId);
            _result.Uln.Should().Be(expectedAssessmentDetails.Uln);
            _result.Firstname.Should().Be(expectedAssessmentDetails.Firstname);
            _result.Lastname.Should().Be(expectedAssessmentDetails.Lastname);
            _result.ProviderUkprn.Should().Be(expectedAssessmentDetails.ProviderUkprn);
            _result.ProviderName.Should().Be(expectedAssessmentDetails.ProviderName);
            _result.PathwayLarId.Should().Be(expectedAssessmentDetails.PathwayLarId);
            _result.PathwayName.Should().Be(expectedAssessmentDetails.PathwayName);
            _result.PathwayAssessmentSeries.Should().Be(expectedAssessmentDetails.PathwayAssessmentSeries);
            _result.PathwayAssessmentId.Should().Be(expectedAssessmentDetails.PathwayAssessmentId);
            _result.SpecialismLarId.Should().Be(expectedAssessmentDetails.SpecialismLarId);
            _result.SpecialismName.Should().Be(expectedAssessmentDetails.SpecialismName);
            _result.SpecialismAssessmentSeries.Should().Be(expectedAssessmentDetails.SpecialismAssessmentSeries);
            _result.SpecialismAssessmentId.Should().Be(expectedAssessmentDetails.SpecialismAssessmentId);
            _result.Status.Should().Be(expectedAssessmentDetails.Status);
            _result.PathwayResultId.Should().Be(expectedAssessmentDetails.PathwayResultId);
            _result.IsIndustryPlacementExist.Should().Be(expectedIsIndustryPlacementExist);
        }
Exemplo n.º 5
0
        public async Task Then_Expected_Results_Are_Returned(long aoUkprn, int uln, bool includeProfile, bool includeIndustryPlacement,
                                                             bool isRegistrationPathwayExpected, bool isRegistrationProfileExpected, bool isPathwayAssessmentExpected, bool isIndustryPlacementExpected)
        {
            var profileId = _registrations.FirstOrDefault(x => x.UniqueLearnerNumber == uln).Id;

            await WhenAsync(aoUkprn, profileId, includeProfile, includeIndustryPlacement);

            if (isRegistrationPathwayExpected)
            {
                _actualResult.Should().NotBeNull();
            }
            else
            {
                _actualResult.Should().BeNull();
                return;
            }

            // Assert RegistrationPathway
            var expectedPathway = GetExpectedRegistrationPathway(uln);

            AssertRegistrationPathway(_actualResult, expectedPathway);

            // Assert if Profile included
            if (isRegistrationProfileExpected)
            {
                _actualResult.TqRegistrationProfile.Should().NotBeNull();
                AssertRegistrationProfile(_actualResult.TqRegistrationProfile, expectedPathway.TqRegistrationProfile);
            }
            else
            {
                _actualResult.TqRegistrationProfile.Should().BeNull();
            }

            // Assert if PathwayAssessment included
            if (isPathwayAssessmentExpected)
            {
                _actualResult.TqPathwayAssessments.Any().Should().BeTrue();

                // Assert PathwayAssessment
                var actualPathwayAssessment   = GetExpectedPathwayAssessment(uln, _actualResult);
                var expectedPathwayAssessment = GetExpectedPathwayAssessment(uln, expectedPathway);
                AssertPathwayAssessment(actualPathwayAssessment, expectedPathwayAssessment);
            }
            else
            {
                _actualResult.TqPathwayAssessments.Any().Should().BeFalse();
            }

            // Assert Industry Placement
            if (isIndustryPlacementExpected)
            {
                _actualResult.IndustryPlacements.Any().Should().BeTrue();

                var actualIndustryPlacement   = _actualResult.IndustryPlacements.FirstOrDefault();
                var expectedIndustryPlacement = expectedPathway.IndustryPlacements.FirstOrDefault(x => x.TqRegistrationPathwayId == expectedPathway.Id);
                AssertIndustryPlacement(actualIndustryPlacement, expectedIndustryPlacement);
            }
            else
            {
                _actualResult.IndustryPlacements.Any().Should().BeFalse();
            }
        }