コード例 #1
0
 private void CheckAccount(BankAccount.BankAccount bankAccount)
 {
     if (bankAccount.Equals(null))
     {
         throw new ArgumentException("Bank account can't be null!");
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: pvadam/AvenPrezi01
        public void Main(string[] args)
        {
            ILogger logger = new Logger();
            BankAccount ba = new BankAccount("Mr. Bryan Walton", 11.99, logger);

            ba.Credit(5.77);
            ba.Debit(11.22);
            Console.WriteLine("Current balance is ${0}", ba.Balance);
        }
コード例 #3
0
        // Create the account and subscribe the event handler.
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create the account.
            TheAccount = new BankAccount();
            TheAccount.Balance = 100m;

            // Subscribe to the Overdrawn event.
            TheAccount.Overdrawn += OverdrawnHandler;

            // Display the account balance.
            DisplayBalance();
        }
コード例 #4
0
        private void CheckNumbers(decimal sum, BankAccount.BankAccount bankAccount, Holder.Holder holder)
        {
            if (sum <= 0)
            {
                throw new ArgumentException("Sum can't be less or equal zero!");
            }

            if (holder.Equals(null))
            {
                throw new ArgumentException("Holder can't be null!");
            }

            CheckAccount(bankAccount);
        }
コード例 #5
0
        public void Debit_WithValidAmount_UpdatesBalance()
        {
            // Arrange
            double beginningBalance = 11.99;
            double debitAmount      = 4.55;
            double expected         = 7.44;

            BankAccount.BankAccount account = new BankAccount.BankAccount("Mr. Bryan Walton", beginningBalance);

            // Act
            account.Debit(debitAmount);

            // Assert
            double actual = account.Balance;

            Assert.AreEqual(expected, actual, 0.001, "Account not debited correctly");
        }
コード例 #6
0
ファイル: BankAccount.cs プロジェクト: pvadam/AvenPrezi01
        public void Debit_WithValidAmount_UpdatesBalance()
        {
            // Prepare
            // Mock<ILogger> mock = new Mock<ILogger>();
            // ILogger logger = mock.Object;
            ILogger logger = null;

            // arrange
            double beginningBalance = 11.99;
            double debitAmount = 4.55;
            double expected = 7.44;
            BankAccount account = new BankAccount("Mr. Bryan Walton", beginningBalance, logger);

            // act
            account.Debit(debitAmount);

            // assert
            double actual = account.Balance;
            Assert.True(actual.Equals(expected));
        }
コード例 #7
0
        public void Debit_WhenAmountIsMoreThanBalance_ShouldThrowArgumentOutOfRange()
        {
            // Arrange
            double beginningBalance = 10;
            double debitAmount      = 20;

            BankAccount.BankAccount account = new BankAccount.BankAccount("Mr. Matas", beginningBalance);

            // Act
            try
            {
                account.Debit(debitAmount);
            }
            catch (System.ArgumentOutOfRangeException e)
            {
                // Asssert
                StringAssert.Contains(e.Message, BankAccount.BankAccount.DebitAmountExceedsBalanceMessage);
                return;
            }

            Assert.Fail("The expected exception was not thrown.");
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: hbumadian/CSharpForDummies
    public static void Main(string[] args)
    {
      Console.WriteLine("This program doesn't compile in its present state.");
      // Open a bank account.
      Console.WriteLine("Create a bank account object");
      BankAccount ba = new BankAccount();
      ba.InitBankAccount();

      // Accessing the balance via the Deposit() method is OK -
      // Deposit() has access to all of the data members.
      ba.Deposit(10);

      // Accessing the data member directly is a compile
      // time error.
      Console.WriteLine("Just in case you get this far the following is "
                      + "supposed to generate a compile error");
      ba._balance += 10;


      // Wait for user to acknowledge the results.
      Console.WriteLine("Press Enter to terminate...");
      Console.Read();
    }
コード例 #9
0
 => this.bankAccountUniqueIdHelper = new BankAccountUniqueIdHelper(this.MockedBankConfiguration.Object);
コード例 #10
0
 public void DeleteAccount(BankAccount.BankAccount bankAccount)
 {
     CheckAccount(bankAccount);
     _holder.AccountsId.Remove(bankAccount);
 }
コード例 #11
0
 public void CreateAccount(AccountFactory accountFactory)
 {
     CheckFactory(accountFactory);
     BankAccount.BankAccount bankAccount = accountFactory.CreateNewAccount(_holder.HolderId);
     _holder.AccountsId.Add(bankAccount);
 }
コード例 #12
0
 public void Withdraw(BankAccount.BankAccount bankAccount, decimal sum)
 {
     CheckNumbers(sum, bankAccount, _holder);
     bankAccount.Deposit(sum);
 }