public void Setup()
        {
            _fixture = new Fixture();

            _baseAddress = new Uri(@"http://localhost");
            _testClient  = new TestHttpClient(_baseAddress);

            _testClient.SetUpPutAsAsync(HttpStatusCode.OK);

            _sut = new LegalEntitiesService(_testClient);
        }
        public async Task Then_The_Api_Is_Called_To_Create_The_New_LegalEntity(
            AccountLegalEntityCreateRequest createObject,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            LegalEntitiesService service)
        {
            client.Setup(x => x.Put(It.Is <PutAccountLegalEntityRequest>(y =>
                                                                         y.PutUrl == $"accounts/{createObject.AccountId}/legalentities" && y.Data.IsSameOrEqualTo(createObject)))).Returns(Task.CompletedTask);

            await service.CreateLegalEntity(createObject);

            client.Verify(x => x.Put(It.Is <PutAccountLegalEntityRequest>(y =>
                                                                          y.PutUrl == $"accounts/{createObject.AccountId}/legalentities")), Times.Once);
        }
Exemple #3
0
        public async Task Then_The_Api_Is_Called_To_Remove_The_LegalEntity_For_An_Account(
            long accountId,
            long accountLegalEntityId,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            LegalEntitiesService service)
        {
            await service.DeleteAccountLegalEntity(accountId, accountLegalEntityId);

            client.Verify(x =>
                          x.Delete(
                              It.Is <DeleteAccountLegalEntityRequest>(c =>
                                                                      c.DeleteUrl.Contains(accountId.ToString()) &&
                                                                      c.DeleteUrl.Contains(accountLegalEntityId.ToString()))), Times.Once);
        }
Exemple #4
0
        public async Task Then_The_Api_Is_Called_To_Sign_The_Agreement(
            SignAgreementRequest request,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            LegalEntitiesService service)
        {
            await service.SignAgreement(request);

            client.Verify(x =>
                          x.Patch(It.Is <PatchSignAgreementRequest>(
                                      c =>
                                      c.PatchUrl.Contains(request.AccountId.ToString()) && c.PatchUrl.Contains(request.AccountLegalEntityId.ToString()) &&
                                      c.Data.IsSameOrEqualTo(request)
                                      )), Times.Once
                          );
        }
Exemple #5
0
        public async Task Then_The_Api_Is_Called_Returning_LegalEntities_For_The_Account(
            long accountId,
            IEnumerable <AccountLegalEntity> apiResponse,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            LegalEntitiesService service
            )
        {
            client.Setup(x =>
                         x.GetAll <AccountLegalEntity>(
                             It.Is <GetAccountLegalEntitiesRequest>(c => c.GetAllUrl.Contains(accountId.ToString()))))
            .ReturnsAsync(apiResponse);

            var actual = await service.GetAccountLegalEntities(accountId);

            actual.Should().BeEquivalentTo(apiResponse);
        }
        public async Task Then_The_Api_Is_Called_With_The_Vendor_Block_Request(
            BlockAccountLegalEntityForPaymentsRequest request,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            LegalEntitiesService service
            )
        {
            client.Setup(x => x.PatchWithResponseCode(It.Is <PatchVendorBlockRequest>(
                                                          c => c.PatchUrl.Contains("blockedpayments")
                                                          ))).ReturnsAsync(new ApiResponse <string>("", HttpStatusCode.NoContent, ""));

            await service.BlockAccountLegalEntitiesForPayments(request);

            client.Verify(x => x.PatchWithResponseCode(It.Is <PatchVendorBlockRequest>(
                                                           c => c.PatchUrl.Contains("blockedpayments")
                                                           )), Times.Once);
        }