Skip to content
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
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: csharp
solution: TravisCI.sln
branches:
only:
- master
install:
- nuget restore TravisCI.sln
script:
- msbuild /p:Configuration=Release TravisCI.sln
2 changes: 1 addition & 1 deletion Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static double Divide(string x, string y)
// Implement this method following a similar pattern as above
public static double Power(string x, string y)
{
throw new NotImplementedException();
return Math.Pow(double.Parse(x), double.Parse(y));
}
}

Expand Down
108 changes: 108 additions & 0 deletions Tests/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,114 @@ public void Add_Null()
Assert.Throws<ArgumentNullException>(() => Program.Add(null, null));
}

/// <summary>
/// //////////////////
/// </summary>

[Test]
public void Subtract_ValidPatel()
{
Assert.AreEqual(0, Program.Subtract("2", "1"));
Assert.AreEqual(5, Program.Subtract("10", "5"));
Assert.AreEqual(12, Program.Subtract("20", "8"));
}

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

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

////////
///

[Test]
public void Multiply_ValidPatel()
{
Assert.AreEqual(2, Program.Multiply("1", "2"));
Assert.AreEqual(6, Program.Multiply("3", "2"));
Assert.AreEqual(35, Program.Multiply("5", "7"));
}

[Test]
public void Multiply_InvalidPatel()
{
Assert.Throws<FormatException>(() => Program.Multiply("1", "a"));
Assert.Throws<FormatException>(() => Program.Multiply("a", "1"));
Assert.Throws<FormatException>(() => Program.Multiply("a", "a"));
}

[Test]
public void Multiply_NullPatel()
{
Assert.Throws<ArgumentNullException>(() => Program.Multiply("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Multiply(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Multiply(null, null));
}

///////
///

[Test]
public void Divide_ValidPatel()
{
Assert.AreEqual(1, Program.Divide("2", "2"));
Assert.AreEqual(4, Program.Divide("8", "2"));
Assert.AreEqual(3, Program.Divide("21", "7"));
}

[Test]
public void Divide_InvalidPatel()
{
Assert.Throws<FormatException>(() => Program.Divide("1", "a"));
Assert.Throws<FormatException>(() => Program.Divide("a", "1"));
Assert.Throws<FormatException>(() => Program.Divide("a", "a"));
}

[Test]
public void Divide_NullPatel()
{
Assert.Throws<ArgumentNullException>(() => Program.Divide("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Divide(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Divide(null, null));
}

////////
///

[Test]
public void Power_ValidPatel()
{
Assert.AreEqual(1, Program.Power("1", "2"));
Assert.AreEqual(9, Program.Power("3", "2"));
Assert.AreEqual(125, Program.Power("5", "3"));
}

[Test]
public void Power_InvalidPatel()
{
Assert.Throws<FormatException>(() => Program.Power("1", "a"));
Assert.Throws<FormatException>(() => Program.Power("a", "1"));
Assert.Throws<FormatException>(() => Program.Power("a", "a"));
}

[Test]
public void Power_NullPatel()
{
Assert.Throws<ArgumentNullException>(() => Program.Power("1", null));
Assert.Throws<ArgumentNullException>(() => Program.Power(null, "1"));
Assert.Throws<ArgumentNullException>(() => Program.Power(null, null));
}
// Implement 3 tests per operation, following a similar pattern as above
}
}
9 changes: 7 additions & 2 deletions TravisCI.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "Console\Console.csproj", "{C5964EEF-DA27-4C98-B4D0-7F27767FE870}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{C3F293D9-3D79-4280-9E67-9E51A00E94F3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4BD22914-4397-4313-B901-239CE74CD21E}"
ProjectSection(SolutionItems) = preProject
.travis.yml = .travis.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down