private static void LogTransactionStarting(MethodInvocationEventArgs eventArgs, Account account)
 {
     Console.WriteLine(string.Format(
         "New {2} transaction on account {0}. Balance before operation is ${1}.",
         account.Number,
         account.CurrentBalance,
         eventArgs.Method.Name));
 }
 private static void LogTransactionDetails(MethodInvocationEventArgs eventArgs, Account account)
 {
     Console.WriteLine(string.Format(
         "{2} ${0} on account {1}.",
         eventArgs.GetArgumentArray().First(),
         account.Number,
         eventArgs.Method.Name));
 }
 private static void LogTransactionFinished(MethodInvocationEventArgs eventArgs, Account account)
 {
     Console.WriteLine(string.Format(
        "Finished {2} transaction on account {0}. Balance after the operation is ${1}.",
        account.Number,
        account.CurrentBalance,
        eventArgs.Method.Name));
 }
コード例 #4
0
        public void ConstructorShouldInitializeOwner()
        {
            Account account1 = new Account(555, "Owner1", 0);
            Assert.AreEqual("Owner1", account1.Owner);

            Account account2 = new Account(666, "Owner2", 0);
            Assert.AreEqual("Owner2", account2.Owner);
        }
コード例 #5
0
        public void ConstructorShouldInitializeNumber()
        {
            Account account1 = new Account(555, "Owner", 0);
            Assert.AreEqual(555, account1.Number);

            Account account2 = new Account(666, "Owner", 0);
            Assert.AreEqual(666, account2.Number);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            Account account = new Account(123, "MACSkeptic");

            account.Deposit(10);
            account.Withdraw(20);

            Console.ReadKey();
        }
コード例 #7
0
        public void ConstructorShouldInitializeBalance()
        {
            Account account1 = new Account(555, "Owner", -10);
            Assert.AreEqual(-10, account1.CurrentBalance);

            Account account2 = new Account(666, "Owner", 20);
            Assert.AreEqual(20, account2.CurrentBalance);

            Account account3 = new Account(666, "Owner", 0);
            Assert.AreEqual(0, account3.CurrentBalance);
        }
コード例 #8
0
 public void ConstructorShouldLeaveBalanceAtZero()
 {
     Account account = new Account(666, "Owner");
     Assert.AreEqual(0, account.CurrentBalance);
 }
 public static void TransferMoney(Account from, Account to, decimal howMuch)
 {
     from.Withdraw(howMuch);
     to.Deposit(howMuch);
 }
 public AccountBuilder()
 {
     this.instance = new Account(0, string.Empty);
     this.Defaults();
 }