当前位置: 首页>>代码示例>>C#>>正文


C# Account.CreateSubaccount方法代码示例

本文整理汇总了C#中Account.CreateSubaccount方法的典型用法代码示例。如果您正苦于以下问题:C# Account.CreateSubaccount方法的具体用法?C# Account.CreateSubaccount怎么用?C# Account.CreateSubaccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Account的用法示例。


在下文中一共展示了Account.CreateSubaccount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: WhenSubaccountCreatedItsPathNameIsCorrect

 public void WhenSubaccountCreatedItsPathNameIsCorrect()
 {
     var acc = new Account("root");
     Account acc2 = acc.CreateSubaccount("subroot");
     Assert.AreEqual(
         AccountPathName.FromString("root.subroot"),
         acc2.PathName
         );
 }
开发者ID:meowthsli,项目名称:C--Home-Ledger,代码行数:9,代码来源:AccountTests.cs

示例4: WhenSubaccountCreatedItIsCorrectAndEventIsGenerated

        public void WhenSubaccountCreatedItIsCorrectAndEventIsGenerated()
        {
            EntityCreatedEvent<Account> @event = null;
            Container.Resolve<IDomainEventBus>()
                .RegisterThreaded<EntityCreatedEvent<Account>>(x => { @event = x; });

            var acc = new Account("root");
            Account acc2 = acc.CreateSubaccount("subroot");
            Assert.IsTrue(acc2.IsSubaccount);

            Assert.IsNotNull(@event);
            Assert.IsInstanceOf(typeof (EntityCreatedEvent<Account>), @event);
            Assert.AreEqual(acc2, @event.Subject);
        }
开发者ID:meowthsli,项目名称:C--Home-Ledger,代码行数:14,代码来源:AccountTests.cs

示例5: TestAccountRepository

 public TestAccountRepository()
 {
     _root = new Account("root");
     _subroot1 = _root.CreateSubaccount("subroot1");
     _subroot2 = _root.CreateSubaccount("subroot2");
 }
开发者ID:meowthsli,项目名称:C--Home-Ledger,代码行数:6,代码来源:TestAccountRepository.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


注:本文中的Account.CreateSubaccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。