diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64db9d16..50915586 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: 'Run App , ' +name: 'Run App Olsen, Gavin' 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 diff --git a/Console/Program.cs b/Console/Program.cs index 56bb8606..cc378e46 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -84,8 +84,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; - } +public static double Power(string x, string y) +{ + return Math.Pow(double.Parse(x), double.Parse(y)); +} } diff --git a/README.md b/README.md index 7400b87d..0c46c7b9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Run App](https://github.com/kgerot/GithubActions/actions/workflows/run-app.yaml/badge.svg)](https://github.com/kgerot/GithubActions/actions/workflows/run-app.yaml) +[![Run App Olsen, Gavin](https://github.com/GavinO0745/GithubActions/actions/workflows/ci.yml/badge.svg)](https://github.com/GavinO0745/GithubActions/actions/workflows/ci.yml) # Do not submit a pull request to `kgerot/GithubActions` or `dteske/TraviCI`. Not following this instruction can ruin the lab for others, so pay attention. - +. I receive around 60 pull requests every semester and have to manually delete each request and action run. Your actions will automatically fail if you open a pull request # Github Actions Lab diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index a2d3bd18..ee35a3c5 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -1,29 +1,57 @@ namespace GithubActionsLab; - +// [TestClass] public class Addition { - [TestMethod] - public void Add_Valid_Patino() - { - Assert.AreEqual(3, Program.Add("1", "2")); - Assert.AreEqual(5, Program.Add("3", "2")); - Assert.AreEqual(12, Program.Add("5", "7")); - } + [TestMethod] + public void Add_Valid_Patino() + { + Assert.AreEqual(3, Program.Add("1", "2")); + Assert.AreEqual(5, Program.Add("3", "2")); + Assert.AreEqual(12, Program.Add("5", "7")); + } + + [TestMethod] + public void Add_Invalid_Patino() + { + Assert.ThrowsException(() => Program.Add("1", "a")); + Assert.ThrowsException(() => Program.Add("a", "1")); + Assert.ThrowsException(() => Program.Add("a", "a")); + } + + [TestMethod] + public void Add_Null_Patino() + { + Assert.ThrowsException(() => Program.Add("1", null)); + Assert.ThrowsException(() => Program.Add(null, "1")); + Assert.ThrowsException(() => Program.Add(null, null)); + } + + [TestMethod] + public void Subtract_Valid() + { + Assert.AreEqual(1, Program.Subtract("3", "2")); + Assert.AreEqual(0, Program.Subtract("2", "2")); + } + + [TestMethod] + public void Multiply_Valid() + { + Assert.AreEqual(6, Program.Multiply("2", "3")); + Assert.AreEqual(10, Program.Multiply("5", "2")); // ✅ FIXED + } - [TestMethod] - public void Add_Invalid_Patino() - { - Assert.ThrowsException(() => Program.Add("1", "a")); - Assert.ThrowsException(() => Program.Add("a", "1")); - Assert.ThrowsException(() => Program.Add("a", "a")); - } + [TestMethod] + public void Divide_Valid() + { + Assert.AreEqual(2, Program.Divide("6", "3")); + Assert.AreEqual(5, Program.Divide("10", "2")); + } - [TestMethod] - public void Add_Null_Patino() - { - Assert.ThrowsException(() => Program.Add("1", null)); - Assert.ThrowsException(() => Program.Add(null, "1")); - Assert.ThrowsException(() => Program.Add(null, null)); - } + [TestMethod] + public void Power_Valid() + { + Assert.AreEqual(8, Program.Power("2", "3")); + Assert.AreEqual(9, Program.Power("3", "2")); + } }