public override void Given()
        {
            _coreCode         = "10000111";
            _providerUkprn    = 12345678;
            ApiClientResponse = false;

            mockApiClientResponse = new RegistrationDetails
            {
                ProfileId     = 1,
                Uln           = Uln,
                ProviderUkprn = _providerUkprn,
                PathwayLarId  = "70000111",
            };

            ViewModel = new ReregisterViewModel
            {
                ReregisterProvider = new ReregisterProviderViewModel {
                    ProfileId = ProfileId
                },
                ReregisterCore = new ReregisterCoreViewModel {
                    ProfileId = ProfileId, SelectedCoreCode = _coreCode
                }
            };

            Loader = new RegistrationLoader(Mapper, Logger, InternalApiClient, BlobStorageService);

            InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ProfileId, RegistrationPathwayStatus.Withdrawn).Returns(mockApiClientResponse);
            InternalApiClient.ReregistrationAsync(Arg.Any <ReregistrationRequest>()).Returns(ApiClientResponse);
        }
        public override void Given()
        {
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            HttpContextAccessor.HttpContext.Returns(new DefaultHttpContext
            {
                User = new ClaimsPrincipal(new ClaimsIdentity(new[]
                {
                    new Claim(ClaimTypes.GivenName, _givename),
                    new Claim(ClaimTypes.Surname, _surname),
                    new Claim(ClaimTypes.Email, _email)
                }))
            });

            CreateMapper();

            BulkAssessmentRequest = new BulkProcessRequest {
                AoUkprn = Ukprn
            };

            BulkAssessmentResponse = new BulkAssessmentResponse
            {
                IsSuccess           = false,
                BlobUniqueReference = Guid.NewGuid(),
                ErrorFileSize       = 1.5
            };

            UploadAssessmentsRequestViewModel = new UploadAssessmentsRequestViewModel {
                AoUkprn = Ukprn, File = FormFile
            };
            InternalApiClient.ProcessBulkAssessmentsAsync(BulkAssessmentRequest).Returns(BulkAssessmentResponse);
            Loader = new AssessmentLoader(Mapper, Logger, InternalApiClient, BlobStorageService);
        }
Esempio n. 3
0
 public override void Given()
 {
     expectedApiResultDetails = new Models.Contracts.ResultDetails {
         PathwayAssessmentId = 999
     };
     InternalApiClient.GetResultDetailsAsync(AoUkprn, ProfileId, RegistrationPathwayStatus.Active).Returns(expectedApiResultDetails);
 }
Esempio n. 4
0
        public override void Given()
        {
            expectedApiLookupData = new List <LookupData>
            {
                new LookupData {
                    Id = 1, Code = "C1", Value = "V1"
                },
                new LookupData {
                    Id = 2, Code = "C2", Value = "V2"
                }
            };

            InternalApiClient.GetLookupDataAsync(LookupCategory.PathwayComponentGrade).Returns(expectedApiLookupData);

            expectedApiResultDetails = new ResultDetails
            {
                ProfileId               = ProfileId,
                PathwayAssessmentId     = AssessmentId,
                PathwayAssessmentSeries = "Summer 2021",
                PathwayLarId            = "12345678",
                PathwayName             = "Construction",
                PathwayResultId         = null,
            };
            InternalApiClient.GetResultDetailsAsync(AoUkprn, ProfileId, RegistrationPathwayStatus.Active).Returns(expectedApiResultDetails);
        }
 public override void Given()
 {
     expectedApiResult = new AssessmentDetails {
         PathwayResultId = 99
     };
     InternalApiClient.GetAssessmentDetailsAsync(AoUkprn, ProfileId).Returns(expectedApiResult);
 }
