forked from S-DRE/Bank-Kata_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.
Acceptance test passing, still to test DateCreator and ProConsole
- Loading branch information
Showing
7 changed files
with
113 additions
and
17 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,15 @@ | ||
namespace Bank; | ||
|
||
public class Movement | ||
{ | ||
public Movement(DateTime date, int operationAmount, int remainingBalance) | ||
{ | ||
this.date = date; | ||
this.operationAmount = operationAmount; | ||
this.remainingBalance = remainingBalance; | ||
} | ||
|
||
public DateTime date {get; } | ||
public int operationAmount {get; } | ||
public int remainingBalance {get; } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
using Bank; | ||
using Moq; | ||
|
||
namespace AccountShould; | ||
namespace BankUnitTests; | ||
|
||
public class AccountShould | ||
{ | ||
private Account account; | ||
|
||
private Mock<WalletRepository> walletRepository = new(); | ||
|
||
private Mock<DateCreator> dateMocker = new(); | ||
|
||
|
||
public AccountShould() | ||
{ | ||
account = new Account(new ProConsole(), new DateCreator(), walletRepository.Object); | ||
account = new Account(new ProConsole(), dateMocker.Object, walletRepository.Object); | ||
} | ||
|
||
[Fact] | ||
public void DepositTheGivenAmountAndSaveTheValue() { | ||
account.Deposit(1000); | ||
walletRepository.Verify(wallet => wallet.add(1000)); | ||
[Theory] | ||
[InlineData(1000)] | ||
[InlineData(2000)] | ||
public void DepositTheGivenAmountAndSaveTheValue(int depositAmount) { | ||
dateMocker.Setup(x => x.CreateCurrentDate()) | ||
.Returns(DateTime.Parse("01/01/2000")); | ||
|
||
account.Deposit(depositAmount); | ||
walletRepository.Verify(wallet => wallet.add(depositAmount)); | ||
} | ||
} |
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,40 @@ | ||
using Bank; | ||
|
||
namespace BankUnitTests; | ||
|
||
public class WalletShould | ||
{ | ||
private Wallet wallet; | ||
|
||
public WalletShould() | ||
{ | ||
wallet = new(); | ||
} | ||
|
||
[Fact] | ||
public void beInitializedWithABalanceOf0() | ||
{ | ||
Assert.Equal(0, wallet.getBalance()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1000)] | ||
[InlineData(2000)] | ||
public void AddGivenAmountToTheBalanceWhenADepositIsMade(int depositAmount) | ||
{ | ||
wallet.add(depositAmount); | ||
|
||
Assert.Equal(depositAmount, wallet.getBalance()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(10000, 1000, 9000)] | ||
[InlineData(10000, 2000, 8000)] | ||
public void RemoveGivenAmountToTheBalanceWhenAWithdrawIsMade(int startingAmount, int withdrawAmount, int expectedAmount) | ||
{ | ||
wallet.add(startingAmount); | ||
wallet.remove(withdrawAmount); | ||
|
||
Assert.Equal(expectedAmount, wallet.getBalance()); | ||
} | ||
} |