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); }
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); } }