Esempio n. 6
0
        public async Task Then_If_Returns_Not_Found_Result_Returns_Empty_List(
            TestInternalApiConfiguration config)
        {
            //Arrange
            config.Url = "https://test.local";
            var configuration = config;
            var response      = new HttpResponseMessage
            {
                Content    = new StringContent(""),
                StatusCode = HttpStatusCode.NotFound
            };
            var getTestRequest     = new GetAllTestRequest();
            var expectedUrl        = $"{config.Url}{getTestRequest.GetAllUrl}";
            var httpMessageHandler = MessageHandler.SetupMessageHandlerMock(response, expectedUrl);
            var client             = new HttpClient(httpMessageHandler.Object);
            var clientFactory      = new Mock <IHttpClientFactory>();

            clientFactory.Setup(_ => _.CreateClient(It.IsAny <string>())).Returns(client);

            var hostingEnvironment = new Mock <IWebHostEnvironment>();

            hostingEnvironment.Setup(x => x.EnvironmentName).Returns("Development");
            var actual = new InternalApiClient <TestInternalApiConfiguration>(clientFactory.Object, configuration, hostingEnvironment.Object, Mock.Of <IAzureClientCredentialHelper>());

            //Act
            var actualResult = await actual.GetAll <string>(getTestRequest);

            //Assert
            Assert.IsEmpty(actualResult);
        }
        public override void Given()
        {
            var profileId = 1;
            var uln       = 1234567890;

            ViewModel = new ChangeLearnersNameViewModel {
                ProfileId = profileId, Firstname = reqFirstName, Lastname = reqLastName
            };

            mockRegDetails = new RegistrationDetails
            {
                Firstname = existingFirstName,
                Lastname  = existingLastName,
                Uln       = uln,
                ProfileId = profileId,
            };

            InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ViewModel.ProfileId, RegistrationPathwayStatus.Active)
            .Returns(mockRegDetails);

            InternalApiClient.UpdateRegistrationAsync(Arg.Is <ManageRegistration>
                                                          (x => x.Uln == mockRegDetails.Uln &&
                                                          x.ProfileId == mockRegDetails.ProfileId &&
                                                          x.FirstName == ViewModel.Firstname &&
                                                          x.LastName == ViewModel.Lastname))
            .Returns(true);
        }
        public override void Given()
        {
            expectedApiResult = new RegistrationDetails
            {
                ProfileId     = 1,
                Uln           = 1234567890,
                Firstname     = "John",
                Lastname      = "Smith",
                DateofBirth   = DateTime.UtcNow,
                ProviderName  = "Test Provider",
                ProviderUkprn = 1234567,
                PathwayName   = "Pathway",
                PathwayLarId  = "7654321",
                Specialisms   = new List <SpecialismDetails> {
                    new SpecialismDetails {
                        Code = "2345678", Name = "Specialism1"
                    }, new SpecialismDetails {
                        Code = "55567", Name = "Specialism2"
                    }
                },
                AcademicYear = 2020,
                Status       = RegistrationPathwayStatus.Active
            };

            InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ProfileId).Returns(expectedApiResult);
        }
 public override void Given()
 {
     ViewModel.ResultId       = 11;
     expectedApiResultDetails = new ResultDetails {
         PathwayResultId = ViewModel.ResultId, PathwayResultCode = ViewModel.SelectedGradeCode
     };
     InternalApiClient.GetResultDetailsAsync(AoUkprn, Arg.Any <int>(), RegistrationPathwayStatus.Active).Returns(expectedApiResultDetails);
 }
 public override void Given()
 {
     ViewModel = new ChangeSpecialismViewModel {
         ProfileId = 1
     };
     InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, Arg.Any <int>(), RegistrationPathwayStatus.Active)
     .Returns(mockRegDetails);
 }
Esempio n. 11
0
 public override void Given()
 {
     ViewModel = new ChangeSpecialismQuestionViewModel {
         ProfileId = 1
     };
     InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, Arg.Any <int>(), RegistrationPathwayStatus.Active)
     .Returns(mockResponse);
     Loader = new RegistrationLoader(Mapper, Logger, InternalApiClient, BlobStorageService);
 }
        public override void Given()
        {
            IsChangeMode = true;

            expectedApiResultDetails = new Models.Contracts.ResultDetails {
                PathwayResultId = null
            };
            InternalApiClient.GetResultDetailsAsync(AoUkprn, ProfileId, RegistrationPathwayStatus.Active).Returns(expectedApiResultDetails);
        }
