Converted AssertHelperTest from using the ExpectedExceptionAttribute to Assert.Throws<>() - let's see if this makes TeamCity happy

git-svn-id: file:///srv/devel/repo-conversion/nusu@136 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-05-07 19:07:28 +00:00
parent d845b08a91
commit 06749b9cbb

View File

@ -44,18 +44,22 @@ namespace Nuclex.Support {
/// Tests whether the almost equal check detects a floating point value that is /// Tests whether the almost equal check detects a floating point value that is
/// just barely too low /// just barely too low
/// </summary> /// </summary>
[Test, ExpectedException(typeof(AssertionException))] [Test]
public void TestThrowOnAlmostEqualWithTooLowFloat() { public void TestAlmostEqualWithTooLowFloat() {
AssertHelper.AreAlmostEqual(exactFloat, minusTwoFloat, 1); Assert.Throws<AssertionException>(
delegate() { AssertHelper.AreAlmostEqual(exactFloat, minusTwoFloat, 1); }
);
} }
/// <summary> /// <summary>
/// Tests whether the almost equal check detects a floating point value that is /// Tests whether the almost equal check detects a floating point value that is
/// just barely too high /// just barely too high
/// </summary> /// </summary>
[Test, ExpectedException(typeof(AssertionException))] [Test]
public void TestThrowOnAlmostEqualWithTooHighFloat() { public void TestAlmostEqualWithTooHighFloat() {
AssertHelper.AreAlmostEqual(exactFloat, plusTwoFloat, 1); Assert.Throws<AssertionException>(
delegate() { AssertHelper.AreAlmostEqual(exactFloat, plusTwoFloat, 1); }
);
} }
/// <summary> /// <summary>
@ -71,18 +75,22 @@ namespace Nuclex.Support {
/// Tests whether the almost equal check detects a double precision floating point /// Tests whether the almost equal check detects a double precision floating point
/// value that is just barely too low /// value that is just barely too low
/// </summary> /// </summary>
[Test, ExpectedException(typeof(AssertionException))] [Test]
public void TestThrowOnAlmostEqualWithTooLowDouble() { public void TestAlmostEqualWithTooLowDouble() {
AssertHelper.AreAlmostEqual(exactDouble, minusTwoDouble, 1); Assert.Throws<AssertionException>(
delegate() { AssertHelper.AreAlmostEqual(exactDouble, minusTwoDouble, 1); }
);
} }
/// <summary> /// <summary>
/// Tests whether the almost equal check detects a double precision floating point /// Tests whether the almost equal check detects a double precision floating point
/// value that is just barely too high /// value that is just barely too high
/// </summary> /// </summary>
[Test, ExpectedException(typeof(AssertionException))] [Test]
public void TestThrowOnAlmostEqualWithTooHighDouble() { public void TestAlmostEqualWithTooHighDouble() {
AssertHelper.AreAlmostEqual(exactDouble, plusTwoDouble, 1); Assert.Throws<AssertionException>(
delegate() { AssertHelper.AreAlmostEqual(exactDouble, plusTwoDouble, 1); }
);
} }
/// <summary> /// <summary>
@ -112,24 +120,28 @@ namespace Nuclex.Support {
/// Verifies that the AreAlmostEqual() helper throws an exception if two arrays /// Verifies that the AreAlmostEqual() helper throws an exception if two arrays
/// of different length are compared to each other /// of different length are compared to each other
/// </summary> /// </summary>
[Test, ExpectedException(typeof(AssertionException))] [Test]
public void TestThrowOnAlmostEqualWithFloatArraysOfDifferentLength() { public void TestAlmostEqualWithFloatArraysOfDifferentLength() {
float[] referenceArray = new float[] { exactFloat, exactFloat, exactFloat }; float[] referenceArray = new float[] { exactFloat, exactFloat, exactFloat };
float[] testArray = new float[] { exactFloat, exactFloat }; float[] testArray = new float[] { exactFloat, exactFloat };
AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); Assert.Throws<AssertionException>(
delegate() { AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); }
);
} }
/// <summary> /// <summary>
/// Verifies that the AreAlmostEqual() helper throws an exception if the two /// Verifies that the AreAlmostEqual() helper throws an exception if the two
/// arrays contain elements that deviate by more than the allowed amount /// arrays contain elements that deviate by more than the allowed amount
/// </summary> /// </summary>
[Test, ExpectedException(typeof(AssertionException))] [Test]
public void TestThrowOnAlmostEqualWithBarelyDifferingFloatArrays() { public void TestThrowOnAlmostEqualWithBarelyDifferingFloatArrays() {
float[] referenceArray = new float[] { exactFloat, exactFloat, exactFloat }; float[] referenceArray = new float[] { exactFloat, exactFloat, exactFloat };
float[] testArray = new float[] { plusOneFloat, minusOneFloat, plusTwoFloat }; float[] testArray = new float[] { plusOneFloat, minusOneFloat, plusTwoFloat };
AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); Assert.Throws<AssertionException>(
delegate() { AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); }
);
} }
/// <summary> /// <summary>