-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update labeler.yml and add dice rolling endpoint * Update labeler configuration and sync labels * Update labeler configuration, Added permissions to the triage job in PR Labeler workflow, and updated lebeler to v5 * Refactor calculator tests and add dice rolling functionality. -Changed random algorithm, used RandomNumberGenerator class instead of general Random. * Refactor DiceRollingTest and Program.cs according to deepsource scan result.
- Loading branch information
1 parent
eb64c51
commit 61343f4
Showing
7 changed files
with
133 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
ci/cd: | ||
- .github/workflows/* | ||
|
||
# Add 'release' label to any PR that is opened against the `main` branch | ||
# Add 'release' label to any PR that is opened against the `main` branch | ||
release: | ||
- base-branch: [ master, main ] | ||
|
||
# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name | ||
feature: | ||
- head-branch: ['^feature', 'feature'] | ||
- head-branch: ['^feature', 'feature','^Feature', 'Feature', 'feature^', 'Feature^', 'feat', 'Feat', '^feat', 'Feat^'] | ||
|
||
# Add 'Documentation' label to any change to .md files within the entire repository | ||
Documentation: | ||
documentation: | ||
- changed-files: | ||
- any-glob-to-any-file: ['*.md', 'docs/*'] | ||
|
||
# Add 'bug' label to any PR that has the word 'bug' in the title | ||
bug: | ||
- title: ['bug', 'Bug', 'BUG', 'fix', 'Fix', 'FIX'] | ||
|
||
# Add CI/CD label to any PR that has the word 'CI' or 'CD' in the title | ||
ci-cd: | ||
- changed-files: | ||
- any-glob-to-any-file: '**/*.md' | ||
- any-glob-to-any-file: '**/.github/workflows/*' | ||
|
||
# Add 'security' label to any PR that has the word 'security' in the title | ||
security: | ||
- title: ['security', 'Security', 'SECURITY', 'secure', 'Secure', 'SECURE'] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,66 @@ | ||
|
||
namespace WebApiCICDWorkFlow.Tests | ||
namespace WebApiCICDWorkFlow.Tests; | ||
|
||
[TestClass] | ||
public class CalculatorTests | ||
{ | ||
[TestClass] | ||
public class CalculatorTests | ||
[TestMethod] | ||
public void Add_TwoNumbers_ReturnsSum() | ||
{ | ||
[TestMethod] | ||
public void Add_TwoNumbers_ReturnsSum() | ||
{ | ||
// Arrange | ||
var a = 5; | ||
var b = 10; | ||
var expected = 15; | ||
// Arrange | ||
var a = 5; | ||
var b = 10; | ||
var expected = 15; | ||
|
||
// Act | ||
var result = Calculator.Add(a, b); | ||
// Act | ||
var result = Calculator.Add(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(expected, result, "The sum of the two numbers is not correct."); | ||
} | ||
// Assert | ||
Assert.AreEqual(expected, result, "The sum of the two numbers is not correct."); | ||
} | ||
|
||
[TestMethod] | ||
public void Subtract_TwoNumbers_ReturnsDifference() | ||
{ | ||
// Arrange | ||
var a = 10; | ||
var b = 5; | ||
var expected = 5; | ||
[TestMethod] | ||
public void Subtract_TwoNumbers_ReturnsDifference() | ||
{ | ||
// Arrange | ||
var a = 10; | ||
var b = 5; | ||
var expected = 5; | ||
|
||
// Act | ||
var result = Calculator.Subtract(a, b); | ||
// Act | ||
var result = Calculator.Subtract(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(expected, result, "The difference of the two numbers is not correct."); | ||
} | ||
// Assert | ||
Assert.AreEqual(expected, result, "The difference of the two numbers is not correct."); | ||
} | ||
|
||
[TestMethod] | ||
public void Multiply_TwoNumbers_ReturnsProduct() | ||
{ | ||
// Arrange | ||
var a = 5; | ||
var b = 10; | ||
var expected = 50; | ||
[TestMethod] | ||
public void Multiply_TwoNumbers_ReturnsProduct() | ||
{ | ||
// Arrange | ||
var a = 5; | ||
var b = 10; | ||
var expected = 50; | ||
|
||
// Act | ||
var result = Calculator.Multiply(a, b); | ||
// Act | ||
var result = Calculator.Multiply(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(expected, result, "The product of the two numbers is not correct."); | ||
} | ||
// Assert | ||
Assert.AreEqual(expected, result, "The product of the two numbers is not correct."); | ||
} | ||
|
||
[TestMethod] | ||
public void Divide_TwoNumbers_ReturnsQuotient() | ||
{ | ||
// Arrange | ||
var a = 10; | ||
var b = 5; | ||
var expected = 2; | ||
[TestMethod] | ||
public void Divide_TwoNumbers_ReturnsQuotient() | ||
{ | ||
// Arrange | ||
var a = 10; | ||
var b = 5; | ||
var expected = 2; | ||
|
||
// Act | ||
var result = Calculator.Divide(a, b); | ||
// Act | ||
var result = Calculator.Divide(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(expected, result, "The quotient of the two numbers is not correct."); | ||
} | ||
// Assert | ||
Assert.AreEqual(expected, result, "The quotient of the two numbers is not correct."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace WebApiCICDWorkFlow.Tests; | ||
|
||
[TestClass] | ||
public class DiceRollingTest | ||
{ | ||
[TestMethod] | ||
public void TestRollDice() | ||
{ | ||
int result = DiceRolling.RollDice(); | ||
Assert.IsTrue(result >= 1 && result <= 6); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
namespace WebApiCICDWorkFlow | ||
namespace WebApiCICDWorkFlow; | ||
|
||
public class Calculator | ||
{ | ||
public class Calculator | ||
public static float Add(float a, float b) | ||
{ | ||
public static float Add(float a, float b) | ||
{ | ||
return a + b; | ||
} | ||
return a + b; | ||
} | ||
|
||
public static float Subtract(float a, float b) | ||
{ | ||
return a - b; | ||
} | ||
public static float Subtract(float a, float b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
public static float Multiply(float a, float b) | ||
{ | ||
return a * b; | ||
} | ||
public static float Multiply(float a, float b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
public static float Divide(float a, float b) | ||
{ | ||
return a / b; | ||
} | ||
public static float Divide(float a, float b) | ||
{ | ||
return a / b; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Security.Cryptography; | ||
|
||
namespace WebApiCICDWorkFlow; | ||
|
||
public class DiceRolling | ||
{ | ||
// This method will return a random number between 1 and 6 | ||
public static int RollDice() | ||
{ | ||
var randomGenerator = RandomNumberGenerator.Create(); | ||
byte[] randomNumber = new byte[1]; | ||
randomGenerator.GetBytes(randomNumber); | ||
return (randomNumber[0] % 6) + 1; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters