Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 12 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/TDDKata/.vs/TDDKata/v15/Server/sqlite3/storage.ide-wal
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
"",
"\\TDDKata"
],
"PreviewInSolutionExplorer": false
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-24ddc0f5d75046c5622901739e7c5dd533143b0c8e959d652212380cedb1ea36.svg)](https://classroom.github.com/a/SDJT-yFW)
Binary file added TDDKata/.vs/TDDKata/DesignTimeBuild/.dtbcache
Binary file not shown.
31 changes: 31 additions & 0 deletions TDDKata/TDDKata.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1831
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDDKata", "TDDKata\TDDKata.csproj", "{725B7F1B-8D19-45D1-8CA8-995995F5FA50}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDDKataCalc", "TDDKataCalc\TDDKataCalc.csproj", "{596AC400-3E05-41A4-AC0B-D860C62FF3B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{725B7F1B-8D19-45D1-8CA8-995995F5FA50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{725B7F1B-8D19-45D1-8CA8-995995F5FA50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{725B7F1B-8D19-45D1-8CA8-995995F5FA50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{725B7F1B-8D19-45D1-8CA8-995995F5FA50}.Release|Any CPU.Build.0 = Release|Any CPU
{596AC400-3E05-41A4-AC0B-D860C62FF3B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{596AC400-3E05-41A4-AC0B-D860C62FF3B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{596AC400-3E05-41A4-AC0B-D860C62FF3B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{596AC400-3E05-41A4-AC0B-D860C62FF3B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {380C4580-FF73-41D9-BB13-A2E15BF2F4DD}
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions TDDKata/TDDKata/TDDKata.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>

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

</Project>
275 changes: 275 additions & 0 deletions TDDKata/TDDKata/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
using TDDKataCalc;
using Xunit;

namespace TDDKata
{
public class UnitTest1
{
/*Create a simple String calculator with a method�int Add(string numbers)The method can take 0, 1 or 2 numbers,
and will return their sum (for an empty string it will return 0) for example��� or �1� or �1,2�
Start with the simplest test case of an empty string and move to 1 and 2 numbers
Remember to solve things as simply as possible so that you force yourself to write tests you did not think about
Remember to refactor �after each passing test */
[Fact]
public void AddBlankAndCalcShouldReturnZero()
{
//Arrange
string digits = "";
int expected = 0;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddNullAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = null;
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}

[Fact]
public void AddCorrectDigitsAndCalcShouldReturnCorrectResult()
{
//Arrange
string digits = "1,2,3";
int expected = 6;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddMultipleCommasCalcShouldReturnMinusOne()
{
//Arrange
string digits = "1,,2,,3";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddStringAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "ss";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddCommaSeparatedStringAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "s,s";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddOtherThanCommasAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "1@";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddStringAndDigitWithCommasAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "abc,1,2";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddStringAndDigitOnlyAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "abc12";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddMaxDigitAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = int.MaxValue + 1.ToString();
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}

/*Allow the Add method to handle new lines between numbers (instead of commas)
�the following input is ok:� �1\n2,3�� (will equal 6)
�the following input is NOT�ok:� �1,\n�*/
[Fact]
public void AddNewLineWithCommasAndCalcShouldReturnCorrectResult()
{
//Arrange
string digits = "1\n2,3";
int expected = 6;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddNewLineInEndAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "1,\n";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddStringNewLineAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "A\n";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddNewLineInStartAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "\n1,2";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddOnlyNewLineAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "\n";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
/*Support different delimiters
to change a delimiter, the beginning of the string will contain a separate line that looks like this:��
�//[delimiter]\n[numbers�]� for example �//;\n1;2� should return three where the default delimiter is �;��
the first line is optional � all existing scenarios should still be supported*/
[Fact]
public void AddNewDelimitersNewLineAndCalcShouldReturnCorrectResult()
{
//Arrange
string digits = "//;\n1;2";
int expected = 3;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddDifferentDelimitersNoNewLineAndCalcShouldReturnMinusOne()
{
//Arrange
string digits = "//;1;2;3";
int expected = -1;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
[Fact]
public void AddDifferentDelimitersWithNewLineAndCalcShouldReturnCorrectResult()
{
//Arrange
string digits = "//;\n1,2,3";
int expected = 6;
var result = new Calc();

//Act
var actual = result.Add(digits);

//Assert
Assert.Equal(expected, actual);
}
}
}
Loading