From b0f7a0de6859cfbd1e8aac7202ebf0e87c88efba Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 12:41:09 -0600 Subject: [PATCH 1/9] Implement Power method and setup CI --- .github/workflows/ci.yml | 12 ++++++++++-- Console/Program.cs | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64db9d16a..971e413f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: 'Run App , ' +name: 'Run App , ' on: [push, pull_request] @@ -6,4 +6,12 @@ jobs: build-and-test: runs-on: ubuntu-latest steps: - - run: echo "Hello, World!" + - uses: actions/checkout@v2 + - name: install dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + - name: build + run: dotnet build + - name: run unit tests + run: dotnet test \ No newline at end of file diff --git a/Console/Program.cs b/Console/Program.cs index 56bb86061..8eea5e7ae 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -86,6 +86,8 @@ 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 0.0; + double baseNum = double.Parse(x); + double exponent = double.Parse(y); + return Math.Pow(baseNum, exponent); } } From 1103865c3e489800c2424dfeb47352b4740658d8 Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 12:48:37 -0600 Subject: [PATCH 2/9] update --- .github/workflows/ci.yml | 2 +- .github/workflows/run-app.yaml | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .github/workflows/run-app.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 971e413f8..2b43e97bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: 'Run App , ' +name: "Run App Clausen" on: [push, pull_request] diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml new file mode 100644 index 000000000..e69de29bb From 5a3b805a1d33e5161a883d57e170f9e96f538a61 Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 12:57:41 -0600 Subject: [PATCH 3/9] Implement Power method and add CalculatorTests --- CalculatorTests/CalculatorTests.csproj | 23 ++++++++++++++ CalculatorTests/MSTestSettings.cs | 1 + CalculatorTests/ProgramTests.cs | 44 ++++++++++++++++++++++++++ CalculatorTests/Test1.cs | 10 ++++++ 4 files changed, 78 insertions(+) create mode 100644 CalculatorTests/CalculatorTests.csproj create mode 100644 CalculatorTests/MSTestSettings.cs create mode 100644 CalculatorTests/ProgramTests.cs create mode 100644 CalculatorTests/Test1.cs diff --git a/CalculatorTests/CalculatorTests.csproj b/CalculatorTests/CalculatorTests.csproj new file mode 100644 index 000000000..14aa51c8a --- /dev/null +++ b/CalculatorTests/CalculatorTests.csproj @@ -0,0 +1,23 @@ + + + + net9.0 + latest + enable + enable + + + + + + + + + + + + + + + + diff --git a/CalculatorTests/MSTestSettings.cs b/CalculatorTests/MSTestSettings.cs new file mode 100644 index 000000000..aaf278c84 --- /dev/null +++ b/CalculatorTests/MSTestSettings.cs @@ -0,0 +1 @@ +[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] diff --git a/CalculatorTests/ProgramTests.cs b/CalculatorTests/ProgramTests.cs new file mode 100644 index 000000000..5dac2e542 --- /dev/null +++ b/CalculatorTests/ProgramTests.cs @@ -0,0 +1,44 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using GithubActionsLab; // Namespace of your console app + +namespace CalculatorTests +{ + [TestClass] + public class ProgramTests + { + [TestMethod] + public void TestAdd_Clausen() + { + double result = Program.Add("2", "3"); + Assert.AreEqual(5, result); + } + + [TestMethod] + public void TestSubtract_Clausen() + { + double result = Program.Subtract("5", "3"); + Assert.AreEqual(2, result); + } + + [TestMethod] + public void TestMultiply_Clausen() + { + double result = Program.Multiply("4", "3"); + Assert.AreEqual(12, result); + } + + [TestMethod] + public void TestDivide_Clausen() + { + double result = Program.Divide("10", "2"); + Assert.AreEqual(5, result); + } + + [TestMethod] + public void TestPower_Clausen() + { + double result = Program.Power("2", "3"); + Assert.AreEqual(8, result); + } + } +} \ No newline at end of file diff --git a/CalculatorTests/Test1.cs b/CalculatorTests/Test1.cs new file mode 100644 index 000000000..6edafe9ae --- /dev/null +++ b/CalculatorTests/Test1.cs @@ -0,0 +1,10 @@ +namespace CalculatorTests; + +[TestClass] +public sealed class Test1 +{ + [TestMethod] + public void TestMethod1() + { + } +} From 9e5be992ee339ab69a31382b37e3a2cea12b5242 Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 13:02:49 -0600 Subject: [PATCH 4/9] update --- .github/workflows/run-app.yaml | 17 +++++++++++++++++ global.json | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index e69de29bb..1b69eafee 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -0,0 +1,17 @@ +name: 'Run App Clausen, Julia' + +on: [push, pull_request] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: install dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.x' + - name: build + run: dotnet build + - name: run unit tests + run: dotnet test \ No newline at end of file diff --git a/global.json b/global.json index 2ddda36c2..0dcaf0132 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,5 @@ { "sdk": { - "version": "8.0.0", - "rollForward": "latestMinor", - "allowPrerelease": false + "version": "9.0.311" } } \ No newline at end of file From fd0207c4ca3c02392fe9cd6606431c96a3857bfe Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 13:12:33 -0600 Subject: [PATCH 5/9] Trigger GitHub Actions workflow --- .github/workflows/run-app.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index 1b69eafee..ac9780f3b 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -1,3 +1,4 @@ +# Trigger Actions workflow name: 'Run App Clausen, Julia' on: [push, pull_request] From 2e4d180d7668cae062488ee1177688464a6e8e05 Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 13:33:12 -0600 Subject: [PATCH 6/9] retrigger workflow From 3d3e7b64e206302801fb3ad5291cd44148c4bb72 Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 13:47:29 -0600 Subject: [PATCH 7/9] switch back to dotnet 8 --- .github/workflows/run-app.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index ac9780f3b..f84d4d17c 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -1,4 +1,3 @@ -# Trigger Actions workflow name: 'Run App Clausen, Julia' on: [push, pull_request] @@ -11,7 +10,7 @@ jobs: - name: install dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.x' + dotnet-version: '8.x' - name: build run: dotnet build - name: run unit tests From ff6c963664ce53b1579d438309e259bd96bb7849 Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 13:50:21 -0600 Subject: [PATCH 8/9] rename tests to include last name --- Tests/UnitTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index a2d3bd18e..04f11c011 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -4,7 +4,7 @@ namespace GithubActionsLab; public class Addition { [TestMethod] - public void Add_Valid_Patino() + public void Add_Valid_Clausen() { Assert.AreEqual(3, Program.Add("1", "2")); Assert.AreEqual(5, Program.Add("3", "2")); @@ -12,7 +12,7 @@ public void Add_Valid_Patino() } [TestMethod] - public void Add_Invalid_Patino() + public void Add_Invalid_Clausen() { Assert.ThrowsException(() => Program.Add("1", "a")); Assert.ThrowsException(() => Program.Add("a", "1")); @@ -20,7 +20,7 @@ public void Add_Invalid_Patino() } [TestMethod] - public void Add_Null_Patino() + public void Add_Null_Clausen() { Assert.ThrowsException(() => Program.Add("1", null)); Assert.ThrowsException(() => Program.Add(null, "1")); From d7e88c140d0717aeca3e9330443e02f3b131ebdf Mon Sep 17 00:00:00 2001 From: Julia Clausen Date: Tue, 3 Mar 2026 14:17:30 -0600 Subject: [PATCH 9/9] Fix nullable warnings and add null checks --- Console/Program.cs | 60 ++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/Console/Program.cs b/Console/Program.cs index 8eea5e7ae..5a2bbd10e 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -63,31 +63,45 @@ private static string GetInput(string prompt) return Console.ReadLine()?.Trim() ?? throw new InvalidOperationException(); } - public static double Add(string x, string y) - { - return double.Parse(x) + double.Parse(y); - } + public static double Add(string? x, string? y) +{ + if (x == null || y == null) + throw new ArgumentNullException(); - public static double Subtract(string x, string y) - { - return double.Parse(x) - double.Parse(y); - } + return double.Parse(x) + double.Parse(y); +} - public static double Multiply(string x, string y) - { - return double.Parse(x) * double.Parse(y); - } +public static double Subtract(string? x, string? y) +{ + if (x == null || y == null) + throw new ArgumentNullException(); - public static double Divide(string x, string y) - { - return double.Parse(x) / double.Parse(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) - { - double baseNum = double.Parse(x); - double exponent = double.Parse(y); - return Math.Pow(baseNum, exponent); - } +public static double Multiply(string? x, string? y) +{ + if (x == null || y == null) + throw new ArgumentNullException(); + + return double.Parse(x) * double.Parse(y); +} + +public static double Divide(string? x, string? y) +{ + if (x == null || y == null) + throw new ArgumentNullException(); + + return double.Parse(x) / double.Parse(y); +} + +public static double Power(string? x, string? y) +{ + if (x == null || y == null) + throw new ArgumentNullException(); + + double baseNum = double.Parse(x); + double exponent = double.Parse(y); + return Math.Pow(baseNum, exponent); } +} \ No newline at end of file