Skip to content

Commit

Permalink
RED AFTER CHECK: Checked that the acceptance test was well built and …
Browse files Browse the repository at this point in the history
…moved back to NotImplementedExceptions
  • Loading branch information
S-DRE committed Mar 9, 2023
1 parent e29fe69 commit 7d1b44b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
18 changes: 10 additions & 8 deletions Bank/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

public class Account
{
public ProConsole ProConsole { get; }
private ProConsole proConsole;
private DateCreator dateCreator;

public Account(ProConsole proConsole)
public Account(ProConsole proConsole, DateCreator dateCreator)
{
ProConsole = proConsole;
this.proConsole = proConsole;
this.dateCreator = dateCreator;
}

public void Deposit(int amount, Date date)
public void Deposit(int amount)
{

throw new NotImplementedException();
}

public void Withdraw(int amount, Date date)
public void Withdraw(int amount)
{

throw new NotImplementedException();
}

public void PrintStatement()
{

throw new NotImplementedException();
}
}
6 changes: 5 additions & 1 deletion Bank/Bank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

public class Bank
{

static void Main(string[] args)
{
// Display the number of command line arguments.
Console.WriteLine("SuperBank");
}
}
5 changes: 3 additions & 2 deletions Bank/Date.cs → Bank/DateCreator.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace Bank;

public class Date
public class DateCreator
{
public Date(string s)

public virtual DateTime CreateCurrentDate()
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion Bank/ProConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class ProConsole
{
public void printLine(string lineToPrint)
public virtual void printLine(string lineToPrint)
{
throw new NotImplementedException();
}
Expand Down
27 changes: 17 additions & 10 deletions BankShould/BankShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,32 @@ public void PerformPrintAListOfPreviousDepositsAndWithdrawals()
10/01/2012 || 1000 || 1000
*/

var consoleMock = new Mock<ProConsole>();
ProConsole proConsoleMock = consoleMock.Object;
var consoleMocker = new Mock<ProConsole>();
ProConsole proConsoleMock = consoleMocker.Object;

var dateMocker = new Mock<DateCreator>();
DateCreator dateCreatorMock = dateMocker.Object;

// given
var account = new Account(proConsoleMock);
var account = new Account(proConsoleMock, dateCreatorMock);
dateMocker.SetupSequence(x => x.CreateCurrentDate())
.Returns(DateTime.Parse("14/01/2012"))
.Returns(DateTime.Parse("13/01/2012"))
.Returns(DateTime.Parse("10/01/2012"));

// when
account.Deposit(1000, new Date("10/01/2012"));
account.Deposit(2000, new Date("13/01/2012"));
account.Withdraw(500, new Date("14/01/2012"));
account.Deposit(1000);
account.Deposit(2000);
account.Withdraw(500);
account.PrintStatement();

// then

// It could also check a bunch of lines if the console has a method for stack of transactions
consoleMock.Verify(console => console.printLine("Date || Amount || Balance"));
consoleMock.Verify(console => console.printLine("14/01/2012 || -500 || 2500"));
consoleMock.Verify(console => console.printLine("13/01/2012 || 2000 || 3000"));
consoleMock.Verify(console => console.printLine("10/01/2012 || 1000 || 1000"));
consoleMocker.Verify(console => console.printLine("Date || Amount || Balance"));
consoleMocker.Verify(console => console.printLine("14/01/2012 || -500 || 2500"));
consoleMocker.Verify(console => console.printLine("13/01/2012 || 2000 || 3000"));
consoleMocker.Verify(console => console.printLine("10/01/2012 || 1000 || 1000"));

}
}
Expand Down

0 comments on commit 7d1b44b

Please sign in to comment.