Skip to content

Commit 4f9f0e6

Browse files
committed
fix to tests
1 parent 8fb1887 commit 4f9f0e6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/MandMCounter.Tests/Controllers/PeanutMandMControllerTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace MandMCounter.Tests.Controllers
88
public class PeanutMandMControllerTests
99
{
1010
private PeanutMandMCounterController _controller;
11-
private const float _tolerance = 0.0001f;
1211

1312
[TestInitialize]
1413
public void Setup()
@@ -22,12 +21,13 @@ public void ControllerCountPeanutMandMsInAmericanCupTest()
2221
//Arrange
2322
string unit = "Cup";
2423
float quantity = 1f;
24+
const float expectedPeanutMandMs = 181f;
2525

2626
//Act
2727
float result = _controller.GetDataForUnit(unit, quantity);
2828

2929
//Assert
30-
Assert.AreEqual(181f, System.Math.Round(result, 0));
30+
Assert.IsLessThan(expectedPeanutMandMs, result);
3131
}
3232

3333
[TestMethod]
@@ -38,12 +38,13 @@ public void ControllerCountPeanutMandMsInA1000CubicCMTest()
3838
float height = 10;
3939
float width = 10;
4040
float length = 10;
41+
const float expectedPeanutMandMs = 764f;
4142

4243
//Act
4344
float result = _controller.GetDataForRectangle(unit, height, width, length);
4445

4546
//Assert
46-
Assert.AreEqual(764, (int)System.Math.Round(result, 0));
47+
Assert.IsLessThan(expectedPeanutMandMs, result);
4748
}
4849

4950
[TestMethod]
@@ -53,12 +54,13 @@ public void ControllerCountPeanutMandMsInACylinderWithCMTest()
5354
string unit = "cm";
5455
float height = 10;
5556
float radius = 5;
57+
const float expectedPeanutMandMs = 600f;
5658

5759
//Act
5860
float result = _controller.GetDataForCylinder(unit, height, radius);
5961

6062
//Assert
61-
Assert.AreEqual(600f, System.Math.Round(result, 0));
63+
Assert.IsLessThan(expectedPeanutMandMs, result);
6264
}
6365

6466
}

src/MandMCounter.Tests/Controllers/SkittleControllerTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace MandMCounter.Tests.Controllers
88
public class SkittleControllerTests
99
{
1010
private SkittleCounterController _controller;
11-
private const float _tolerance = 0.0001f;
1211

1312
[TestInitialize]
1413
public void Setup()
@@ -29,7 +28,7 @@ public void ControllerCountSkittlesInAUSCupTest()
2928
float result = _controller.GetDataForUnit(unit, quantity);
3029

3130
//Assert
32-
Assert.AreEqual(expectedSkittles, System.Math.Round(result, 0), _tolerance);
31+
Assert.IsLessThan(expectedSkittles, result);
3332
}
3433

3534
[TestMethod]
@@ -40,14 +39,14 @@ public void ControllerCountSkittlesInA1CubicCMTest()
4039
float height = 10;
4140
float width = 10;
4241
float length = 10;
42+
const float expectedSkittles = 896f;
4343

4444
//Act
4545
//SkittleCounterController controller = new SkittleCounterController();
4646
float result = _controller.GetDataForRectangle(unit, height, width, length);
4747

4848
//Assert
49-
const float expected = 896f;
50-
Assert.AreEqual(expected, System.Math.Round(result, 0), _tolerance);
49+
Assert.IsLessThan(expectedSkittles, result);
5150
}
5251

5352
[TestMethod]
@@ -57,14 +56,14 @@ public void ControllerCountSkittlesInACylinderWithCMTest()
5756
string unit = "cm";
5857
float height = 10;
5958
float radius = 5;
59+
const float expectedSkittles = 704f;
6060

6161
//Act
6262
//SkittleCounterController controller = new SkittleCounterController();
6363
float result = _controller.GetDataForCylinder(unit, height, radius);
6464

6565
//Assert
66-
const float expected = 704f;
67-
Assert.AreEqual(expected, System.Math.Round(result, 0), _tolerance);
66+
Assert.IsLessThan(expectedSkittles, result);
6867
}
6968

7069
}

0 commit comments

Comments
 (0)