public void GivenAnEmployerApplyingHasMultipleLegalentitiesWithEligibleApprenticeships() { var testdata = new TestData.Account.WithMultipleLegalEntitiesWithEligibleApprenticeships(); var accountId = _testDataStore.GetOrCreate("AccountId", onCreate: () => testdata.AccountId); _testDataStore.Add("HashedAccountId", _hashingService.HashValue(accountId)); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _hashingService.HashValue(accountId)); _testDataStore.Add("HashedAccountLegalEntityId", _hashingService.HashValue(testdata.LegalEntities.First().AccountLegalEntityId)); var legalEntities = _testDataStore.GetOrCreate("Legalentities", onCreate: () => testdata.LegalEntities); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{accountId}/legalentities") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(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)); }
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 void GivenAnEmployerWhoHasSignedTheIncentiveTermsIsApplyingForAGrant() { 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($"/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)); }
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 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)); }