From 8c80238f9f3ff35b66e5e1465da3df4cb90c1276 Mon Sep 17 00:00:00 2001 From: Caleb Koranda Date: Wed, 31 Mar 2021 14:05:47 -0500 Subject: [PATCH 1/3] Update Program.cs --- Console/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Console/Program.cs b/Console/Program.cs index b3fcdf6a..caee0994 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 591e828c7e51426cb7a9b6382731940d583f3397 Mon Sep 17 00:00:00 2001 From: Caleb Koranda Date: Wed, 31 Mar 2021 14:48:09 -0500 Subject: [PATCH 2/3] Update UnitTests.cs --- Tests/UnitTests.cs | 102 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 3 deletions(-) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index 84cde036..8d0d8ca3 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -7,7 +7,7 @@ namespace TravisCILab public class Math { [Test] - public void Add_Valid() + public void Add_Valid_Koranda() { Assert.AreEqual(3, Program.Add("1", "2")); Assert.AreEqual(5, Program.Add("3", "2")); @@ -15,7 +15,7 @@ public void Add_Valid() } [Test] - public void Add_Invalid() + public void Add_Invalid_Koranda() { Assert.Throws(() => Program.Add("1", "a")); Assert.Throws(() => Program.Add("a", "1")); @@ -23,7 +23,7 @@ public void Add_Invalid() } [Test] - public void Add_Null() + public void Add_Null_Koranda() { Assert.Throws(() => Program.Add("1", null)); Assert.Throws(() => Program.Add(null, "1")); @@ -31,5 +31,101 @@ public void Add_Null() } // Implement 3 tests per operation, following a similar pattern as above + + [Test] + public void Subtract_Valid_Koranda() + { + Assert.AreEqual(3, Program.Subtract("5", "2")); + Assert.AreEqual(5, Program.Subtract("7", "2")); + Assert.AreEqual(12, Program.Subtract("19", "7")); + } + + [Test] + public void Subtract_Invalid_Koranda() + { + Assert.Throws(() => Program.Subtract("1", "a")); + Assert.Throws(() => Program.Subtract("a", "1")); + Assert.Throws(() => Program.Subtract("a", "a")); + } + + [Test] + public void Subtract_Null_Koranda() + { + Assert.Throws(() => Program.Subtract("1", null)); + Assert.Throws(() => Program.Subtract(null, "1")); + Assert.Throws(() => Program.Subtract(null, null)); + } + + [Test] + public void Multiply_Valid_Koranda() + { + Assert.AreEqual(3, Program.Multiply("1", "3")); + Assert.AreEqual(6, Program.Multiply("3", "2")); + Assert.AreEqual(35, Program.Multiply("5", "7")); + } + + [Test] + public void Multiply_Invalid_Koranda() + { + Assert.Throws(() => Program.Multiply("1", "a")); + Assert.Throws(() => Program.Multiply("a", "1")); + Assert.Throws(() => Program.Multiply("a", "a")); + } + + [Test] + public void Multiply_Null_Koranda() + { + Assert.Throws(() => Program.Multiply("1", null)); + Assert.Throws(() => Program.Multiply(null, "1")); + Assert.Throws(() => Program.Multiply(null, null)); + } + + [Test] + public void Divide_Valid_Koranda() + { + Assert.AreEqual(3, Program.Divide("6", "2")); + Assert.AreEqual(5, Program.Divide("10", "2")); + Assert.AreEqual(12, Program.Divide("60", "5")); + } + + [Test] + public void Divide_Invalid_Koranda() + { + Assert.Throws(() => Program.Divide("1", "a")); + Assert.Throws(() => Program.Divide("a", "1")); + Assert.Throws(() => Program.Divide("a", "a")); + } + + [Test] + public void Divide_Null_Koranda() + { + Assert.Throws(() => Program.Divide("1", null)); + Assert.Throws(() => Program.Divide(null, "1")); + Assert.Throws(() => Program.Divide(null, null)); + } + + [Test] + public void Power_Valid_Koranda() + { + Assert.AreEqual(4, Program.Power("1", "2")); + Assert.AreEqual(9, Program.Power("3", "2")); + Assert.AreEqual(1, Program.Power("1", "7")); + } + + [Test] + public void Power_Invalid_Koranda() + { + Assert.Throws(() => Program.Power("1", "a")); + Assert.Throws(() => Program.Power("a", "1")); + Assert.Throws(() => Program.Power("a", "a")); + } + + [Test] + public void Power_Null_Koranda() + { + Assert.Throws(() => Program.Power("1", null)); + Assert.Throws(() => Program.Power(null, "1")); + Assert.Throws(() => Program.Power(null, null)); + } } } From 19616369a7c474f71ab91d8e87c6baf570da9f7c Mon Sep 17 00:00:00 2001 From: Caleb Koranda Date: Wed, 31 Mar 2021 14:57:19 -0500 Subject: [PATCH 3/3] Update UnitTests.cs --- Tests/UnitTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index 8d0d8ca3..9ed3d322 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -107,7 +107,7 @@ public void Divide_Null_Koranda() [Test] public void Power_Valid_Koranda() { - Assert.AreEqual(4, Program.Power("1", "2")); + Assert.AreEqual(4, Program.Power("2", "2")); Assert.AreEqual(9, Program.Power("3", "2")); Assert.AreEqual(1, Program.Power("1", "7")); }