forked from kiiadi/abc-bank-c-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added logic and test cases for 1. A customer can transfer between their accounts 2. Change Maxi-Savings accounts to have an interest rate of 5% assuming no withdrawals in the past 10 days otherwise 0.1%
- Loading branch information
Showing
15 changed files
with
408 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AbcBank.Test | ||
{ | ||
[TestFixture] | ||
public class AccountTest | ||
{ | ||
public void Test_Deposit() | ||
{ | ||
SavingsAccount svgAccount = new SavingsAccount(); | ||
svgAccount.Deposit(100); | ||
Assert.AreEqual(1, svgAccount.transactions.Count); | ||
} | ||
|
||
[Test] | ||
[ExpectedException] | ||
public void Test_DepositNegativeAmount() | ||
{ | ||
SavingsAccount svgAccount = new SavingsAccount(); | ||
svgAccount.Deposit(-100); | ||
Assert.AreEqual(1, svgAccount.transactions.Count); | ||
} | ||
|
||
[Test] | ||
public void Test_Withdraw() | ||
{ | ||
SavingsAccount svgAccount = new SavingsAccount(); | ||
svgAccount.Deposit(100); | ||
|
||
svgAccount.Withdraw(100); | ||
Assert.AreEqual(2, svgAccount.transactions.Count); | ||
} | ||
|
||
[Test] | ||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "amount to withdraw is more than your current balance")] | ||
public void Test_WithdrawMoreThanBalance() | ||
{ | ||
SavingsAccount svgAccount = new SavingsAccount(); | ||
svgAccount.Withdraw(100); | ||
Assert.AreEqual(1, svgAccount.transactions.Count); | ||
} | ||
|
||
[Test] | ||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "amount must be greater than zero")] | ||
public void Test_WithdrawNegativeAmount() | ||
{ | ||
SavingsAccount svgAccount = new SavingsAccount(); | ||
svgAccount.Withdraw(-100); | ||
Assert.AreEqual(1, svgAccount.transactions.Count); | ||
} | ||
|
||
[Test] | ||
public void Test_SumTransactions() | ||
{ | ||
SavingsAccount acc1 = new SavingsAccount(); | ||
acc1.Deposit(100); | ||
acc1.Deposit(200); | ||
|
||
Assert.AreEqual(300, acc1.SumTransactions()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.