-
Notifications
You must be signed in to change notification settings - Fork 27
feat(dotnet): add JUnit XML output, upgrade to .NET 8, and refactor to Calculator classes #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,6 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class AddCalculator | ||
| { | ||
| public int Add(int a, int b) => a + b; | ||
| } |
This file contains hidden or 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,21 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class AddCalculatorTest | ||
| { | ||
| private readonly AddCalculator _calculator = new(); | ||
|
|
||
| [Test] | ||
| public void TestAdd() | ||
| { | ||
| Assert.That(_calculator.Add(2, 3), Is.EqualTo(5)); | ||
| Assert.That(_calculator.Add(-1, 1), Is.EqualTo(0)); | ||
| Assert.That(_calculator.Add(0, 0), Is.EqualTo(0)); | ||
| } | ||
|
|
||
| // Intentionally failing test to verify failure reporting in test reports | ||
| [Test] | ||
| public void TestAddFailing() | ||
| { | ||
| Assert.That(_calculator.Add(2, 3), Is.EqualTo(999)); | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class Calculator | ||
| { | ||
| private readonly AddCalculator _add = new(); | ||
| private readonly SubtractCalculator _subtract = new(); | ||
| private readonly MultiplyCalculator _multiply = new(); | ||
| private readonly DivideCalculator _divide = new(); | ||
| private readonly PowerCalculator _power = new(); | ||
|
|
||
| public int Add(int a, int b) => _add.Add(a, b); | ||
| public int Subtract(int a, int b) => _subtract.Subtract(a, b); | ||
| public int Multiply(int a, int b) => _multiply.Multiply(a, b); | ||
| public double Divide(double a, double b) => _divide.Divide(a, b); | ||
| public double Power(double base_, double exponent) => _power.Power(base_, exponent); | ||
| } |
This file contains hidden or 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,11 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class DivideCalculator | ||
| { | ||
| public double Divide(double a, double b) | ||
| { | ||
| if (b == 0) | ||
| throw new ArgumentException("Cannot divide by zero"); | ||
| return a / b; | ||
| } | ||
| } |
This file contains hidden or 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,27 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class DivideCalculatorTest | ||
| { | ||
| private readonly DivideCalculator _calculator = new(); | ||
|
|
||
| [Test] | ||
| public void TestDivide() | ||
| { | ||
| Assert.That(_calculator.Divide(10, 2), Is.EqualTo(5.0)); | ||
| Assert.That(_calculator.Divide(9, 3), Is.EqualTo(3.0)); | ||
| Assert.That(_calculator.Divide(-10, 2), Is.EqualTo(-5.0)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void TestDivideByZero() | ||
| { | ||
| Assert.Throws<ArgumentException>(() => _calculator.Divide(10, 0)); | ||
| } | ||
|
|
||
| // Intentionally failing test to verify failure reporting in test reports | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI failed due to this intentional failed test |
||
| [Test] | ||
| public void TestDivideFailing() | ||
| { | ||
| Assert.That(_calculator.Divide(10, 2), Is.EqualTo(99.0)); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,6 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class MultiplyCalculator | ||
| { | ||
| public int Multiply(int a, int b) => a * b; | ||
| } |
This file contains hidden or 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,14 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class MultiplyCalculatorTest | ||
| { | ||
| private readonly MultiplyCalculator _calculator = new(); | ||
|
|
||
| [Test] | ||
| public void TestMultiply() | ||
| { | ||
| Assert.That(_calculator.Multiply(2, 3), Is.EqualTo(6)); | ||
| Assert.That(_calculator.Multiply(-2, 3), Is.EqualTo(-6)); | ||
| Assert.That(_calculator.Multiply(0, 100), Is.EqualTo(0)); | ||
| } | ||
| } |
This file contains hidden or 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,6 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class PowerCalculator | ||
| { | ||
| public double Power(double base_, double exponent) => Math.Pow(base_, exponent); | ||
| } |
This file contains hidden or 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,14 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class PowerCalculatorTest | ||
| { | ||
| private readonly PowerCalculator _calculator = new(); | ||
|
|
||
| [Test] | ||
| public void TestPower() | ||
| { | ||
| Assert.That(_calculator.Power(2, 3), Is.EqualTo(8.0)); | ||
| Assert.That(_calculator.Power(5, 2), Is.EqualTo(25.0)); | ||
| Assert.That(_calculator.Power(10, 0), Is.EqualTo(1.0)); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,6 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class SubtractCalculator | ||
| { | ||
| public int Subtract(int a, int b) => a - b; | ||
| } |
This file contains hidden or 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,14 @@ | ||
| namespace rocket_car_dotnet; | ||
|
|
||
| public class SubtractCalculatorTest | ||
| { | ||
| private readonly SubtractCalculator _calculator = new(); | ||
|
|
||
| [Test] | ||
| public void TestSubtract() | ||
| { | ||
| Assert.That(_calculator.Subtract(5, 3), Is.EqualTo(2)); | ||
| Assert.That(_calculator.Subtract(0, 5), Is.EqualTo(-5)); | ||
| Assert.That(_calculator.Subtract(10, 10), Is.EqualTo(0)); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotnet 7 is already EOL