Esempio n. 13
0
        public override void Given()
        {
            expectedApiResultDetails = new ResultDetails {
                PathwayAssessmentId = AssessmentId
            };
            InternalApiClient.GetResultDetailsAsync(AoUkprn, ProfileId, RegistrationPathwayStatus.Active).Returns(expectedApiResultDetails);

            expectedApiLookupData = new List <LookupData>();
            InternalApiClient.GetLookupDataAsync(LookupCategory.PathwayComponentGrade).Returns(expectedApiLookupData);
        }
 public override void Given()
 {
     ProviderUkprn      = 87945612;
     ProfileId          = 0;
     _expectedApiResult = null;
     ViewModel          = new UpdateEnglishAndMathsQuestionViewModel {
         ProfileId = ProfileId, EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
     };
     InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId).Returns(_expectedApiResult);
 }
 public void Then_Expected_Methods_AreCalled()
 {
     InternalApiClient.Received(1).GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId);
     InternalApiClient.Received(1).UpdateLearnerRecordAsync(Arg.Is <UpdateLearnerRecordRequest>
                                                                (x => x.ProfileId == ViewModel.ProfileId &&
                                                                x.Ukprn == ProviderUkprn &&
                                                                x.Uln == _expectedApiResult.Uln &&
                                                                x.EnglishAndMathsStatus == ViewModel.EnglishAndMathsStatus &&
                                                                x.PerformedBy == $"{Givenname} {Surname}"));
 }
 public void Then_Expected_Methods_AreCalled()
 {
     InternalApiClient.Received(1).GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId, RegistrationPathwayId);
     InternalApiClient.Received(1).UpdateLearnerRecordAsync(Arg.Is <UpdateLearnerRecordRequest>
                                                                (x => x.ProfileId == ViewModel.ProfileId &&
                                                                x.Ukprn == ProviderUkprn &&
                                                                x.RegistrationPathwayId == ViewModel.RegistrationPathwayId &&
                                                                x.IndustryPlacementId == ViewModel.IndustryPlacementId &&
                                                                x.IndustryPlacementStatus == ViewModel.IndustryPlacementStatus &&
                                                                x.PerformedBy == $"{Givenname} {Surname}"));
 }
        public override void Given()
        {
            expectedApiResult = new AssessmentEntryDetails
            {
                ProfileId            = 1,
                AssessmentId         = 5,
                AssessmentSeriesName = "Summer 2021"
            };

            InternalApiClient.GetActiveAssessmentEntryDetailsAsync(AoUkprn, ProfileId, componentType).Returns(expectedApiResult);
        }
        public override void Given()
        {
            mockResult = new RegistrationDetails
            {
                ProfileId = 1,
                Firstname = "John",
                Lastname  = "Smith",
            };

            InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ProfileId, RegistrationPathwayStatus.Active).Returns(mockResult);
        }
Esempio n. 19
0
        public async Task Then_The_Endpoint_Is_Called_And_Content_Returned_With_Response_Code(
            string authToken,
            string postContent,
            int id,
            string responseContent,
            TestInternalApiConfiguration config)
        {
            //Arrange
            var azureClientCredentialHelper = new Mock <IAzureClientCredentialHelper>();

            azureClientCredentialHelper.Setup(x => x.GetAccessTokenAsync(config.Identifier)).ReturnsAsync(authToken);
            config.Url = "https://test.local";
            var testObject = JsonConvert.SerializeObject(new TestResponse {
                MyResponse = responseContent
            });
            var response = new HttpResponseMessage
            {
                Content    = new StringContent(testObject),
                StatusCode = HttpStatusCode.Created
            };
            var postTestRequest = new PostTestRequest(id)
            {
                Data = postContent
            };
            var expectedUrl        = $"{config.Url}{postTestRequest.PostUrl}";
            var httpMessageHandler = MessageHandler.SetupMessageHandlerMock(response, expectedUrl, "post");
            var client             = new HttpClient(httpMessageHandler.Object);
            var hostingEnvironment = new Mock <IWebHostEnvironment>();
            var clientFactory      = new Mock <IHttpClientFactory>();

            clientFactory.Setup(_ => _.CreateClient(It.IsAny <string>())).Returns(client);

            hostingEnvironment.Setup(x => x.EnvironmentName).Returns("Staging");
            var actual = new InternalApiClient <TestInternalApiConfiguration>(clientFactory.Object, config, hostingEnvironment.Object, azureClientCredentialHelper.Object);

            //Act
            var actualResult = await actual.PostWithResponseCode <TestResponse>(postTestRequest);

            //Assert
            httpMessageHandler.Protected()
            .Verify <Task <HttpResponseMessage> >(
                "SendAsync", Times.Once(),
                ItExpr.Is <HttpRequestMessage>(c =>
                                               c.Method.Equals(HttpMethod.Post) &&
                                               c.RequestUri.AbsoluteUri.Equals(expectedUrl) &&
                                               c.Headers.Authorization.Scheme.Equals("Bearer") &&
                                               c.Headers.FirstOrDefault(h => h.Key.Equals("X-Version")).Value.FirstOrDefault() == "2.0" &&
                                               c.Headers.Authorization.Parameter.Equals(authToken)),
                ItExpr.IsAny <CancellationToken>()
                );

            actualResult.StatusCode.Should().Be(HttpStatusCode.Created);
            actualResult.Body.MyResponse.Should().Be(responseContent);
        }
