Skip to content

Commit 71f3669

Browse files
authored
Merge pull request #293 from SamSmithNZ-dotcom/copilot/add-comments-to-skittle-tests
Add missing Arrange/Act/Assert comments and improve exception specificity in SkittleTests
2 parents 835188c + 29c70e4 commit 71f3669

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/MandMCounter.Core/Calculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private static float GetCubicCmForVolume(string unit, float quantity)
8585
{
8686
if (string.IsNullOrEmpty(unit))
8787
{
88-
unit = "";
88+
throw new ArgumentNullException(nameof(unit), "Unit cannot be null or empty.");
8989
}
9090

9191
switch (unit.ToLower())

src/MandMCounter.Tests/SkittleTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void CountSkittlesInANullUnitTest()
109109
float quantity = 1;
110110

111111
//Act & Assert
112-
Assert.Throws<Exception>(() => Calculator.CountSkittles(unit, quantity));
112+
Assert.Throws<ArgumentNullException>(() => Calculator.CountSkittles(unit, quantity));
113113
}
114114

115115
[TestMethod]
@@ -169,11 +169,15 @@ public void CountSkittlesInA1CubicInchTest()
169169
[TestMethod]
170170
public void CountSkittlesInA1CubicNullUnitTest()
171171
{
172+
//Arrange
172173
string unit = null;
173174
float height = 1;
174175
float width = 1;
175176
float length = 1;
176177

178+
//Act
179+
180+
//Assert
177181
Assert.Throws<Exception>(() => Calculator.CountSkittles(unit, height, width, length));
178182
}
179183

@@ -216,10 +220,12 @@ public void CountSkittlesInACylinderWithInchTest()
216220
[TestMethod]
217221
public void CountSkittlesInACylinderWithNullUnitTest()
218222
{
223+
//Arrange
219224
string unit = null;
220225
float height = 10;
221226
float radius = 5;
222227

228+
//Act & Assert
223229
Assert.Throws<Exception>(() => Calculator.CountSkittles(unit, height, radius));
224230
}
225231

0 commit comments

Comments
 (0)