示例#1
0
        public async Task Then_the_viewmodel_reflects_that_the_account_holder_can_change_their_provided_bank_details()
        {
            // Arrange
            var applicationsResponse = new GetApplicationsModel
            {
                BankDetailsStatus           = BankDetailsStatus.Completed,
                ApprenticeApplications      = _fixture.CreateMany <ApprenticeApplicationModel>(5).ToList(),
                FirstSubmittedApplicationId = Guid.NewGuid()
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(applicationsResponse);

            // Act
            var viewResult = await _sut.Index(_accountId, _accountLegalEntityId) as ViewResult;

            // Assert
            viewResult.Should().NotBeNull();
            var model = viewResult.Model as HubPageViewModel;

            model.Should().NotBeNull();
            model.OrganisationName.Should().Be(_legalEntities[0].Name);
            model.ShowBankDetailsRequired.Should().BeFalse();
            model.BankDetailsApplicationId.Should().NotBeEmpty();
            model.ShowAmendBankDetails.Should().BeTrue();
            model.AccountId.Should().Be(_accountId);
            model.AccountLegalEntityId.Should().Be(_accountLegalEntityId);
        }
示例#2
0
        public void Arrange()
        {
            _fixture              = new Fixture();
            _accountId            = _fixture.Create <string>();
            _accountLegalEntityId = _fixture.Create <string>();

            _legalEntitiesService                  = new Mock <ILegalEntitiesService>();
            _legalEntities                         = _fixture.CreateMany <LegalEntityModel>(1).ToList();
            _legalEntities[0].AccountId            = _accountId;
            _legalEntities[0].AccountLegalEntityId = _accountLegalEntityId;
            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(_legalEntities);

            _applicationService = new Mock <IApprenticeshipIncentiveService>();
            var applicationsResponse = new GetApplicationsModel
            {
                BankDetailsStatus           = BankDetailsStatus.Completed,
                ApprenticeApplications      = _fixture.CreateMany <ApprenticeApplicationModel>(5).ToList(),
                FirstSubmittedApplicationId = Guid.NewGuid()
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(applicationsResponse);

            _configuration = new Mock <IOptions <ExternalLinksConfiguration> >();
            var config = new ExternalLinksConfiguration {
                ManageApprenticeshipSiteUrl = "https://manage-apprentices.com"
            };

            _configuration.Setup(x => x.Value).Returns(config);

            _sut = new Web.Controllers.HubController(_legalEntitiesService.Object, _applicationService.Object, _configuration.Object);
        }
示例#3
0
        private void AnEmployerHasASingleSubmittedApplication(Guid applicationId, BankDetailsStatus bankDetailsStatus = BankDetailsStatus.Completed)
        {
            _testData = new TestData.Account.WithInitialApplicationForASingleEntity();
            _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
            _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);

            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.AccountId, _testData.AccountId)
                .Create()
            };

            applications[0].Status = "Submitted";
            var getApplications = new GetApplicationsModel {
                ApprenticeApplications = applications, BankDetailsStatus = bankDetailsStatus, FirstSubmittedApplicationId = applicationId
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
        public async Task Then_applications_are_sorted_by_application_date_ascending()
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.AddRange(_fixture.CreateMany <ApprenticeApplicationModel>(2));
            applications[0].ApplicationDate = new DateTime(2020, 09, 01);
            applications[1].ApplicationDate = new DateTime(2020, 08, 20);
            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _apprenticeshipIncentiveService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, ApplicationsSortOrder.Ascending, ApplicationsSortField.ApplicationDate) as ViewResult;

            // Assert
            result.Should().NotBeNull();
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            var modelApplications = viewModel.Applications.ToArray();

            modelApplications[0].ApplicationDate.Should().Be(applications[1].ApplicationDate);
            modelApplications[1].ApplicationDate.Should().Be(applications[0].ApplicationDate);
        }
