public void GivenAnEmployerWithAMultipleOrganisationsWantsToApplyForAGrant() { var testdata = new TestData.Account.WithMultipleLegalEntitiesWithEligibleApprenticeships(); _testDataStore.Add("HashedAccountId", testdata.HashedAccountId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, testdata.HashedAccountId); _testDataStore.Add("HashedAccountLegalEntityId", testdata.HashedAccountLegalEntityId1); _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)); }
public EmployerIncentivesApiBuilder WithMultipleLegalEntityWithEligibleApprenticeships() { var data = new TestData.Account.WithMultipleLegalEntitiesWithEligibleApprenticeships(); _server .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/legalentities") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(data.LegalEntities, TestHelper.DefaultSerialiserSettings))); _server .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/legalentities/{data.AccountLegalEntityId1}") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(data.LegalEntity1, TestHelper.DefaultSerialiserSettings))); _server .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/legalentities/{data.AccountLegalEntityId2}") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(data.LegalEntity2, TestHelper.DefaultSerialiserSettings))); _server .Given( Request .Create() .WithPath($"/apprenticeships") .WithParam("accountid", data.AccountId.ToString()) .WithParam("accountlegalentityid", data.LegalEntities.First().AccountLegalEntityId.ToString()) .UsingGet() ) .RespondWith( Response.Create() .WithBody(JsonConvert.SerializeObject(data.Apprentices, TestHelper.DefaultSerialiserSettings)) .WithStatusCode(HttpStatusCode.OK)); AddClaim(EmployerClaimTypes.Account, data.HashedAccountId); return(this); }
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 EmployerIncentivesApiBuilder WithUpdateApplication() { var data = new TestData.Account.WithMultipleLegalEntitiesWithEligibleApprenticeships(); _server .Given( Request .Create() .WithPath(x => x.Contains($"accounts/{data.AccountId}/applications")) .UsingPut() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK)); return(this); }
public EmployerIncentivesApiBuilder WithCreateApplication() { var data = new TestData.Account.WithMultipleLegalEntitiesWithEligibleApprenticeships(); _server .Given( Request .Create() .WithPath(x => x.Contains($"accounts/{data.AccountId}/applications")) .UsingPost() ) .RespondWith( Response.Create() .WithBody(string.Empty) .WithStatusCode(HttpStatusCode.OK)); _server .Given( Request .Create() .WithPath(x => x.Contains($"accounts/{data.AccountId}/applications")) .UsingPatch() ) .RespondWith( Response.Create() .WithBody(string.Empty) .WithStatusCode(HttpStatusCode.OK)); var applicationResponse = new ApplicationResponse { Application = new IncentiveApplicationDto { AccountLegalEntityId = data.AccountLegalEntityId1, BankDetailsRequired = true, Apprenticeships = new List <IncentiveApplicationApprenticeshipDto> { new IncentiveApplicationApprenticeshipDto { ApprenticeshipId = 1234, CourseName = "Early Years Educator Level 3", FirstName = "Adam", LastName = "Glover", TotalIncentiveAmount = 2000m, PlannedStartDate = new DateTime(2020, 9, 1), Uln = 12345678 } } } }; _server .Given( Request .Create() .WithPath(x => x.Contains($"accounts/{data.AccountId}/applications")) .WithParam("includeApprenticeships") .UsingGet() ) .RespondWith( Response.Create() .WithBody(JsonConvert.SerializeObject(applicationResponse)) .WithStatusCode(HttpStatusCode.OK)); _server .Given( Request .Create() .WithPath(x => x.Contains($"accounts/{data.AccountId}/applications") && x.Contains("accountlegalentity")) .UsingGet() ) .RespondWith( Response.Create() .WithBody("123") .WithStatusCode(HttpStatusCode.OK)); return(this); }