當前位置: 首頁>>代碼示例>>C#>>正文


C# Account.GetBalance方法代碼示例

本文整理匯總了C#中Account.GetBalance方法的典型用法代碼示例。如果您正苦於以下問題:C# Account.GetBalance方法的具體用法?C# Account.GetBalance怎麽用?C# Account.GetBalance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Account的用法示例。


在下文中一共展示了Account.GetBalance方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WhenTransactionExecutedOnhierarchicalAccountsThenParametersCalculated

        public void WhenTransactionExecutedOnhierarchicalAccountsThenParametersCalculated()
        {
            var rootAccount = new Account("root");
            var accIncome = rootAccount.CreateSubaccount("income")
                .CreateSubaccount("income2");
            var accOutcome = rootAccount.CreateSubaccount("expences");

            const decimal amount1 = 42.0m;
            const decimal amount2 = 77.0m;

            new AccountingTransaction("tx1",
                accIncome,
                accOutcome,
                amount1).Execute();

            new AccountingTransaction("tx2",
                accOutcome,
                accIncome,
                amount2).Execute();

            Assert.AreEqual(amount2, accIncome.CreditTurnover);
            Assert.AreEqual(amount1, accIncome.DebtTurnover);
            Assert.AreEqual(amount2-amount1, accIncome.GetBalance());

            Assert.AreEqual(amount2, accOutcome.DebtTurnover);
            Assert.AreEqual(amount1, accOutcome.CreditTurnover);
            Assert.AreEqual(amount1-amount2, accOutcome.GetBalance());

            Assert.AreEqual(0.0m, rootAccount.GetBalance());
            Assert.AreEqual(2* (amount1+amount2), rootAccount.GetTurnover());
        }
開發者ID:meowthsli,項目名稱:C--Home-Ledger,代碼行數:31,代碼來源:TransactionTests.cs

示例2: WhenTransactionCreditAndDebtThenAccountSaldoAndTurnoverAreOk

        public void WhenTransactionCreditAndDebtThenAccountSaldoAndTurnoverAreOk()
        {
            var acc = new Account("root");

            acc.TransactCredit(10.0m);
            acc.TransactDebt(5.0m);

            Assert.AreEqual(10.0m, acc.CreditTurnover);
            Assert.AreEqual(5.0m, acc.DebtTurnover);

            Assert.AreEqual(15.0m, acc.GetTurnover());
            Assert.AreEqual(5.0, acc.GetBalance());
        }
開發者ID:meowthsli,項目名稱:C--Home-Ledger,代碼行數:13,代碼來源:AccountTests.cs

示例3: ABalanceForASpecificMonthShouldOnlyReturnTheSumOfTransactionsUpToThisMonth

        public void ABalanceForASpecificMonthShouldOnlyReturnTheSumOfTransactionsUpToThisMonth()
        {
            account = account
                .Deposit(new DateTime(2012, 2, 1), new Money(20))
                .Withdraw(new DateTime(2012, 3, 1), new Money(30))
                .Deposit(new DateTime(2012, 4, 1), new Money(40))
                .Deposit(new DateTime(2012, 5, 1), new Money(50));

            Assert.That(account.GetBalance(Month.January, 2010), Is.EqualTo(Money.ZERO), "2010");
            Assert.That(account.GetBalance(Month.January, 2012), Is.EqualTo(new Money(100)), "January");
            Assert.That(account.GetBalance(Month.February, 2012), Is.EqualTo(new Money(100 + 20)), "February");
            Assert.That(account.GetBalance(Month.March, 2012), Is.EqualTo(new Money(100 + 20 - 30)), "March");
            Assert.That(account.GetBalance(Month.April, 2012), Is.EqualTo(new Money(100 + 20 - 30 + 40)), "April");
            Assert.That(account.GetBalance(Month.May, 2012), Is.EqualTo(new Money(100 + 20 - 30 + 40 + 50)), "May");
            Assert.That(account.GetBalance(Month.June, 2012), Is.EqualTo(new Money(100 + 20 - 30 + 40 + 50)), "June");
        }
開發者ID:magicmonty,項目名稱:plan-ahead,代碼行數:16,代碼來源:AccountTests.cs

示例4: WhenTransactionCreditAndDebtThenParentAccountSaldoAndTurnoverAreOk

        public void WhenTransactionCreditAndDebtThenParentAccountSaldoAndTurnoverAreOk()
        {
            var acc = new Account("root");
            var acc1 = acc.CreateSubaccount("expence");
            var acc2 = acc.CreateSubaccount("income");

            acc1.TransactDebt(6.0m);
            acc2.TransactCredit(17.0m);

            Assert.AreEqual(17.0m, acc.CreditTurnover);
            Assert.AreEqual(6.0m, acc.DebtTurnover);

            Assert.AreEqual(23.0m, acc.GetTurnover());
            Assert.AreEqual(11.0, acc.GetBalance());
        }
開發者ID:meowthsli,項目名稱:C--Home-Ledger,代碼行數:15,代碼來源:AccountTests.cs

示例5: GetBalance

 public static double GetBalance(this IEnumerable<Transaction> transactions, Account account, DateTime time)
 {
     return account.GetBalance(transactions, time);
 }
開發者ID:skasti,項目名稱:Budgeteer,代碼行數:4,代碼來源:StateExtensions.cs

示例6: WhenTransactionExecutedOnPairedAccountsThenParametersCalculated

        public void WhenTransactionExecutedOnPairedAccountsThenParametersCalculated()
        {
            var rootAccount = new Account("root");
            var accIncome = rootAccount.CreateSubaccount("income");
            var accOutcome = rootAccount.CreateSubaccount("expences");

            const decimal amount = 77.0m;

            var tx = new AccountingTransaction("tx1",
                accIncome,
                accOutcome,
                amount);
            tx.Execute();

            Assert.AreEqual(0.0m, accIncome.CreditTurnover);
            Assert.AreEqual(amount, accIncome.DebtTurnover);
            Assert.AreEqual(-amount, accIncome.GetBalance());

            Assert.AreEqual(0.0m, accOutcome.DebtTurnover);
            Assert.AreEqual(amount, accOutcome.CreditTurnover);
            Assert.AreEqual(amount, accOutcome.GetBalance());

            Assert.AreEqual(0.0m, rootAccount.GetBalance());
            Assert.AreEqual(2 * amount, rootAccount.GetTurnover());
        }
開發者ID:meowthsli,項目名稱:C--Home-Ledger,代碼行數:25,代碼來源:TransactionTests.cs

示例7: AcceptAccount

 public void AcceptAccount(Account a)
 {
     account = a;
     if (account != null)
       if (transType == BALANCE){
     screen.Display("The balance is {0:C}"
            + account.GetBalance());
       }
       else {
      if (transType == DEPOSIT || transType == WITHDRAW){
        screen.SpecifyAmount();
      }
       }
     else
       screen.Display("No such account -- session terminated");
 }
開發者ID:JnS-Software-LLC,項目名稱:CSC153,代碼行數:16,代碼來源:AtmScreen+(1).cs


注:本文中的Account.GetBalance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。