示例#5
0
        public void GivenAnEmployerHasNoApplications()
        {
            var applications    = new List <ApprenticeApplicationModel>();
            var getApplications = new GetApplicationsModel
            {
                ApprenticeApplications = applications, BankDetailsStatus = BankDetailsStatus.NotSupplied
            };

            _testData = new TestData.Account.WithInitialApplicationForASingleEntity();
            _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
            _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(
                    $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
        public async Task Then_the_view_contains_summary_for_submitted_applications()
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.AddRange(_fixture.CreateMany <ApprenticeApplicationModel>(5));

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications, FirstSubmittedApplicationId = Guid.NewGuid()
            };

            _apprenticeshipIncentiveService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, _sortOrder, _sortField) as ViewResult;

            // Assert
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            viewModel.Applications.Count().Should().Be(applications.Count());
            viewModel.AddBankDetailsLink.Should().Be($":///{_accountId}/bank-details/{getApplicationsResponse.FirstSubmittedApplicationId}/add-bank-details");
        }
        public async Task Then_employment_check_status_message_is_not_shown_if_employment_check_passed()
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.Add(
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.FirstPaymentStatus, _fixture.Build <PaymentStatusModel>().With(p => p.EmploymentCheckPassed, true).Create())
                .With(p => p.SecondPaymentStatus, _fixture.Build <PaymentStatusModel>().With(p => p.EmploymentCheckPassed, true).Create())
                .Create());

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, _sortOrder, _sortField) as ViewResult;

            // Assert
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            viewModel.Applications.First().FirstPaymentStatus.EmploymentCheckPassed.Should().BeTrue();
            viewModel.Applications.First().SecondPaymentStatus.EmploymentCheckPassed.Should().BeTrue();
        }
        public async Task Then_a_shutter_page_is_shown_if_no_applcations()
        {
            // Arrange
            var applications            = new List <ApprenticeApplicationModel>();
            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _apprenticeshipIncentiveService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, _sortOrder, _sortField) as RedirectToActionResult;

            // Assert
            result.Should().NotBeNull();
            result.ActionName.Should().Be("NoApplications");
        }
示例#9
0
        public void GivenTheEmployerHasPreviouslySuppliedTheirBankDetails()
        {
            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Create <ApprenticeApplicationModel>()
            };

            var getApplications = new GetApplicationsModel
            {
                ApprenticeApplications      = applications,
                BankDetailsStatus           = BankDetailsStatus.Completed,
                FirstSubmittedApplicationId = _applicationId
            };

            var testData = new TestData.Account.WithInitialApplicationForASingleEntity();

            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, testData.HashedAccountId);

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{testData.AccountId}/legalentity/{testData.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
示例#10
0
        public EmployerIncentivesApiBuilder WithPreviousApplications()
        {
            var data = new TestData.Account.WithPreviousApplicationsForFirstLegalEntity();

            var applications = new List <ApprenticeApplicationModel> {
                data.Application1, data.Application2, data.Application3, data.Application4, data.Application5
            };
            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications, BankDetailsStatus = BankDetailsStatus.NotSupplied
            };

            _server
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{data.AccountId}/legalentity/{data.AccountLegalEntityId1}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplicationsResponse)));

            AddClaim(EmployerClaimTypes.Account, data.HashedAccountId);

            return(this);
        }
        public async Task Then_accept_new_employer_agreement_is_shown_if_an_application_has_payment_status_that_requires_new_agreement(
            bool?firstPaymentStatusRequiresNewAgreement,
            bool?secondPaymentStatusRequiresNewAgreement,
            bool showAcceptNewEmployerAgreement)
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.Add(
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.FirstPaymentStatus, firstPaymentStatusRequiresNewAgreement.HasValue ? _fixture.Build <PaymentStatusModel>().With(p => p.RequiresNewEmployerAgreement, firstPaymentStatusRequiresNewAgreement).Create() : null)
                .With(p => p.SecondPaymentStatus, secondPaymentStatusRequiresNewAgreement.HasValue ? _fixture.Build <PaymentStatusModel>().With(p => p.RequiresNewEmployerAgreement, secondPaymentStatusRequiresNewAgreement).Create() : null)
                .Create());

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, _sortOrder, _sortField) as ViewResult;

            // Assert
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            viewModel.ShowAcceptNewEmployerAgreement.Should().Be(showAcceptNewEmployerAgreement);
            viewModel.ViewAgreementLink = $"{_manageApprenticeshipSiteUrl}/accounts/{_accountId}/agreements";
            if (firstPaymentStatusRequiresNewAgreement.HasValue)
            {
                viewModel.Applications.First().FirstPaymentStatus.RequiresNewEmployerAgreement = firstPaymentStatusRequiresNewAgreement.Value;
                viewModel.Applications.First().FirstPaymentStatus.ViewAgreementLink = $"{_manageApprenticeshipSiteUrl}/accounts/{_accountId}/agreements";
            }
            else
            {
                viewModel.Applications.First().FirstPaymentStatus.Should().BeNull();
            }
            if (secondPaymentStatusRequiresNewAgreement.HasValue)
            {
                viewModel.Applications.First().SecondPaymentStatus.RequiresNewEmployerAgreement = secondPaymentStatusRequiresNewAgreement.Value;
                viewModel.Applications.First().SecondPaymentStatus.ViewAgreementLink = $"{_manageApprenticeshipSiteUrl}/accounts/{_accountId}/agreements";
            }
            else
            {
                viewModel.Applications.First().SecondPaymentStatus.Should().BeNull();
            }
        }
        public async Task Then_applications_are_sorted_by_sort_field_and_then_by_name_and_ULN()
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.AddRange(_fixture.CreateMany <ApprenticeApplicationModel>(3));
            applications[0].ULN        = 999;
            applications[0].CourseName = "Engineering";
            applications[0].FirstName  = "Adam";
            applications[0].LastName   = "Smith";
            applications[1].ULN        = 444;
            applications[1].CourseName = "Manufacturing";
            applications[0].FirstName  = "Shauna";
            applications[0].LastName   = "Smith";
            applications[2].ULN        = 222;
            applications[2].CourseName = "Engineering";
            applications[0].FirstName  = "Adam";
            applications[0].LastName   = "Smith";

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _apprenticeshipIncentiveService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, ApplicationsSortOrder.Ascending, ApplicationsSortField.CourseName) as ViewResult;

            // Assert
            result.Should().NotBeNull();
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            var modelApplications = viewModel.Applications.ToArray();

            modelApplications[0].ULN.Should().Be(applications[2].ULN);
            modelApplications[1].ULN.Should().Be(applications[0].ULN);
            modelApplications[2].ULN.Should().Be(applications[1].ULN);
        }
