Exemple #1
0
        public async Task Get_QAReport_For_Unable_To_CompleteQA(ApprenticeshipQAUnableToCompleteReasons unableReason)
        {
            //arange
            var ukprn          = 12345;
            var email          = "*****@*****.**";
            var providerName   = "Provider 1";
            var providerUserId = $"{ukprn}-user";
            var adminUserId    = $"admin-user";

            Clock.UtcNow = new DateTime(2019, 5, 17, 9, 3, 27, DateTimeKind.Utc);
            var requestedOn = Clock.UtcNow;
            var unableToCompleteComments = "QA Cannot be completed because x";

            var providerId = await TestData.CreateProvider(
                ukprn : ukprn,
                providerName : providerName,
                apprenticeshipQAStatus : ApprenticeshipQAStatus.UnableToComplete);

            var providerUser = await TestData.CreateUser(providerUserId, email, "Provider 1", "Person", providerId);

            var adminUser = await TestData.CreateUser(adminUserId, "admin", "admin", "admin", null);

            var standard = await TestData.CreateStandard(standardCode : 1234, version : 1, standardName : "Test Standard");

            var apprenticeshipId = await TestData.CreateApprenticeship(providerId, standard, createdBy : providerUser);

            // Create submission
            var submissionId = await TestData.CreateApprenticeshipQASubmission(
                providerId,
                submittedOn : Clock.UtcNow,
                submittedByUserId : providerUserId,
                providerMarketingInformation : "The overview",
                apprenticeshipIds : new[] { apprenticeshipId });

            // Create provider assessment
            Clock.UtcNow = Clock.UtcNow.AddDays(5);
            var unableToCompleteOn = Clock.UtcNow;
            await TestData.CreateApprenticeshipQAUnableToCompleteInfo(
                providerId,
                unableToCompleteReasons : unableReason,
                comments : unableToCompleteComments,
                addedByUserId : adminUserId,
                unableToCompleteOn);

            // Update submission
            await TestData.UpdateApprenticeshipQASubmission(
                submissionId,
                providerAssessmentPassed : false,
                apprenticeshipAssessmentsPassed : null,
                passed : null,
                lastAssessedByUserId : adminUserId,
                lastAssessedOn : unableToCompleteOn);

            // Act
            var response = await HttpClient.GetAsync($"apprenticeship-qa/report");

            // Assert
            var results = await response.AsCsvListOf <ReportModel>();

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Collection(results, item =>
            {
                Assert.Equal(ukprn, item.Ukprn);
                Assert.Equal(providerName, item.ProviderName);
                Assert.Equal(email, item.Email);
                Assert.Equal("No", item.PassedQA);
                Assert.Empty(item.PassedQAOn);
                Assert.Equal("No", item.FailedQA);
                Assert.Empty(item.FailedQAOn);
                Assert.Equal("Yes", item.UnableToComplete);
                Assert.Equal(unableToCompleteOn.ToString("dd MMM yyyy"), item.UnableToCompleteOn);
                Assert.Equal(unableToCompleteComments, item.Notes);
                Assert.Equal(item.UnableToCompleteReasons, unableReason.ToDescription());
                Assert.Equal(ApprenticeshipQAStatus.UnableToComplete.ToDescription(), item.QAStatus);
            });
        }