Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
name: 'Run App <last name>, <first name>'
name: 'Run App Kapaba, Defi'

on: [push, pull_request]

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
6 changes: 5 additions & 1 deletion Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ 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;
if (x == null || y == null)
throw new ArgumentNullException();

return Math.Pow(Convert.ToDouble(x), Convert.ToDouble(y));
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![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 Kapaba, Defi](https://github.com/defimal/GithubActions/actions/workflows/ci.yml/badge.svg)](https://github.com/defimal/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
Expand Down
26 changes: 26 additions & 0 deletions Tests/DivisionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace GithubActionsLab;

[TestClass]
public class Division
{
[TestMethod]
public void Divide_Valid_Kapaba()
{
Assert.AreEqual(2, Program.Divide("4", "2"));
Assert.AreEqual(3, Program.Divide("9", "3"));
}

[TestMethod]
public void Divide_Invalid_Kapaba()
{
Assert.ThrowsException<FormatException>(() => Program.Divide("a", "2"));
Assert.ThrowsException<FormatException>(() => Program.Divide("2", "b"));
}

[TestMethod]
public void Divide_Null_Kapaba()
{
Assert.ThrowsException<ArgumentNullException>(() => Program.Divide(null, "2"));
Assert.ThrowsException<ArgumentNullException>(() => Program.Divide("2", null));
}
}
27 changes: 27 additions & 0 deletions Tests/MultiplicationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace GithubActionsLab;

[TestClass]
public class Multiplication
{
[TestMethod]
public void Multiply_Valid_Kapaba()
{
Assert.AreEqual(6, Program.Multiply("2", "3"));
Assert.AreEqual(0, Program.Multiply("0", "5"));
Assert.AreEqual(-6, Program.Multiply("-2", "3"));
}

[TestMethod]
public void Multiply_Invalid_Kapaba()
{
Assert.ThrowsException<FormatException>(() => Program.Multiply("a", "2"));
Assert.ThrowsException<FormatException>(() => Program.Multiply("2", "b"));
}

[TestMethod]
public void Multiply_Null_Kapaba()
{
Assert.ThrowsException<ArgumentNullException>(() => Program.Multiply(null, "2"));
Assert.ThrowsException<ArgumentNullException>(() => Program.Multiply("2", null));
}
}
27 changes: 27 additions & 0 deletions Tests/PowerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace GithubActionsLab;

[TestClass]
public class PowerTests
{
[TestMethod]
public void Power_Valid_Kapaba()
{
Assert.AreEqual(8, Program.Power("2", "3"));
Assert.AreEqual(1, Program.Power("5", "0"));
Assert.AreEqual(16, Program.Power("4", "2"));
}

[TestMethod]
public void Power_Invalid_Kapaba()
{
Assert.ThrowsException<FormatException>(() => Program.Power("a", "2"));
Assert.ThrowsException<FormatException>(() => Program.Power("2", "b"));
}

[TestMethod]
public void Power_Null_Kapaba()
{
Assert.ThrowsException<ArgumentNullException>(() => Program.Power(null, "2"));
Assert.ThrowsException<ArgumentNullException>(() => Program.Power("2", null));
}
}
27 changes: 27 additions & 0 deletions Tests/SubtractionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace GithubActionsLab;

[TestClass]
public class Subtraction
{
[TestMethod]
public void Subtract_Valid_Kapaba()
{
Assert.AreEqual(1, Program.Subtract("3", "2"));
Assert.AreEqual(0, Program.Subtract("5", "5"));
Assert.AreEqual(-2, Program.Subtract("3", "5"));
}

[TestMethod]
public void Subtract_Invalid_Kapaba()
{
Assert.ThrowsException<FormatException>(() => Program.Subtract("1", "a"));
Assert.ThrowsException<FormatException>(() => Program.Subtract("a", "1"));
}

[TestMethod]
public void Subtract_Null_Kapaba()
{
Assert.ThrowsException<ArgumentNullException>(() => Program.Subtract(null, "1"));
Assert.ThrowsException<ArgumentNullException>(() => Program.Subtract("1", null));
}
}