From 4df0070068177707128554666277655414f50e00 Mon Sep 17 00:00:00 2001 From: Parul-0107 Date: Wed, 31 Mar 2021 16:06:29 -0500 Subject: [PATCH 1/5] Added .travis.yml --- .travis.yml | 9 +++++++++ TravisCI.sln | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..3d6d6f8b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: csharp +solution: TravisCI.sln +branches: + only: + - master +install: + - nuget restore TravisCI.sln +script: + - msbuild /p:Configuration=Release TravisCI.sln \ No newline at end of file diff --git a/TravisCI.sln b/TravisCI.sln index c3edf276..5876a4fd 100644 --- a/TravisCI.sln +++ b/TravisCI.sln @@ -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", "{D9CFF8B8-3F9A-4C44-8991-D603137BBC7D}" + ProjectSection(SolutionItems) = preProject + .travis.yml = .travis.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From cc6f233ba3ed3cd0766e958d2ca54108935539b1 Mon Sep 17 00:00:00 2001 From: Parul-0107 Date: Wed, 31 Mar 2021 16:19:57 -0500 Subject: [PATCH 2/5] Implemented the power function --- Console/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Console/Program.cs b/Console/Program.cs index b3fcdf6a..f0c618ae 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -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)); } } From 659348828aa946daaeac3faf72f61dc4369e3265 Mon Sep 17 00:00:00 2001 From: Parul-0107 Date: Wed, 31 Mar 2021 16:33:43 -0500 Subject: [PATCH 3/5] Made changes to the script in .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d6d6f8b..afd0e8a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ branches: install: - nuget restore TravisCI.sln script: - - msbuild /p:Configuration=Release TravisCI.sln \ No newline at end of file + - msbuild /p:Configuration=Release TravisCI.sln + - mono ./packages/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./Tests/bin/Release/Tests.dll \ No newline at end of file From 3008fec68130b748980a33e7df3cea2b6d1a3a75 Mon Sep 17 00:00:00 2001 From: Parul-0107 Date: Wed, 31 Mar 2021 17:47:46 -0500 Subject: [PATCH 4/5] Added test cases for all the functions, one would fail. --- Tests/UnitTests.cs | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index 84cde036..dc63fd22 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -30,6 +30,114 @@ public void Add_Null() Assert.Throws(() => Program.Add(null, null)); } + /// + /// ////////////////// + /// + + [Test] + public void Subtract_ValidAggarwal() + { + Assert.AreEqual(1, Program.Subtract("2", "1")); + Assert.AreEqual(5, Program.Subtract("10", "5")); + Assert.AreEqual(12, Program.Subtract("20", "8")); + } + + [Test] + public void Subtract_InvalidAggarwal() + { + Assert.Throws(() => Program.Subtract("1", "a")); + Assert.Throws(() => Program.Subtract("a", "1")); + Assert.Throws(() => Program.Subtract("a", "a")); + } + + [Test] + public void Subtract_NullAggarwal() + { + Assert.Throws(() => Program.Subtract("1", null)); + Assert.Throws(() => Program.Subtract(null, "1")); + Assert.Throws(() => Program.Subtract(null, null)); + } + + //////// + /// + + [Test] + public void Multiply_ValidAggarwal () + { + 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_InvalidAggarwal() + { + Assert.Throws(() => Program.Multiply("1", "a")); + Assert.Throws(() => Program.Multiply("a", "1")); + Assert.Throws(() => Program.Multiply("a", "a")); + } + + [Test] + public void Multiply_NullAggarwal() + { + Assert.Throws(() => Program.Multiply("1", null)); + Assert.Throws(() => Program.Multiply(null, "1")); + Assert.Throws(() => Program.Multiply(null, null)); + } + + /////// + /// + + [Test] + public void Divide_ValidAggarwal() + { + 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_InvalidAggarwal () + { + Assert.Throws(() => Program.Divide("1", "a")); + Assert.Throws(() => Program.Divide("a", "1")); + Assert.Throws(() => Program.Divide("a", "a")); + } + + [Test] + public void Divide_NullAggarwal() + { + Assert.Throws(() => Program.Divide("1", null)); + Assert.Throws(() => Program.Divide(null, "1")); + Assert.Throws(() => Program.Divide(null, null)); + } + + //////// + /// + + [Test] + public void Power_ValidAggarwal() + { + Assert.AreEqual(2, Program.Power("1", "2")); + Assert.AreEqual(9, Program.Power("3", "2")); + Assert.AreEqual(125, Program.Power("5", "3")); + } + + [Test] + public void Power_InvalidAggarwal() + { + Assert.Throws(() => Program.Power("1", "a")); + Assert.Throws(() => Program.Power("a", "1")); + Assert.Throws(() => Program.Power("a", "a")); + } + + [Test] + public void Power_NullAggarwal() + { + Assert.Throws(() => Program.Power("1", null)); + Assert.Throws(() => Program.Power(null, "1")); + Assert.Throws(() => Program.Power(null, null)); + } // Implement 3 tests per operation, following a similar pattern as above } } From 6e5b42a09e70a18ba6228d0f02215088c1259c10 Mon Sep 17 00:00:00 2001 From: Parul-0107 Date: Wed, 31 Mar 2021 17:56:50 -0500 Subject: [PATCH 5/5] Fixed the test --- Tests/UnitTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index dc63fd22..de518b41 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -118,7 +118,7 @@ public void Divide_NullAggarwal() [Test] public void Power_ValidAggarwal() { - Assert.AreEqual(2, Program.Power("1", "2")); + Assert.AreEqual(1, Program.Power("1", "2")); Assert.AreEqual(9, Program.Power("3", "2")); Assert.AreEqual(125, Program.Power("5", "3")); }