Skip to content

Add missing Arrange/Act/Assert comments and improve exception specificity in SkittleTests#293

Merged
samsmithnz merged 3 commits intomainfrom
copilot/add-comments-to-skittle-tests
Dec 4, 2025
Merged

Add missing Arrange/Act/Assert comments and improve exception specificity in SkittleTests#293
samsmithnz merged 3 commits intomainfrom
copilot/add-comments-to-skittle-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 4, 2025

Applies consistency fixes to test methods in SkittleTests.cs by adding missing AAA pattern comments and improving exception type specificity.

Changes

  • Test comments: Added //Arrange, //Act, and //Assert comments to CountSkittlesInA1CubicNullUnitTest() and CountSkittlesInACylinderWithNullUnitTest() for consistency with other tests in the class

  • Exception specificity: Changed Assert.Throws<Exception> to Assert.Throws<ArgumentNullException> in CountSkittlesInANullUnitTest() and updated Calculator.GetCubicCmForVolume() to throw ArgumentNullException when unit is null/empty:

if (string.IsNullOrEmpty(unit))
{
    throw new ArgumentNullException(nameof(unit), "Unit cannot be null or empty.");
}
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"Missing //Arrange comment for consistency with other test methods in the same class.","fixFiles":[{"filePath":"src/MandMCounter.Tests/SkittleTests.cs","diff":"diff --git a/src/MandMCounter.Tests/SkittleTests.cs b/src/MandMCounter.Tests/SkittleTests.cs\n--- a/src/MandMCounter.Tests/SkittleTests.cs\n+++ b/src/MandMCounter.Tests/SkittleTests.cs\n@@ -169,6 +169,7 @@\n         [TestMethod]\n         public void CountSkittlesInA1CubicNullUnitTest()\n         {\n+            //Arrange\n             string unit = null;\n             float height = 1;\n             float width = 1;\n"}]},{"message":"Missing //Act & Assert comment for consistency with other test methods in the same class.","fixFiles":[{"filePath":"src/MandMCounter.Tests/SkittleTests.cs","diff":"diff --git a/src/MandMCounter.Tests/SkittleTests.cs b/src/MandMCounter.Tests/SkittleTests.cs\n--- a/src/MandMCounter.Tests/SkittleTests.cs\n+++ b/src/MandMCounter.Tests/SkittleTests.cs\n@@ -174,6 +174,9 @@\n             float width = 1;\n             float length = 1;\n \n+            //Act\n+\n+            //Assert\n             Assert.Throws<Exception>(() => Calculator.CountSkittles(unit, height, width, length));\n         }\n \n"}]},{"message":"Missing //Arrange comment for consistency with other test methods in the same class.","fixFiles":[{"filePath":"src/MandMCounter.Tests/SkittleTests.cs","diff":"diff --git a/src/MandMCounter.Tests/SkittleTests.cs b/src/MandMCounter.Tests/SkittleTests.cs\n--- a/src/MandMCounter.Tests/SkittleTests.cs\n+++ b/src/MandMCounter.Tests/SkittleTests.cs\n@@ -216,6 +216,7 @@\n         [TestMethod]\n         public void CountSkittlesInACylinderWithNullUnitTest()\n         {\n+            //Arrange\n             string unit = null;\n             float height = 10;\n             float radius = 5;\n"}]},{"message":"Missing //Act & Assert comment for consistency with other test methods in the same class.","fixFiles":[{"filePath":"src/MandMCounter.Tests/SkittleTests.cs","diff":"diff --git a/src/MandMCounter.Tests/SkittleTests.cs b/src/MandMCounter.Tests/SkittleTests.cs\n--- a/src/MandMCounter.Tests/SkittleTests.cs\n+++ b/src/MandMCounter.Tests/SkittleTests.cs\n@@ -216,10 +216,12 @@\n         [TestMethod]\n         public void CountSkittlesInACylinderWithNullUnitTest()\n         {\n+            //Arrange\n             string unit = null;\n             float height = 10;\n             float radius = 5;\n \n+            //Act & Assert\n             Assert.Throws<Exception>(() => Calculator.CountSkittles(unit, height, radius));\n         }\n \n"}]},{"message":"Using generic Exception type in assertion is too broad. Consider asserting for a more specific exception type like ArgumentNullException or ArgumentException.","fixFiles":[{"filePath":"src/MandMCounter.Tests/SkittleTests.cs","diff":"diff --git a/src/MandMCounter.Tests/SkittleTests.cs b/src/MandMCounter.Tests/SkittleTests.cs\n--- a/src/MandMCounter.Tests/SkittleTests.cs\n+++ b/src/MandMCounter.Tests/SkittleTests.cs\n@@ -109,7 +109,7 @@\n             float quantity = 1;\n \n             //Act & Assert\n-            Assert.Throws<Exception>(() => Calculator.CountSkittles(unit, quantity));\n+            Assert.Throws<ArgumentNullException>(() => Calculator.CountSkittles(unit, quantity));\n         }\n \n         [TestMethod]\n"}]}]

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 4, 2025

Pull Request Test Coverage Report for Build 19936861958

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-10.4%) to 81.992%

Files with Coverage Reduction New Missed Lines %
src/MandMCounter.Core/Calculator.cs 1 80.17%
Totals Coverage Status
Change from base Build 19936563282: -10.4%
Covered Lines: 100
Relevant Lines: 101

💛 - Coveralls

Copilot AI and others added 2 commits December 4, 2025 16:48
…city in SkittleTests

Co-authored-by: samsmithnz <8389039+samsmithnz@users.noreply.github.com>
Co-authored-by: samsmithnz <8389039+samsmithnz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add missing comments for consistency in Skittle tests Add missing Arrange/Act/Assert comments and improve exception specificity in SkittleTests Dec 4, 2025
Copilot AI requested a review from samsmithnz December 4, 2025 16:53
@samsmithnz samsmithnz marked this pull request as ready for review December 4, 2025 16:56
@samsmithnz samsmithnz enabled auto-merge December 4, 2025 16:56
@samsmithnz samsmithnz merged commit 71f3669 into main Dec 4, 2025
6 checks passed
@samsmithnz samsmithnz deleted the copilot/add-comments-to-skittle-tests branch December 4, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants