Exemplo n.º 1
0
        public void GivenAnEmployerHasMultipleSubmittedApplications()
        {
            var applications = new List <ApprenticeApplicationModel>
            {
                _fixture.Create <ApprenticeApplicationModel>(),
                _fixture.Create <ApprenticeApplicationModel>()
            };
            var getApplications = new GetApplicationsModel {
                ApprenticeApplications = applications, BankDetailsStatus = BankDetailsStatus.InProgress
            };

            _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)));
        }
Exemplo n.º 2
0
        public void GivenAnEmployerApplyingForAGrantHasAlreadySelectedEligibleApprentices(int p0)
        {
            _testData = new TestData.Account.WithInitialApplicationForASingleEntity();
            _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);

            SetupServiceMocks(_testData.ApplicationResponse);
        }
        public void GivenAnEmployerApplyingForAGrantHasExistingAppliedForApprenticeshipIncentives()
        {
            _apprenticeshipData = _data.ApprenticeshipIncentives;
            _legalEntity        = _data.LegalEntities.First();

            var accountId = _testData.GetOrCreate("AccountId", onCreate: () => _data.AccountId);

            _testData.Add("HashedAccountId", _hashingService.HashValue(accountId));
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _hashingService.HashValue(accountId));
            var accountLegalEntityId = _testData.GetOrCreate("AccountLegalEntityId", onCreate: () => _legalEntity.AccountLegalEntityId);

            _testData.Add("HashedAccountLegalEntityId", _hashingService.HashValue(accountLegalEntityId));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{accountId}/legalentities/{_legalEntity.AccountLegalEntityId}/apprenticeshipIncentives")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_apprenticeshipData, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

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

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/withdrawals")
                .UsingPost()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Accepted));
        }
 public ApprenticeConfirmationSteps(TestContext testContext) : base(testContext)
 {
     _testContext = testContext;
     _testData    = new TestData.Account.WithInitialApplicationForASingleEntity();
     _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId);
     _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);
 }
 public AmendApprenticeSelectionSteps(TestContext testContext) : base(testContext)
 {
     _testContext    = testContext;
     _hashingService = _testContext.HashingService;
     _data           = new TestData.Account.WithInitialApplicationForASingleEntity();
     _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _data.HashedAccountId);
 }
        public void GivenAnEmployerApplyingHasASingleLegalEntityWithEligibleApprenticeships()
        {
            var testdata = new TestData.Account.WithSingleLegalEntityWithEligibleApprenticeships();

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

            _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($"/accounts/{testdata.AccountId}/legalentities/{testdata.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(testdata.LegalEntities.First(), 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));
        }
Exemplo n.º 7
0
 public EmploymentStartDatesSteps(TestContext testContext) : base(testContext)
 {
     _testContext    = testContext;
     _hashingService = _testContext.HashingService;
     _data           = new TestData.Account.WithInitialApplicationForASingleEntity();
     _legalEntity    = _data.LegalEntities.First();
     _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _data.HashedAccountId);
 }
        public void GivenAnEmployerHasSubmittedAnApplication()
        {
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId);
            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testData.AccountId}/applications/{_testData.ApplicationId}")
                .WithParam("includeApprenticeships", new ExactMatcher("False"))
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(_testData.ApplicationResponse)));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testData.AccountId}/applications/{_testData.ApplicationId}/accountlegalentity")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(_testData.AccountLegalEntityId.ToString()));

            var getBankingDetailsUrl = "/" + OuterApiRoutes.Application.GetBankingDetailsUrl(_testData.AccountId, _testData.ApplicationId, _testData.HashedAccountId).Split("?").First();

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(getBankingDetailsUrl)
                .WithParam("hashedAccountId", _testData.HashedAccountId)
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_testData.BankingDetails, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testData.AccountId}/legalentities/{_testData.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(_testData.LegalEntity)));
        }
Exemplo n.º 9
0
        public ReadyToEnterBankDetailsSteps(TestContext testContext) : base(testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();
            _data        = new TestData.Account.WithInitialApplicationAndBankingDetails();

            _testContext.TestDataStore.Add("HashedAccountId", _data.HashedAccountId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _data.HashedAccountId);
        }
        public async Task WhenTheEmployerSubmitsAnApplicationForTheApprenticeshipPayment()
        {
            var testdata = new TestData.Account.WithInitialApplicationForASingleEntity();

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

            var url      = $"{testdata.HashedAccountId}/apply/declaration/{testdata.ApplicationId}";
            var request  = new HttpRequestMessage(HttpMethod.Post, url);
            var response = await _testContext.WebsiteClient.SendAsync(request);

            response.EnsureSuccessStatusCode();

            _testContext.TestDataStore.GetOrCreate("Response", onCreate: () =>
            {
                return(response);
            });
        }
        public ChooseOrganisationSteps(TestContext testContext) : base(testContext)
        {
            _testContext = testContext;
            _fixture     = new Fixture();

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

            _accountId       = testData.AccountId;
            _hashedAccountId = testData.HashedAccountId;

            _testContext.TestDataStore.Add("HashedAccountId", testData.HashedAccountId);
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, testData.HashedAccountId);
        }
        public void GivenTheEmployerHasAllTheInformationRequiredToProcessTheirBankDetails()
        {
            _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}/applications/{_testdata.ApplicationId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(_testdata.ApplicationResponse)));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testdata.AccountId}/applications/{_testdata.ApplicationId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(_testdata.ApplicationResponse)));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testdata.AccountId}/applications/{_testdata.ApplicationId}/accountlegalentity")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(_testdata.AccountLegalEntityId.ToString()));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testdata.AccountId}/applications/{_testdata.ApplicationId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(_testdata.ApplicationResponse, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            var getBankingDetailsUrl = "/" + OuterApiRoutes.Application.GetBankingDetailsUrl(_testdata.AccountId, _testdata.ApplicationId, _testdata.HashedAccountId).Split("?").First();

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(getBankingDetailsUrl)
                .WithParam("hashedAccountId", _testdata.HashedAccountId)
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_testdata.BankingDetails, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testdata.AccountId}/legalentities/{_testdata.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(_testdata.LegalEntity)));

            _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($"/accounts/{_testdata.AccountId}/legalentities/{_testdata.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithBody(JsonConvert.SerializeObject(_testdata.LegalEntity, TestHelper.DefaultSerialiserSettings)));
            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_testdata.AccountId}/legalentity/{_testdata.AccountLegalEntityId}/vrfcasestatus")
                .WithParam("vrfCaseStatus", "Requested")
                .UsingPut()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json"));
        }
        public void GivenAnEmployerApplyingForAGrantHasApprenticesMatchingTheEligibilityRequirement()
        {
            var data = new TestData.Account.WithInitialApplicationForASingleEntity();

            _apprenticeshipData = data.Apprentices;
            _legalEntity        = data.LegalEntities.First();

            var accountId = _testData.GetOrCreate("AccountId", onCreate: () => data.AccountId);

            _testData.Add("HashedAccountId", _hashingService.HashValue(accountId));
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _hashingService.HashValue(accountId));
            var accountLegalEntityId = _testData.GetOrCreate("AccountLegalEntityId", onCreate: () => data.AccountLegalEntityId);

            _testData.Add("HashedAccountLegalEntityId", _hashingService.HashValue(accountLegalEntityId));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/apprenticeships")
                .WithParam("accountid", accountId.ToString())
                .WithParam("accountlegalentityid", accountLegalEntityId.ToString())
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_apprenticeshipData, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{accountId}/applications")
                .UsingPost()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Created));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(x => x.Contains($"/accounts/{data.AccountId}/applications/") && !x.Contains("accountlegalentity"))
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(data.ApplicationResponse, TestHelper.DefaultSerialiserSettings)));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{accountId}/applications")
                .UsingPost()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Created)
                .WithHeader("Content-Type", "application/json")
                .WithBody(string.Empty));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(x =>
                          x.Contains($"accounts/{data.AccountId}/applications") &&
                          x.Contains("accountlegalentity")) // applicationid is generated in application service so will vary per request
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(data.AccountLegalEntityId.ToString()));

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