Skip to content

Commit

Permalink
RED: First test (acceptance) created
Browse files Browse the repository at this point in the history
  • Loading branch information
S-DRE committed Mar 8, 2023
1 parent 7ac209b commit e29fe69
Show file tree
Hide file tree
Showing 11 changed files with 639 additions and 0 deletions.
479 changes: 479 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Bank-Kata_C-Sharp.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bank", "Bank\Bank.csproj", "{0F68A395-EFF9-4FF4-80AA-091FFBD94C10}"
ProjectSection(ProjectDependencies) = postProject
{1C9DCC2D-22A7-40BB-8325-37260870309A} = {1C9DCC2D-22A7-40BB-8325-37260870309A}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankShould", "BankShould\BankShould.csproj", "{1C9DCC2D-22A7-40BB-8325-37260870309A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F68A395-EFF9-4FF4-80AA-091FFBD94C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F68A395-EFF9-4FF4-80AA-091FFBD94C10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F68A395-EFF9-4FF4-80AA-091FFBD94C10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F68A395-EFF9-4FF4-80AA-091FFBD94C10}.Release|Any CPU.Build.0 = Release|Any CPU
{1C9DCC2D-22A7-40BB-8325-37260870309A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C9DCC2D-22A7-40BB-8325-37260870309A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C9DCC2D-22A7-40BB-8325-37260870309A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C9DCC2D-22A7-40BB-8325-37260870309A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
26 changes: 26 additions & 0 deletions Bank/Account.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Bank;

public class Account
{
public ProConsole ProConsole { get; }

public Account(ProConsole proConsole)
{
ProConsole = proConsole;
}

public void Deposit(int amount, Date date)
{

}

public void Withdraw(int amount, Date date)
{

}

public void PrintStatement()
{

}
}
6 changes: 6 additions & 0 deletions Bank/Bank.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Bank;

public class Bank
{

}
10 changes: 10 additions & 0 deletions Bank/Bank.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
9 changes: 9 additions & 0 deletions Bank/Date.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Bank;

public class Date
{
public Date(string s)
{
throw new NotImplementedException();
}
}
9 changes: 9 additions & 0 deletions Bank/ProConsole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Bank;

public class ProConsole
{
public void printLine(string lineToPrint)
{
throw new NotImplementedException();
}
}
40 changes: 40 additions & 0 deletions BankShould/BankShould.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Bank;
using Moq;

namespace BankShould;

public class BankShould
{
[Fact]
public void PerformPrintAListOfPreviousDepositsAndWithdrawals()
{
/*
* Date || Amount || Balance
14/01/2012 || -500 || 2500
13/01/2012 || 2000 || 3000
10/01/2012 || 1000 || 1000
*/

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

// given
var account = new Account(proConsoleMock);

// 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.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"));

}
}

31 changes: 31 additions & 0 deletions BankShould/BankShould.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>

<RootNamespace>BankTest</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Bank\Bank.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions BankShould/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Bank-Kata_C-Sharp
Pair programming session of the Bank Kata in C#

Using:
* [xUnit](https://xunit.net/) as the testing framework
* [Moq4](https://github.com/moq/moq4) as the mocking one.


### Bank Kata link:
https://www.codurance.com/katalyst/bank

0 comments on commit e29fe69

Please sign in to comment.