diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64db9d16a..ff8a95f68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: 'Run App , ' +name: 'Run App Kundoor, Subbu' 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..90c3e61b7 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -86,6 +86,6 @@ 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; + return Math.Pow(double.Parse(x), double.Parse(y)); } } diff --git a/README.md b/README.md index 7400b87d5..557d9b6b4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![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 Kundoor, Subbu](https://github.com/skundoor2/GithubActions/actions/workflows/ci.yml/badge.svg)](https://github.com/skundoor2/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. diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index a2d3bd18e..9aab5ade2 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_Kundoor() { 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_Kundoor() { Assert.ThrowsException(() => Program.Add("1", "a")); Assert.ThrowsException(() => Program.Add("a", "1")); @@ -20,10 +20,122 @@ public void Add_Invalid_Patino() } [TestMethod] - public void Add_Null_Patino() + public void Add_Null_Kundoor() { Assert.ThrowsException(() => Program.Add("1", null)); Assert.ThrowsException(() => Program.Add(null, "1")); Assert.ThrowsException(() => Program.Add(null, null)); } } + +[TestClass] +public class Subtraction +{ + [TestMethod] + public void Subtract_Valid_Kundoor() + { + Assert.AreEqual(-1, Program.Subtract("1", "2")); + Assert.AreEqual(1, Program.Subtract("3", "2")); + Assert.AreEqual(-2, Program.Subtract("5", "7")); + } + + [TestMethod] + public void Subtract_Invalid_Kundoor() + { + Assert.ThrowsException(() => Program.Subtract("1", "a")); + Assert.ThrowsException(() => Program.Subtract("a", "1")); + Assert.ThrowsException(() => Program.Subtract("a", "a")); + } + + [TestMethod] + public void Subtract_Null_Kundoor() + { + Assert.ThrowsException(() => Program.Subtract("1", null)); + Assert.ThrowsException(() => Program.Subtract(null, "1")); + Assert.ThrowsException(() => Program.Subtract(null, null)); + } +} + +[TestClass] +public class Multiplication +{ + [TestMethod] + public void Multiply_Valid_Kundoor() + { + Assert.AreEqual(2, Program.Multiply("1", "2")); + Assert.AreEqual(6, Program.Multiply("3", "2")); + Assert.AreEqual(35, Program.Multiply("5", "7")); + } + + [TestMethod] + public void Multiply_Invalid_Kundoor() + { + Assert.ThrowsException(() => Program.Multiply("1", "a")); + Assert.ThrowsException(() => Program.Multiply("a", "1")); + Assert.ThrowsException(() => Program.Multiply("a", "a")); + } + + [TestMethod] + public void Multiply_Null_Kundoor() + { + Assert.ThrowsException(() => Program.Multiply("1", null)); + Assert.ThrowsException(() => Program.Multiply(null, "1")); + Assert.ThrowsException(() => Program.Multiply(null, null)); + } +} + +[TestClass] +public class Division +{ + [TestMethod] + public void Divide_Valid_Kundoor() + { + Assert.AreEqual(0.5, Program.Divide("1", "2")); + Assert.AreEqual(1.5, Program.Divide("3", "2")); + Assert.AreEqual(5, Program.Divide("10", "2")); + } + + [TestMethod] + public void Divide_Invalid_Kundoor() + { + Assert.ThrowsException(() => Program.Divide("1", "a")); + Assert.ThrowsException(() => Program.Divide("a", "1")); + Assert.ThrowsException(() => Program.Divide("a", "a")); + } + + [TestMethod] + public void Divide_Null_Kundoor() + { + Assert.ThrowsException(() => Program.Divide("1", null)); + Assert.ThrowsException(() => Program.Divide(null, "1")); + Assert.ThrowsException(() => Program.Divide(null, null)); + } +} + +[TestClass] +public class PowerTests +{ + [TestMethod] + public void Power_Valid_Kundoor() + { + Assert.AreEqual(1, Program.Power("1", "2")); + Assert.AreEqual(8, Program.Power("2", "3")); + Assert.AreEqual(25, Program.Power("5", "2")); + } + + [TestMethod] + public void Power_Invalid_Kundoor() + { + Assert.ThrowsException(() => Program.Power("1", "a")); + Assert.ThrowsException(() => Program.Power("a", "1")); + Assert.ThrowsException(() => Program.Power("a", "a")); + } + + [TestMethod] + public void Power_Null_Kundoor() + { + Assert.ThrowsException(() => Program.Power("1", null)); + Assert.ThrowsException(() => Program.Power(null, "1")); + Assert.ThrowsException(() => Program.Power(null, null)); + } +} \ No newline at end of file