Ejemplo n.º 1
0
        public async Task GetListAsync_ReturnsList()
        {
            // Act
            var data = (await BankAccountClient.List().Filter(a => a.CurrencyId.IsNotEqual(0)).GetAsync()).AssertResult();

            // Assert
            Assert.Greater(data.Items.Count(), 0);
        }
Ejemplo n.º 2
0
        public async Task DeleteAsync_SuccessfullyDeleted()
        {
            // Act
            var data = (await BankAccountClient.DeleteAsync(_newBankAccountId)).AssertResult();

            // Assert
            Assert.True(data);
        }
Ejemplo n.º 3
0
        public async Task GetDetailAsync_ReturnsDetail()
        {
            // Act
            var data = (await BankAccountClient.Detail(_newBankAccountId).Include(a => a.Bank).GetAsync()).AssertResult();

            // Assert
            Assert.AreEqual(_newBankAccountId, data.Id);
            Assert.NotNull(data.Bank);
            Assert.AreEqual(data.Bank.Id, data.BankId);
        }
Ejemplo n.º 4
0
        public async Task UpdateAsync_SuccessfullyUpdated()
        {
            // Arrange
            var model = CreatePatchModel();

            // Act
            var data = (await BankAccountClient.UpdateAsync(model)).AssertResult();

            // Assert
            AssertData(model, data);
        }
Ejemplo n.º 5
0
        public async Task PostAsync_SuccessfullyPosted()
        {
            // Arrange
            var model = CreatePostModel();

            // Act
            var data = (await BankAccountClient.PostAsync(model)).AssertResult();

            _newBankAccountId = data.Id;

            // Assert
            Assert.Greater(data.Id, 0);
            AssertData(model, data);
        }
Ejemplo n.º 6
0
    public async Task GivenBankAccount_WhenTransactionsSet_ShouldSucceed()
    {
        BankAccountClient     accountClient     = TestApplication.GetBankAccountClient();
        BankTransactionClient transactionClient = TestApplication.GetBankTransactionClient();

        DocumentId documentId = (DocumentId)"test/bank/bankAccount2";

        await accountClient.Delete(documentId);

        BankAccount entry = new BankAccount
        {
            AccountId     = documentId.Path,
            AccountName   = "testBankAccount2",
            AccountNumber = Guid.NewGuid().ToString(),
        };

        await accountClient.Set(entry);

        TrxBalance?balanceTrx = await transactionClient.GetBalance(documentId);

        balanceTrx.Should().NotBeNull();
        balanceTrx !.Balance.Should().Be(0.0m);

        await ApplyTransaction(transactionClient, documentId : documentId, balance : 155.15m, 100.0m, 75.15m, -20.0m);
        await ApplyTransaction(transactionClient, documentId : documentId, balance : 240.30m, -10.0m, 75.15m, 20.0m);
        await ApplyTransaction(transactionClient, documentId : documentId, balance : 270.42m, -20.0m, 45.0m, 5.12m);

        BankAccount?readAccount = await accountClient.Get(documentId);

        readAccount.Should().NotBeNull();

        readAccount !.AccountId.Should().Be(entry.AccountId);
        readAccount.AccountName.Should().Be(entry.AccountName);
        readAccount.AccountNumber.Should().Be(entry.AccountNumber);
        readAccount.Transactions.Count.Should().Be(9);

        await accountClient.Delete(documentId);
    }
Ejemplo n.º 7
0
    public async Task GivenAccount_WhenRoundTrip_ShouldSucceed()
    {
        BankAccountClient client = TestApplication.GetBankAccountClient();

        DocumentId documentId = (DocumentId)"test/bank/bankAccount1";

        await client.Delete(documentId);

        BankAccount entry = new BankAccount
        {
            AccountId     = documentId.Path,
            AccountName   = "testBankAccount",
            AccountNumber = Guid.NewGuid().ToString(),
        };

        await client.Set(entry);

        BankAccount?account = await client.Get(documentId);

        account.Should().NotBeNull();
        account !.AccountId.Should().Be(entry.AccountId);
        account.AccountName.Should().Be(entry.AccountName);
        account.AccountNumber.Should().Be(entry.AccountNumber);
        account.Transactions.Count.Should().Be(0);

        account = account with
        {
            AccountName  = "newBankAccount",
            Transactions = new[]
            {
                new TrxRecord {
                    Type = TrxType.Credit, Amount = 100.0m
                },
                new TrxRecord {
                    Type = TrxType.Debit, Amount = 41.0m
                },
            }.ToList()
        };

        await client.Set(account);

        BankAccount?account1 = await client.Get(documentId);

        account1.Should().NotBeNull();
        account1 !.AccountId.Should().Be(account.AccountId);
        account1.AccountName.Should().Be(account.AccountName);
        account1.AccountNumber.Should().Be(account.AccountNumber);
        account1.Transactions.Count.Should().Be(2);
        (account1.Transactions[0] == account.Transactions[0]).Should().BeTrue();
        (account1.Transactions[1] == account.Transactions[1]).Should().BeTrue();

        var query = new QueryParameter
        {
            Filter = "test/bank"
        };

        BatchSetCursor <DatalakePathItem> cursor = client.Search(query);

        cursor.Should().NotBeNull();

        BatchSet <DatalakePathItem> batchSet = await cursor.ReadNext();

        batchSet.Should().NotBeNull();
        batchSet.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeTrue();

        await client.Delete(documentId);
    }
}
Ejemplo n.º 8
0
 public void OneTimeSetUp()
 {
     InitDokladApi();
     BankAccountClient = DokladApi.BankAccountClient;
 }
Ejemplo n.º 9
0
 public BankAccountManager(BankAccountClient bankAccountClient)
 {
     _bankAccountClient = bankAccountClient;
 }