示例#13
0
        private void AnEmployerHasAnApplicationWithAnAgreementVersionThatNeedsSigning(Guid applicationId)
        {
            _testData = new TestData.Account.WithInitialApplicationForASingleEntity();
            _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
            _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);

            ClawbackStatusModel clawbackStatus = null;

            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.AccountId, _testData.AccountId)
                .With(p => p.FirstPaymentStatus,
                      _fixture.Build <PaymentStatusModel>()
                      .With(p => p.RequiresNewEmployerAgreement, true)
                      .With(p => p.PaymentIsStopped, false)
                      .With(p => p.WithdrawnByCompliance, false)
                      .With(p => p.WithdrawnByEmployer, false)
                      .With(p => p.EmploymentCheckPassed, true)
                      .Without(p => p.IsClawedBack)
                      .Create()
                      )
                .With(p => p.FirstClawbackStatus, clawbackStatus)
                .With(p => p.SecondClawbackStatus, clawbackStatus)
                .Create()
            };

            var getApplications = new GetApplicationsModel
            {
                ApprenticeApplications = applications, FirstSubmittedApplicationId = applicationId
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(
                    $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
示例#14
0
        private void AnApplicationWithAFailedEmploymentCheck(Guid applicationId)
        {
            _testData = new TestData.Account.WithInitialApplicationForASingleEntity();
            _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
            _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);

            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.AccountId, _testData.AccountId)
                .With(p => p.FirstPaymentStatus,
                      _fixture.Build <PaymentStatusModel>()
                      .With(p => p.EmploymentCheckPassed, false)
                      .Create()
                      )
                .With(p => p.SecondPaymentStatus,
                      _fixture.Build <PaymentStatusModel>()
                      .With(p => p.EmploymentCheckPassed, false)
                      .Create()
                      )
                .Without(p => p.FirstClawbackStatus)
                .Without(p => p.SecondClawbackStatus)
                .Create()
            };

            var getApplications = new GetApplicationsModel
            {
                ApprenticeApplications = applications, FirstSubmittedApplicationId = applicationId
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(
                    $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
        public async Task Then_employment_check_status_message_is_not_shown_if_employment_check_result_not_set()
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.Add(
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.FirstPaymentStatus, _fixture.Build <PaymentStatusModel>().Without(p => p.EmploymentCheckPassed).Create())
                .With(p => p.SecondPaymentStatus, _fixture.Build <PaymentStatusModel>().Without(p => p.EmploymentCheckPassed).Create())
                .Create());

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            _sut = new Web.Controllers.PaymentsController(_applicationService.Object, _legalEntitiesService.Object, _linksConfiguration.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                }
            };

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, _sortOrder, _sortField) as ViewResult;

            // Assert
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            viewModel.Applications.First().FirstPaymentStatus.EmploymentCheckPassed.HasValue.Should().BeFalse();
            viewModel.Applications.First().SecondPaymentStatus.EmploymentCheckPassed.HasValue.Should().BeFalse();
        }
        public void GivenTheEmployerAccountHasASingleOrganisation()
        {
            var accountLegalEntityId = _fixture.Create <long>();

            var legalEntities = new List <LegalEntityDto>
            {
                new LegalEntityDto {
                    AccountId = _accountId, AccountLegalEntityId = accountLegalEntityId
                }
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_accountId}/legalentities")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(legalEntities)));

            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Create <ApprenticeApplicationModel>()
            };
            var getApplications = new GetApplicationsModel {
                ApprenticeApplications = applications, BankDetailsStatus = BankDetailsStatus.NotSupplied
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_accountId}/legalentity/{accountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
示例#17
0
        public async Task Then_the_bank_details_banner_content_should_be_shown_if_none_supplied_and_the_cut_off_date_has_elapsed(BankDetailsStatus bankDetailsStatus)
        {
            // Arrange
            var applicationsResponse = new GetApplicationsModel
            {
                BankDetailsStatus           = bankDetailsStatus,
                ApprenticeApplications      = _fixture.CreateMany <ApprenticeApplicationModel>(5).ToList(),
                FirstSubmittedApplicationId = Guid.NewGuid()
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(applicationsResponse);

            // Act
            var viewResult = await _sut.Index(_accountId, _accountLegalEntityId) as ViewResult;

            // Assert
            var viewModel = viewResult.Model as HubPageViewModel;

            viewModel.ShowBankDetailsRequired.Should().BeTrue();
        }
示例#18
0
        private void AnApplicationWithAnUnsentClawedBackPayment(Guid applicationId)
        {
            _testData = new TestData.Account.WithInitialApplicationForASingleEntity();
            _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
            _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);

            var clawbackStatus = new ClawbackStatusModel
            {
                ClawbackDate        = _fixture.Create <DateTime>(), // unset still has a clawback date
                ClawbackAmount      = _fixture.Create <decimal>(),
                OriginalPaymentDate = _fixture.Create <DateTime>()
            };

            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.AccountId, _testData.AccountId)
                .With(p => p.FirstClawbackStatus, clawbackStatus)
                .Without(p => p.SecondClawbackStatus)
                .Create()
            };

            var getApplications = new GetApplicationsModel
            {
                ApprenticeApplications = applications, FirstSubmittedApplicationId = applicationId
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(
                    $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }
示例#19
0
        public async Task Then_a_list_of_applications_is_received()
        {
            var applicationList = new List <ApprenticeApplicationModel>
            {
                _fixture.Create <ApprenticeApplicationModel>(),
                _fixture.Create <ApprenticeApplicationModel>()
            };
            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applicationList, BankDetailsStatus = BankDetailsStatus.InProgress
            };

            _httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent <GetApplicationsModel>(getApplicationsResponse, new JsonMediaTypeFormatter(), "application/json")
            };

            _httpClientHandlerFake.ExpectedResponseMessage = _httpResponseMessage;

            var response = await _sut.GetList(_accountId, _accountLegalEntityId);

            response.ApprenticeApplications.Count().Should().Be(2);
        }
        public async Task Then_withdrawn_message_is_shown_when_the_apprenticeship_incentive_is_in_withdrawn_by_employer(
            bool firstPaymentStatusPaymentIsWithdrawn,
            bool secondPaymentStatusPaymentIsWithdrawn,
            bool showWithdrawnMessageInFirstColumn,
            bool showWithdrawnMessageInSecondColumn)
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.Add(
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.FirstPaymentStatus, _fixture.Build <PaymentStatusModel>().With(p => p.WithdrawnByEmployer, firstPaymentStatusPaymentIsWithdrawn).Create())
                .With(p => p.SecondPaymentStatus, _fixture.Build <PaymentStatusModel>().With(p => p.WithdrawnByEmployer, secondPaymentStatusPaymentIsWithdrawn).Create())
                .Create());

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, _sortOrder, _sortField) as ViewResult;

            // Assert
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            viewModel.Applications.First().FirstPaymentStatus.WithdrawnByEmployer.Should().Be(showWithdrawnMessageInFirstColumn);
            viewModel.Applications.First().SecondPaymentStatus.WithdrawnByEmployer.Should().Be(showWithdrawnMessageInSecondColumn);
        }
