Skip to content

Commit 855664b

Browse files
committed
Starting point
1 parent e1c5551 commit 855664b

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

Bank/Bank.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>

Bank/BankAccount.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
3+
namespace Bank
4+
{
5+
/// <summary>
6+
/// Bank account demo class.
7+
/// </summary>
8+
public class BankAccount
9+
{
10+
private double balance;
11+
12+
public BankAccount()
13+
{
14+
}
15+
16+
public BankAccount(double balance)
17+
{
18+
this.balance = balance;
19+
}
20+
21+
public double Balance
22+
{
23+
get { return balance; }
24+
}
25+
26+
public void Add(double amount)
27+
{
28+
if (amount < 0)
29+
{
30+
throw new ArgumentOutOfRangeException(nameof(amount));
31+
}
32+
33+
balance += amount;
34+
}
35+
36+
public void Withdraw(double amount)
37+
{
38+
if (amount > balance)
39+
{
40+
throw new ArgumentOutOfRangeException(nameof(amount));
41+
}
42+
43+
if (amount < 0)
44+
{
45+
throw new ArgumentOutOfRangeException(nameof(amount));
46+
}
47+
48+
balance -= amount;
49+
}
50+
51+
public void TransferFundsTo(BankAccount otherAccount, double amount)
52+
{
53+
if (otherAccount is null)
54+
{
55+
throw new ArgumentNullException(nameof(otherAccount));
56+
}
57+
58+
Withdraw(amount);
59+
otherAccount.Add(amount);
60+
}
61+
}
62+
}

UnitTestingTutorial.sln

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30804.86
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bank", "Bank\Bank.csproj", "{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Debug|x86 = Debug|x86
13+
Release|Any CPU = Release|Any CPU
14+
Release|x64 = Release|x64
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Debug|x64.ActiveCfg = Debug|Any CPU
21+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Debug|x64.Build.0 = Debug|Any CPU
22+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Debug|x86.ActiveCfg = Debug|Any CPU
23+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Debug|x86.Build.0 = Debug|Any CPU
24+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Release|x64.ActiveCfg = Release|Any CPU
27+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Release|x64.Build.0 = Release|Any CPU
28+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Release|x86.ActiveCfg = Release|Any CPU
29+
{FA0254C6-CC54-4A9C-9159-6BF8CB54F2FA}.Release|x86.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {4BCC87AC-B903-4FB1-9764-3B52191EF14E}
36+
EndGlobalSection
37+
EndGlobal

0 commit comments

Comments
 (0)