From bec4d2ab0f0eb379b5ebeda72e9976c79d8f0650 Mon Sep 17 00:00:00 2001 From: itcast123 Date: Wed, 31 Mar 2021 11:45:37 -0500 Subject: [PATCH 1/9] =?UTF-8?q?yml=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..5bf208ef --- /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 From 8e39a1a5062ef1bcddb2fbf79921ba7b4615572c Mon Sep 17 00:00:00 2001 From: itcast123 Date: Wed, 31 Mar 2021 12:34:56 -0500 Subject: [PATCH 2/9] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=8B=89=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Console/Program.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Console/Program.cs b/Console/Program.cs index b3fcdf6a..fff44878 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -19,7 +19,7 @@ static void Main(string[] args) Console.WriteLine("4) Divide (x/y)"); Console.WriteLine("5) Power (x^y)"); Console.WriteLine("6) Quit"); - var operationSelection = GetInput("Select your operation: "); + var operationSelection = GetInputLi("Select your operation: "); switch (operationSelection) { case "1": @@ -44,8 +44,8 @@ static void Main(string[] args) throw new ArgumentException("You did not select a valid option!"); } - var x = GetInput("Enter x: "); - var y = GetInput("Enter y: "); + var x = GetInputLi("Enter x: "); + var y = GetInputLi("Enter y: "); var result = operation(x, y); Console.WriteLine($"Result: {result}"); } @@ -57,34 +57,34 @@ static void Main(string[] args) } } - public static string GetInput(string prompt) + public static string GetInputLi(string prompt) { Console.Write(prompt); return Console.ReadLine().Trim(); } - public static double Add(string x, string y) + public static double AddLi(string x, string y) { return double.Parse(x) + double.Parse(y); } - public static double Subtract(string x, string y) + public static double SubtractLi(string x, string y) { return double.Parse(x) - double.Parse(y); } - public static double Multiply(string x, string y) + public static double MultiplyLi(string x, string y) { return double.Parse(x) * double.Parse(y); } - public static double Divide(string x, string y) + public static double DivideLi(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) + public static double PowerLi(string x, string y) { - throw new NotImplementedException(); + return Math.Pow(double.Parse(x), double.Parse(y)); } } From 2d4db1bd949937d132bc633f9c2bfa09926e1db4 Mon Sep 17 00:00:00 2001 From: itcast123 Date: Wed, 31 Mar 2021 13:41:17 -0500 Subject: [PATCH 3/9] tijiaodaomaster --- Console/Program.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Console/Program.cs b/Console/Program.cs index fff44878..b3fcdf6a 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -19,7 +19,7 @@ static void Main(string[] args) Console.WriteLine("4) Divide (x/y)"); Console.WriteLine("5) Power (x^y)"); Console.WriteLine("6) Quit"); - var operationSelection = GetInputLi("Select your operation: "); + var operationSelection = GetInput("Select your operation: "); switch (operationSelection) { case "1": @@ -44,8 +44,8 @@ static void Main(string[] args) throw new ArgumentException("You did not select a valid option!"); } - var x = GetInputLi("Enter x: "); - var y = GetInputLi("Enter y: "); + var x = GetInput("Enter x: "); + var y = GetInput("Enter y: "); var result = operation(x, y); Console.WriteLine($"Result: {result}"); } @@ -57,34 +57,34 @@ static void Main(string[] args) } } - public static string GetInputLi(string prompt) + public static string GetInput(string prompt) { Console.Write(prompt); return Console.ReadLine().Trim(); } - public static double AddLi(string x, string y) + public static double Add(string x, string y) { return double.Parse(x) + double.Parse(y); } - public static double SubtractLi(string x, string y) + public static double Subtract(string x, string y) { return double.Parse(x) - double.Parse(y); } - public static double MultiplyLi(string x, string y) + public static double Multiply(string x, string y) { return double.Parse(x) * double.Parse(y); } - public static double DivideLi(string x, string y) + 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 PowerLi(string x, string y) + public static double Power(string x, string y) { - return Math.Pow(double.Parse(x), double.Parse(y)); + throw new NotImplementedException(); } } From 5143c16814b1a5dd3bd9ce687250e96550a3746e Mon Sep 17 00:00:00 2001 From: itcast123 Date: Wed, 31 Mar 2021 13:47:19 -0500 Subject: [PATCH 4/9] tijiao --- Console/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Console/Program.cs b/Console/Program.cs index b3fcdf6a..cce74e0d 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -89,5 +89,4 @@ public static double Power(string x, string y) } - } From a019ea2596958088f1708da389fd311e70b403f2 Mon Sep 17 00:00:00 2001 From: itcast123 Date: Wed, 31 Mar 2021 14:32:57 -0500 Subject: [PATCH 5/9] pushtoaa --- Console/Program.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Console/Program.cs b/Console/Program.cs index cce74e0d..fff44878 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -19,7 +19,7 @@ static void Main(string[] args) Console.WriteLine("4) Divide (x/y)"); Console.WriteLine("5) Power (x^y)"); Console.WriteLine("6) Quit"); - var operationSelection = GetInput("Select your operation: "); + var operationSelection = GetInputLi("Select your operation: "); switch (operationSelection) { case "1": @@ -44,8 +44,8 @@ static void Main(string[] args) throw new ArgumentException("You did not select a valid option!"); } - var x = GetInput("Enter x: "); - var y = GetInput("Enter y: "); + var x = GetInputLi("Enter x: "); + var y = GetInputLi("Enter y: "); var result = operation(x, y); Console.WriteLine($"Result: {result}"); } @@ -57,36 +57,37 @@ static void Main(string[] args) } } - public static string GetInput(string prompt) + public static string GetInputLi(string prompt) { Console.Write(prompt); return Console.ReadLine().Trim(); } - public static double Add(string x, string y) + public static double AddLi(string x, string y) { return double.Parse(x) + double.Parse(y); } - public static double Subtract(string x, string y) + public static double SubtractLi(string x, string y) { return double.Parse(x) - double.Parse(y); } - public static double Multiply(string x, string y) + public static double MultiplyLi(string x, string y) { return double.Parse(x) * double.Parse(y); } - public static double Divide(string x, string y) + public static double DivideLi(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) + public static double PowerLi(string x, string y) { - throw new NotImplementedException(); + return Math.Pow(double.Parse(x), double.Parse(y)); } } + } From 1285927c015900b5d9dff631233ec505d17c80f9 Mon Sep 17 00:00:00 2001 From: itcast123 Date: Wed, 31 Mar 2021 16:29:49 -0500 Subject: [PATCH 6/9] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E4=B8=AA=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Console/Program.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Console/Program.cs b/Console/Program.cs index fff44878..ba690a96 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -19,7 +19,7 @@ static void Main(string[] args) Console.WriteLine("4) Divide (x/y)"); Console.WriteLine("5) Power (x^y)"); Console.WriteLine("6) Quit"); - var operationSelection = GetInputLi("Select your operation: "); + var operationSelection = GetInput("Select your operation: "); switch (operationSelection) { case "1": @@ -44,8 +44,8 @@ static void Main(string[] args) throw new ArgumentException("You did not select a valid option!"); } - var x = GetInputLi("Enter x: "); - var y = GetInputLi("Enter y: "); + var x = GetInput("Enter x: "); + var y = GetInput("Enter y: "); var result = operation(x, y); Console.WriteLine($"Result: {result}"); } @@ -57,34 +57,34 @@ static void Main(string[] args) } } - public static string GetInputLi(string prompt) + public static string GetInput(string prompt) { Console.Write(prompt); return Console.ReadLine().Trim(); } - public static double AddLi(string x, string y) + public static double Add(string x, string y) { return double.Parse(x) + double.Parse(y); } - public static double SubtractLi(string x, string y) + public static double Subtract(string x, string y) { return double.Parse(x) - double.Parse(y); } - public static double MultiplyLi(string x, string y) + public static double Multiply(string x, string y) { return double.Parse(x) * double.Parse(y); } - public static double DivideLi(string x, string y) + 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 PowerLi(string x, string y) + public static double Power(string x, string y) { - return Math.Pow(double.Parse(x), double.Parse(y)); + return Math.Pow(Double.Parse(x), Double.Parse(y)); } } From 2c3e3329f8ba6dc430383c578716d389c064d570 Mon Sep 17 00:00:00 2001 From: bingolxdtca <81684545+bingolxdtca@users.noreply.github.com> Date: Wed, 31 Mar 2021 18:47:15 -0500 Subject: [PATCH 7/9] Update Program.cs --- Console/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Console/Program.cs b/Console/Program.cs index ba690a96..b71ca11b 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -84,6 +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) { + // return Math.Pow(Double.Parse(x), Double.Parse(y)); } } From 161c08e8b2c886feb73f3b8aa02cdbf3cbd09abe Mon Sep 17 00:00:00 2001 From: bingolxdtca <81684545+bingolxdtca@users.noreply.github.com> Date: Wed, 31 Mar 2021 18:55:25 -0500 Subject: [PATCH 8/9] Update .travis.yml ss --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5bf208ef..09799671 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,4 @@ 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 From 9afd5755cc65a72652c8b11cc2913f61cea0d2ec Mon Sep 17 00:00:00 2001 From: bingolxdtca <81684545+bingolxdtca@users.noreply.github.com> Date: Wed, 31 Mar 2021 19:23:25 -0500 Subject: [PATCH 9/9] Update UnitTests.cs --- Tests/UnitTests.cs | 117 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 6 deletions(-) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index 84cde036..d84d2c58 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -1,13 +1,14 @@ -using System; +using System; using NUnit.Framework; namespace TravisCILab { [TestFixture] - public class Math + public class MathLi { + #region Add [Test] - public void Add_Valid() + public void Add_ValidLi() { Assert.AreEqual(3, Program.Add("1", "2")); Assert.AreEqual(5, Program.Add("3", "2")); @@ -15,7 +16,7 @@ public void Add_Valid() } [Test] - public void Add_Invalid() + public void Add_InvalidLi() { Assert.Throws(() => Program.Add("1", "a")); Assert.Throws(() => Program.Add("a", "1")); @@ -23,13 +24,117 @@ public void Add_Invalid() } [Test] - public void Add_Null() + public void Add_NullLi() { Assert.Throws(() => Program.Add("1", null)); Assert.Throws(() => Program.Add(null, "1")); Assert.Throws(() => Program.Add(null, null)); } + #endregion - // Implement 3 tests per operation, following a similar pattern as above + #region Subtract + [Test] + public void Subtract_ValidLi() + { + Assert.AreEqual(3, Program.Subtract("5", "2")); + Assert.AreEqual(1, Program.Subtract("3", "2")); + Assert.AreEqual(1, Program.Subtract("5", "4")); + } + + [Test] + public void Subtract_InvalidLi() + { + Assert.Throws(() => Program.Subtract("1", "a")); + Assert.Throws(() => Program.Subtract("a", "1")); + Assert.Throws(() => Program.Subtract("a", "a")); + } + + [Test] + public void Subtract_NullLi() + { + Assert.Throws(() => Program.Subtract("1", null)); + Assert.Throws(() => Program.Subtract(null, "1")); + Assert.Throws(() => Program.Subtract(null, null)); + } + #endregion + + #region Multiply + [Test] + public void Multiply_ValidLi() + { + Assert.AreEqual(2, Program.Multiply("1", "2")); + Assert.AreEqual(6, Program.Multiply("3", "2")); + Assert.AreEqual(5, Program.Multiply("5", "1")); + } + + [Test] + public void Multiply_InvalidLi() + { + Assert.Throws(() => Program.Multiply("1", "a")); + Assert.Throws(() => Program.Multiply("a", "1")); + Assert.Throws(() => Program.Multiply("a", "a")); + } + + [Test] + public void Multiply_NullLi() + { + Assert.Throws(() => Program.Multiply("1", null)); + Assert.Throws(() => Program.Multiply(null, "1")); + Assert.Throws(() => Program.Multiply(null, null)); + } + #endregion + + #region Divide + [Test] + public void Divide_ValidLi() + { + Assert.AreEqual(3, Program.Divide("3", "1")); + Assert.AreEqual(1.5, Program.Divide("3", "2")); + Assert.AreEqual(12, Program.Divide("24", "2")); + } + + [Test] + public void Divide_InvalidLi() + { + Assert.Throws(() => Program.Divide("1", "a")); + Assert.Throws(() => Program.Divide("a", "1")); + Assert.Throws(() => Program.Divide("a", "a")); + } + + [Test] + public void Divide_NullLi() + { + Assert.Throws(() => Program.Divide("1", null)); + Assert.Throws(() => Program.Divide(null, "1")); + Assert.Throws(() => Program.Divide(null, null)); + } + #endregion + + #region Power + [Test] + public void Power_ValidLi() + { + Assert.AreEqual(1, Program.Power("1", "2")); + Assert.AreEqual(9, Program.Power("3", "2")); + Assert.AreEqual(5, Program.Power("5", "1")); + } + + [Test] + public void Power_InvalidLi() + { + Assert.Throws(() => Program.Power("1", "a")); + Assert.Throws(() => Program.Power("a", "1")); + Assert.Throws(() => Program.Power("a", "a")); + } + + [Test] + public void Power_NullLi() + { + Assert.Throws(() => Program.Power("1", null)); + Assert.Throws(() => Program.Power(null, "1")); + Assert.Throws(() => Program.Power(null, null)); + } + #endregion } } +