示例#21
0
        public async Task Then_accept_new_employer_agreement_is_shown_if_an_application_has_payment_status_that_requires_new_agreement(
            bool?firstPaymentStatusRequiresNewAgreement,
            bool?secondPaymentStatusRequiresNewAgreement,
            bool showAcceptNewEmployerAgreement)
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.Add(
                _fixture.Build <ApprenticeApplicationModel>()
                .With(p => p.FirstPaymentStatus, firstPaymentStatusRequiresNewAgreement.HasValue ? _fixture.Build <PaymentStatusModel>().With(p => p.RequiresNewEmployerAgreement, firstPaymentStatusRequiresNewAgreement).Create() : null)
                .With(p => p.SecondPaymentStatus, secondPaymentStatusRequiresNewAgreement.HasValue ? _fixture.Build <PaymentStatusModel>().With(p => p.RequiresNewEmployerAgreement, secondPaymentStatusRequiresNewAgreement).Create() : null)
                .Create());

            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications, FirstSubmittedApplicationId = Guid.NewGuid()
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var viewResult = await _sut.Index(_accountId, _accountLegalEntityId) as ViewResult;

            // Assert
            var viewModel = viewResult.Model as HubPageViewModel;

            viewModel.Should().NotBeNull();
            viewModel.ShowAcceptNewEmployerAgreement.Should().Be(showAcceptNewEmployerAgreement);
            viewModel.ViewAgreementLink.Should().Be($"{_manageApprenticeshipSiteUrl}/accounts/{_accountId}/agreements");
        }
        public async Task Then_the_default_sort_order_is_ascending_by_apprentice_name(string orderByText)
        {
            // Arrange
            var applications = new List <ApprenticeApplicationModel>();

            applications.AddRange(_fixture.CreateMany <ApprenticeApplicationModel>(2));
            applications[0].FirstName = "Steve";
            applications[0].LastName  = "Jones";
            applications[1].FirstName = "Freda";
            applications[1].LastName  = "Johnson";
            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = applications
            };

            _apprenticeshipIncentiveService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            var legalEntities = new List <LegalEntityModel> {
                new LegalEntityModel {
                    AccountId = _accountId, AccountLegalEntityId = _accountLegalEntityId
                }
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.ListPaymentsForLegalEntity(_accountId, _accountLegalEntityId, ApplicationsSortOrder.Ascending, ApplicationsSortField.ApprenticeName) as ViewResult;

            // Assert
            result.Should().NotBeNull();
            var viewModel = result.Model as ViewApplicationsViewModel;

            viewModel.Should().NotBeNull();
            var modelApplications = viewModel.Applications.ToArray();

            modelApplications[0].ApprenticeName.Should().Be(applications[1].ApprenticeName);
            modelApplications[1].ApprenticeName.Should().Be(applications[0].ApprenticeName);
        }
