Skip to content
Open

Dev #184

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
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: csharp
solution: TravisCI.sln
branches:
only:
- master
install:
- nuget restore TravisCI.sln
script:
- msbuild /p:Configuration=Release TravisCI.sln
- mono ./packages/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./Tests/bin/Release/Tests.dll
2 changes: 1 addition & 1 deletion Console/Console.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down
25 changes: 25 additions & 0 deletions Console/Console.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.810.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "Console.csproj", "{C5964EEF-DA27-4C98-B4D0-7F27767FE870}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C5964EEF-DA27-4C98-B4D0-7F27767FE870}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5964EEF-DA27-4C98-B4D0-7F27767FE870}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5964EEF-DA27-4C98-B4D0-7F27767FE870}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5964EEF-DA27-4C98-B4D0-7F27767FE870}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E9E65B21-FC44-473C-AF97-180CE81CA355}
EndGlobalSection
EndGlobal
12 changes: 8 additions & 4 deletions Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ public static double Divide(string x, string y)
return double.Parse(x) / double.Parse(y);
}

// Implement this method following a similar pattern as above
public static double Power(string x, string y)
{
throw new NotImplementedException();
}
}

double ret = 1;
for (int i = 0; i <= double.Parse(y); i++) {
ret *= double.Parse(x);

}
return ret;
}

}

}
77 changes: 76 additions & 1 deletion Tests/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,81 @@ public void Add_Null()
Assert.Throws<ArgumentNullException>(() => Program.Add(null, null));
}

// Implement 3 tests per operation, following a similar pattern as above
[Test]
public void Sub_Valid_Durante(){
Assert.AreEqual(-1, Program.Subtract("1", "2"));
Assert.AreEqual(1, Program.Subtract("3", "2"));
Assert.AreEqual(3, Program.Subtract("10", "7"));
}

[Test]
public void Sub_Invalid_Durante(){
Assert.Throws<FormatException>(() => Program.Subtract("1", "a"));
Assert.Throws<FormatException>(() => Program.Subtract("a", "1"));
Assert.Throws<FormatException>(() => Program.Subtract("a", "a"));
}
[Test]
public void Sub_Null_Durante(){
Assert.Throws<ArgumentNullException>(() => Program.Subtract("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Subtract(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Subtract(null, null));
}

[Test]
public void Mult_Valid_Durante(){
Assert.AreEqual(2, Program.Multiply("1", "2"));
Assert.AreEqual(0, Program.Multiply("0", "99"));
Assert.AreEqual(70, Program.Multiply("10", "7"));
}
[Test]
public void Mult_Invalid_Durante(){
Assert.Throws<FormatException>(() => Program.Multiply("1", "a"));
Assert.Throws<FormatException>(() => Program.Multiply("a", "1"));
Assert.Throws<FormatException>(() => Program.Multiply("a", "a"));
}
[Test]
public void Mult_Null_Durante(){
Assert.Throws<ArgumentNullException>(() => Program.Multiply("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Multiply(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Multiply(null, null));
}

[Test]
public void Div_Valid_Durante(){
Assert.AreEqual(.5, Program.Divide("1", "2"));
Assert.AreEqual(0, Program.Divide("0", "99"));
Assert.AreEqual(20, Program.Divide("100", "5"));
}
[Test]
public void Div_Invalid_Durante(){
Assert.Throws<FormatException>(() => Program.Divide("1", "a"));
Assert.Throws<FormatException>(() => Program.Divide("a", "1"));
Assert.Throws<FormatException>(() => Program.Divide("a", "a"));
}
[Test]
public void Div_Null_Durante(){
Assert.Throws<ArgumentNullException>(() => Program.Divide("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Divide(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Divide(null, null));
}

[Test]
public void Pow_Valid_Durante(){
Assert.AreEqual(0, Program.Power("0", "2"));
Assert.AreEqual(64, Program.Power("4", "2"));
Assert.AreEqual(81, Program.Power("3", "3"));
}
[Test]
public void Pow_Invalid_Durante(){
Assert.Throws<FormatException>(() => Program.Power("1", "a"));
Assert.Throws<FormatException>(() => Program.Power("a", "1"));
Assert.Throws<FormatException>(() => Program.Power("a", "a"));
}
[Test]
public void Pow_Null_Durante(){
Assert.Throws<ArgumentNullException>(() => Program.Power("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Power(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Power(null, null));
}
}
}