Esempio n. 20
0
        public override void Given()
        {
            ViewModel = new ChangeLearnersNameViewModel {
                ProfileId = 1, Firstname = firstName, Lastname = lastName
            };
            regDetailsMock = new RegistrationDetails {
                Firstname = firstName.Trim().ToUpper(), Lastname = lastName.Trim().ToUpper()
            };

            InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ViewModel.ProfileId, RegistrationPathwayStatus.Active)
            .Returns(regDetailsMock);
        }
        public override void Given()
        {
            ApiClientResponse = new ProviderTlevels
            {
                Id          = 1,
                DisplayName = "Test1",
                Ukprn       = 12345
            };

            InternalApiClient.GetAllProviderTlevelsAsync(Ukprn, ProviderId).Returns(ApiClientResponse);
            Loader = new ProviderLoader(InternalApiClient, Mapper);
        }
Esempio n. 22
0
        public override void Given()
        {
            ApiClientResponse = new List <AwardingOrganisationPathwayStatus>
            {
                new AwardingOrganisationPathwayStatus {
                    Id = 1, PathwayId = PathwayId, TlevelTitle = "Tlevel Title", StatusId = 2
                },
            };

            InternalApiClient.GetAllTlevelsByUkprnAsync(Ukprn).Returns(ApiClientResponse);
            Loader = new TlevelLoader(InternalApiClient, Mapper);
        }
Esempio n. 23
0
 public override void Given()
 {
     ApiClientResponse = true;
     ViewModel         = new WithdrawRegistrationViewModel {
         ProfileId = 1, Uln = Uln
     };
     Loader          = new RegistrationLoader(Mapper, Logger, InternalApiClient, BlobStorageService);
     withdrawRequest = new WithdrawRegistrationRequest {
         AoUkprn = AoUkprn, ProfileId = ProfileId, PerformedBy = $"{Givenname} {Surname}"
     };
     InternalApiClient.WithdrawRegistrationAsync(Arg.Any <WithdrawRegistrationRequest>()).Returns(ApiClientResponse);
 }
        public override void Given()
        {
            expectedApiResult = new FindUlnResponse
            {
                RegistrationProfileId = 1,
                Uln = Uln,
                IsRegisteredWithOtherAo = true,
                Status = Common.Enum.RegistrationPathwayStatus.Active
            };

            InternalApiClient.FindUlnAsync(Ukprn, Uln).Returns(expectedApiResult);
        }
        public override void Given()
        {
            ProviderUkprn         = 87945612;
            ProfileId             = 0;
            RegistrationPathwayId = 1;

            _expectedApiResult = null;
            ViewModel          = new UpdateIndustryPlacementQuestionViewModel {
                ProfileId = ProfileId, RegistrationPathwayId = RegistrationPathwayId, IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };
            InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId, RegistrationPathwayId).Returns(_expectedApiResult);
        }
