public async Task CustomerTriesToMakePaymentTransfer_ErrorFromPbf_ErrorReturned (TransferError pbfError, PaymentTransfersErrorCodes expectedError) { _cpClient.Setup(x => x.CustomerProfiles.GetByCustomerIdAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>())) .ReturnsAsync(new CustomerProfileResponse { Profile = new CustomerProfile.Client.Models.Responses.CustomerProfile() }); _wmClient .Setup(x => x.Api.GetCustomerWalletBlockStateAsync(It.IsAny <string>())) .ReturnsAsync(new CustomerWalletBlockStatusResponse { Status = CustomerWalletActivityStatus.Active }); _campaignClient.Setup(x => x.BurnRules.GetByIdAsync(It.IsAny <Guid>())) .ReturnsAsync(new BurnRuleResponse { ErrorCode = CampaignServiceErrorCodes.None, Vertical = Vertical.RealEstate }); _eligibilityEngineClientMock.Setup(x => x.ConversionRate.GetAmountBySpendRuleAsync(It.IsAny <ConvertAmountBySpendRuleRequest>())) .ReturnsAsync(new ConvertAmountBySpendRuleResponse { ErrorCode = EligibilityEngineErrors.None, Amount = ValidAmount }); _pbfClientMock.Setup(x => x.GenericTransfersApi.GenericTransferAsync(It.IsAny <GenericTransferRequestModel>())) .ReturnsAsync(new TransferResponseModel { Error = pbfError }); var requestDto = new PaymentTransferDto { CustomerId = FakeCustomerId, SpendRuleId = FakeCampaignId, AmountInFiat = ValidAmount }; var sut = CreateSutInstance(); var result = await sut.PaymentTransferAsync(requestDto); Assert.Equal(expectedError, result); }
public async Task HandleUndecodedEvent_EventOfTypeRejected_ErrorOnAccepting_PublisherNotCalled(PaymentTransfersErrorCodes error) { _settingsServiceMock.Setup(x => x.GetPaymentTransfersAddress()) .Returns(FakeContractAddress); _blockchainEventDecoderMock.Setup(x => x.GetEventType(_fakeEventTopics[0])) .Returns(BlockchainEventType.TransferRejected); _blockchainEventDecoderMock .Setup(x => x.DecodeTransferRejectedEvent(_fakeEventTopics, FakeData)) .Returns(new TransferRejectedModel { TransferId = FakeTransferId }); _paymentsServiceMock.Setup(x => x.RejectPaymentTransferAsync(FakeTransferId)) .ReturnsAsync(error); var sut = CreateSutInstance(); await sut.HandleAsync(_fakeEventTopics, FakeData, FakeContractAddress); _transferProcessedPublisherMock.Verify(x => x.PublishAsync(It.IsAny <PaymentTransferProcessedEvent>()), Times.Never); }