public async Task Then_If_The_Account_Not_Found_Then_Null_Returned( string accountLegalEntityPublicHashedId, AccountDetail accountDetailApiResponse, GetEmployerAccountLegalEntityItem legalEntityItem, [Frozen] Mock <IAccountsApiClient <AccountsConfiguration> > accountsApi, AccountLegalEntityPermissionService service) { var accountIdentifier = new AccountIdentifier("Employer-ABC123-Product"); accountsApi .Setup(x => x.Get <AccountDetail>( It.Is <GetAllEmployerAccountLegalEntitiesRequest>(c => c.GetUrl.EndsWith($"accounts/{accountIdentifier.AccountHashedId}")))) .ReturnsAsync((AccountDetail)null); var actual = await service.GetAccountLegalEntity(accountIdentifier, accountLegalEntityPublicHashedId); actual.Should().BeNull(); }
public async Task Then_If_The_Legal_Entity_Does_Not_Belong_To_The_Employer_Account_Exception_Thrown( string responseValue, CreateVacancyCommand command, AccountDetail accountDetailApiResponse, GetEmployerAccountLegalEntityItem leaglEntityResponse, [Frozen] Mock <IAccountLegalEntityPermissionService> accountLegalEntityPermissionService, [Frozen] Mock <IRecruitApiClient <RecruitApiConfiguration> > recruitApiClient, CreateVacancyCommandHandler handler) { command.PostVacancyRequestData.OwnerType = OwnerType.Employer; accountLegalEntityPermissionService .Setup(x => x.GetAccountLegalEntity(It.IsAny <AccountIdentifier>(), It.IsAny <string>())) .ReturnsAsync((AccountLegalEntityItem)null); //Act Assert.ThrowsAsync <SecurityException>(() => handler.Handle(command, CancellationToken.None)); recruitApiClient.Verify(x => x.PostWithResponseCode <string>( It.IsAny <PostVacancyRequest>()), Times.Never); }