Esempio n. 26
0
 public override void Given()
 {
     ProviderUkprn      = 87945612;
     ProfileId          = 1;
     _expectedApiResult = new LearnerRecordDetails {
         ProfileId = 1, IsLearnerRecordAdded = true, HasLrsEnglishAndMaths = false, IsEnglishAndMathsAchieved = true, IsSendLearner = false
     };
     ViewModel = new UpdateEnglishAndMathsQuestionViewModel {
         ProfileId = 1, EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
     };
     InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId).Returns(_expectedApiResult);
 }
        public override void Given()
        {
            CreateMapper();
            ProviderUkprn = 987654321;

            SoaLearnerRecordDetailsViewModel = new SoaLearnerRecordDetailsViewModel
            {
                ProfileId     = 10,
                Uln           = 1234567890,
                LearnerName   = "John Smith",
                DateofBirth   = DateTime.Now.AddYears(-20),
                ProviderName  = "Barsley College",
                ProviderUkprn = 456789123,

                TlevelTitle           = "Design, Surveying and Planning for Construction",
                RegistrationPathwayId = 1,
                PathwayDisplayName    = "Design, Surveying and Planning for Construction (60358300)",
                PathwayName           = "Design, Surveying and Planning for Construction",
                PathwayCode           = "60358300",
                PathwayGrade          = "A*",
                SpecialismDisplayName = "Building Services Design (ZTLOS003)",
                SpecialismName        = "Building Services Design",
                SpecialismCode        = "ZTLOS003",
                SpecialismGrade       = "None",

                IsEnglishAndMathsAchieved = true,
                HasLrsEnglishAndMaths     = false,
                IsSendLearner             = true,
                IndustryPlacementStatus   = IndustryPlacementStatus.NotCompleted,

                HasPathwayResult             = false,
                IsNotWithdrawn               = false,
                IsLearnerRegistered          = true,
                IsIndustryPlacementAdded     = true,
                IsIndustryPlacementCompleted = false,

                ProviderAddress = new AddressViewModel {
                    AddressId = 10, DepartmentName = "Operations", OrganisationName = "College Ltd", AddressLine1 = "10, House", AddressLine2 = "Street", Town = "Birmingham", Postcode = "B1 1AA"
                },
            };

            _expectedApiResult = new SoaPrintingResponse {
                Uln = SoaLearnerRecordDetailsViewModel.Uln, LearnerName = SoaLearnerRecordDetailsViewModel.LearnerName, IsSuccess = true
            };

            InternalApiClient.CreateSoaPrintingRequestAsync(Arg.Any <SoaPrintingRequest>()).Returns(_expectedApiResult);

            Loader = new StatementOfAchievementLoader(InternalApiClient, Mapper);
        }
        public override void Given()
        {
            ViewModel = new ChangeDateofBirthViewModel {
                Day = "1", Month = "2", Year = "2000"
            };

            regDetailsMock = new RegistrationDetails
            {
                DateofBirth = ViewModel.DateofBirth.ToDateTime(),
                ProfileId   = ViewModel.ProfileId,
            };

            InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ViewModel.ProfileId, RegistrationPathwayStatus.Active)
            .Returns(regDetailsMock);
        }
Esempio n. 29
0
        public override void Given()
        {
            expectedApiResult = new ResultDetails
            {
                ProfileId     = 1,
                Uln           = 1234567890,
                Firstname     = "John",
                Lastname      = "Smith",
                ProviderUkprn = 1234567,
                ProviderName  = "Test Provider",
                Status        = RegistrationPathwayStatus.Active
            };

            InternalApiClient.GetResultDetailsAsync(AoUkprn, ProfileId).Returns(expectedApiResult);
        }
        public override void Given()
        {
            ProviderUkprn = 9874561231;

            _expectedApiResult = new Address
            {
                DepartmentName   = "Dept",
                OrganisationName = "Org",
                AddressLine1     = "Line1",
                AddressLine2     = "Line2",
                Town             = "Town",
                Postcode         = "x11 1yy"
            };
            InternalApiClient.GetAddressAsync(ProviderUkprn).Returns(_expectedApiResult);
        }