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


C# Account.Withdraw方法代码示例

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


在下文中一共展示了Account.Withdraw方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var acc = new Account(Guid.NewGuid());

            acc.Deposit(new Amount(3100));
            acc.Withdraw(new Amount(100));
            acc.Withdraw(new Amount(10000));

            foreach (var @event in acc.RecordedEvents())
                Console.WriteLine(@event);

            Console.ReadLine();

            var sw = new Stopwatch();

            sw.Start();

            var accountId = Guid.Parse("44b9da68-8415-4adc-b99f-2631f1115f9e");

            var account = new Account(accountId);

            for (var i = 0; i < 500; i++)
            {
                account.Withdraw(new Amount(i * 1000));
                account.Deposit(new Amount(i * 1000 * 2));
            }

            var eventStore = new FileEventStore();
            eventStore.Create(accountId, account.RecordedEvents());

            sw.Stop();

            Console.WriteLine(string.Format("Appended {0} events to stream in {1}.", account.RecordedEvents().Count(), sw.Elapsed.TotalSeconds));

            sw.Restart();

            var stream = eventStore.GetStream(accountId);

            new ProjectionToConsole().Handle(stream);

            sw.Stop();

            Console.WriteLine(string.Format("Read {0} events from stream in {1}.", stream.Count(), sw.Elapsed.TotalSeconds));

            sw.Reset();

            var restoredAccount = new Account(accountId);
            restoredAccount.Initialize(stream);

            sw.Stop();

            Console.WriteLine(string.Format("Replayed {0} events from stream in {1}.", stream.Count(), sw.Elapsed.TotalSeconds));
            Console.ReadLine();
        }
开发者ID:JefClaes,项目名称:naive-eventsourcing,代码行数:54,代码来源:Program.cs

示例2: Main

        public static void Main()
        {
            var account = new Account("Jim Johnson");

            account.Deposit(500.0);
            account.Deposit(300.0);
            account.Deposit(550.0);
            account.PayInterest();
            account.Withdraw(1000.00);
            account.Withdraw(1100.00);
        }
开发者ID:Alex223124,项目名称:High-Quality-Code,代码行数:11,代码来源:Program.cs

示例3: TestWithdrawNegative

	public void TestWithdrawNegative()
	{
		Account acc = new Account();
		acc.Withdraw(-3.14F);
		float balance = acc.Balance;
		Assert.AreEqual(balance, 1000F);
	}
开发者ID:Alex223124,项目名称:High-Quality-Code,代码行数:7,代码来源:TestAccount.cs

示例4: TestWithdraw

	public void TestWithdraw()
	{
		Account acc = new Account();
		acc.Withdraw(138.56F);
		float balance = acc.Balance;
		Assert.AreEqual(balance, -138.56F);
	}
开发者ID:Alex223124,项目名称:High-Quality-Code,代码行数:7,代码来源:TestAccount.cs

示例5: TestWithdrawNegative

 public void TestWithdrawNegative()
 {
     var acc = new Account();
     acc.Withdraw(-3.14M);
     var balance = acc.Balance;
     Assert.AreEqual(balance, 3.14M);
 }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:7,代码来源:AccountTest.cs

示例6: TestWithdraw

 public void TestWithdraw()
 {
     var acc = new Account();
     acc.Withdraw(138.56M);
     var balance = acc.Balance;
     Assert.AreEqual(balance, -138.56M);
 }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:7,代码来源:AccountTest.cs

示例7: TransferFunds

 public static void TransferFunds(Account sourceAccount,
                                  Account destinationAccount,
                                  float amount)
 {
     sourceAccount.Withdraw(amount);
     destinationAccount.Deposit(amount);
 }
开发者ID:paulrayner,项目名称:console_app,代码行数:7,代码来源:MoneyMover.cs

示例8: Withdraw_NonEmptyAccount_ShouldPass

        public void Withdraw_NonEmptyAccount_ShouldPass()
        {
            var account = new Account();
            account.Deposit(3000.0);
            account.Withdraw(2000.0);

            Assert.AreEqual(1000.0, account.Balance);
        }
开发者ID:AngataHristov,项目名称:High-Quality-Code,代码行数:8,代码来源:AccountTests.cs

示例9: TestDepositWithdrawTransferFunds

    public void TestDepositWithdrawTransferFunds()
    {
        var source = new Account();
        source.Deposit(200.00F);
        source.Withdraw(100.00F);

        var dest = new Account();
        dest.Deposit(150.00F);
        dest.Withdraw(50.00F);

        source.TransferFunds(dest, 100.00F);
        Assert.AreEqual(0.00F, source.Balance);
        Assert.AreEqual(200.00F, dest.Balance);
    }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:14,代码来源:TestAccount.cs

示例10: PrintAllClientStatements

        public void PrintAllClientStatements()
        {
            var account = new Account(transactionRepository, statementPrinter);

            account.Deposit(1000);
            account.Withdraw(100);
            account.Deposit(500);

            account.PrintStatement();

            Received.InOrder(() =>
            {
                console.Received().WriteLine("DATE       | AMOUNT  | BALANCE");
                console.Received().WriteLine("10/11/2015 | 500.00 | 1400.00");
                console.Received().WriteLine("02/11/2015 | -100.00 | 900.00");
                console.Received().WriteLine("01/11/2015 | 1000.00 | 1000.00");
            });
        }
开发者ID:robi-y,项目名称:BankAccountKata,代码行数:18,代码来源:PrintStatementFeature.cs

示例11: TestWithdrawZero

	public void TestWithdrawZero()
	{
		Account acc = new Account();
		acc.Withdraw(0);
	}
开发者ID:Alex223124,项目名称:High-Quality-Code,代码行数:5,代码来源:TestAccount.cs

示例12: Main

  public static void Main( string[] args )
  {
    // Open a new account
    Account account = new Account( "Patty La Belle" );

    // Apply financial transactions
    account.Deposit( 500.0 );
    account.Deposit( 300.0 );
    account.Deposit( 550.0 );
    account.PayInterest();
    account.Withdraw( 2000.00 );
    account.Withdraw( 1100.00 );
    
  }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:14,代码来源:State_RealWorld.cs

示例13: Main

        static void Main(string[] args)
        {
            //open a new account
            Account account = new Account("Joe Bloggs");

            //Apply Financial transactions
            account.Deposit(500.0);
            account.Deposit(300.0);
            account.Deposit(550.0);
            account.PayInterest();
            account.Withdraw(2000.00);
            account.Withdraw(1100.00);

            //wait for user input
            Console.ReadKey(true);
        }
开发者ID:Paulmcl78,项目名称:PatternPractice,代码行数:16,代码来源:Program.cs


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