示例#23
0
        public async Task Then_the_bank_details_banner_content_should_be_not_shown_if_none_supplied_and_the_cut_off_date_has_elapsed_and_no_applications_submitted(BankDetailsStatus bankDetailsStatus)
        {
            // Arrange
            var webConfig = new WebConfigurationOptions {
                ApplicationShutterPageDate = DateTime.Now.ToString()
            };

            _webConfiguration.Setup(x => x.Value).Returns(webConfig);
            var getApplicationsResponse = new GetApplicationsModel {
                ApprenticeApplications = new List <ApprenticeApplicationModel>(), FirstSubmittedApplicationId = null, BankDetailsStatus = bankDetailsStatus
            };

            _applicationService.Setup(x => x.GetList(_accountId, _accountLegalEntityId)).ReturnsAsync(getApplicationsResponse);

            _sut = new Web.Controllers.HubController(_legalEntitiesService.Object, _applicationService.Object, _externalLinksConfiguration.Object, _webConfiguration.Object);

            // Act
            var viewResult = await _sut.Index(_accountId, _accountLegalEntityId) as ViewResult;

            // Assert
            var viewModel = viewResult.Model as HubPageViewModel;

            viewModel.ShowBankDetailsRequired.Should().BeFalse();
        }
 private static bool CanAmendBankDetails(GetApplicationsModel applications)
 {
     return(applications.BankDetailsStatus == BankDetailsStatus.Completed);
 }
 private static bool BankDetailsRequired(GetApplicationsModel applications)
 {
     return(applications.BankDetailsStatus == BankDetailsStatus.NotSupplied || applications.BankDetailsStatus == BankDetailsStatus.Rejected);
 }
        private void GivenAnEmployerWithALaterAgreementVersionThatIs(bool isSigned)
        {
            var testdata = new TestData.Account.WithSingleLegalEntityWithEligibleApprenticeships();

            _testDataStore.Add("HashedAccountId", testdata.HashedAccountId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, testdata.HashedAccountId);
            _testDataStore.Add("HashedAccountLegalEntityId", testdata.HashedAccountLegalEntityId);

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{testdata.AccountId}/legalentities")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(testdata.LegalEntities, TestHelper.DefaultSerialiserSettings)));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/apprenticeships")
                .WithParam("accountid", testdata.AccountId.ToString())
                .WithParam("accountlegalentityid", testdata.LegalEntities.First().AccountLegalEntityId.ToString())
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(testdata.Apprentices, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{testdata.AccountId}/legalentities/{testdata.LegalEntities.First().AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(testdata.LegalEntities.First()))
                .WithStatusCode(HttpStatusCode.OK));

            var applications = new List <ApprenticeApplicationModel>
            {
                new ApprenticeApplicationModel {
                    AccountId = testdata.AccountId, ApplicationDate = new DateTime(2020, 09, 01), FirstName = "Jane", LastName = "Doe", TotalIncentiveAmount = 1500m, LegalEntityName = $"Organisation {testdata.LegalEntities.First().AccountLegalEntityId}", ULN = 900004567, CourseName = "Accounting", FirstPaymentStatus = new PaymentStatusModel {
                        RequiresNewEmployerAgreement = isSigned
                    }
                }
            };

            var getApplications = new GetApplicationsModel {
                ApprenticeApplications = applications, FirstSubmittedApplicationId = Guid.NewGuid()
            };

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{testdata.AccountId}/legalentity/{testdata.LegalEntities.First().AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(getApplications)));
        }