public async Task TransferAsync_SenderWalletNotAssigned_ReturnsFail()
        {
            _walletsServiceMock
            .Setup(x => x.GetCustomerWalletAsync(FakeSenderCustomerId))
            .ReturnsAsync(CustomerWalletAddressResultModel.Failed(CustomerWalletAddressError.CustomerWalletMissing));

            var sut = CreateSutInstance();

            var result = await sut.P2PTransferAsync(FakeSenderCustomerId, FakeRecipientCustomerId, 1, FakeTransferId);

            Assert.Equal(TransferError.SenderWalletMissing, result.Error);
        }
        public async Task RewardAsync_CustomerWallet_HasNotBeenRegisteredYet_ReturnsFail()
        {
            _walletsServiceMock
            .Setup(x => x.GetCustomerWalletAsync(It.IsAny <string>()))
            .ReturnsAsync(
                CustomerWalletAddressResultModel.Failed(CustomerWalletAddressError.CustomerWalletMissing));

            var sut = CreateSutInstance();

            var result = await sut.RewardAsync(FakeCustomerId, 1, default(string), "bonusReason", "campaignId",
                                               "conditionId");

            Assert.Equal(BonusRewardError.CustomerWalletMissing, result.Error);
        }
示例#3
0
        public async Task <CustomerWalletAddressResultModel> GetCustomerWalletAsync(string customerId)
        {
            if (string.IsNullOrEmpty(customerId))
            {
                return(CustomerWalletAddressResultModel.Failed(CustomerWalletAddressError.InvalidCustomerId));
            }

            var walletOwner = await _walletOwnersRepository.GetByOwnerIdAsync(customerId);

            if (string.IsNullOrEmpty(walletOwner?.WalletId))
            {
                return(CustomerWalletAddressResultModel.Failed(CustomerWalletAddressError.CustomerWalletMissing));
            }

            return(CustomerWalletAddressResultModel.Succeeded(walletOwner.WalletId));
        }
        public async Task GetAsync_NoWalletRegistered_ReturnsFail()
        {
            _walletsServiceMock
            .Setup(x => x.GetCustomerWalletAsync(It.IsAny <string>()))
            .ReturnsAsync(CustomerWalletAddressResultModel.Failed(CustomerWalletAddressError.CustomerWalletMissing));

            _distributedCacheMock
            .Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync((byte[])null);

            var sut = CreateSutInstance();

            var result = await sut.GetAsync(FakeCustomerId);

            Assert.Equal(CustomerBalanceError.CustomerWalletMissing, result.Error);
            Assert.Equal(0, result.Total);
        }