From 06749b9cbb16a23f2581aea4631a052dcc8e54ea Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Thu, 7 May 2009 19:07:28 +0000 Subject: [PATCH] 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 --- Source/AssertHelper.Test.cs | 46 +++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/Source/AssertHelper.Test.cs b/Source/AssertHelper.Test.cs index 6800050..f38f712 100644 --- a/Source/AssertHelper.Test.cs +++ b/Source/AssertHelper.Test.cs @@ -44,18 +44,22 @@ namespace Nuclex.Support { /// Tests whether the almost equal check detects a floating point value that is /// just barely too low /// - [Test, ExpectedException(typeof(AssertionException))] - public void TestThrowOnAlmostEqualWithTooLowFloat() { - AssertHelper.AreAlmostEqual(exactFloat, minusTwoFloat, 1); + [Test] + public void TestAlmostEqualWithTooLowFloat() { + Assert.Throws( + delegate() { AssertHelper.AreAlmostEqual(exactFloat, minusTwoFloat, 1); } + ); } /// /// Tests whether the almost equal check detects a floating point value that is /// just barely too high /// - [Test, ExpectedException(typeof(AssertionException))] - public void TestThrowOnAlmostEqualWithTooHighFloat() { - AssertHelper.AreAlmostEqual(exactFloat, plusTwoFloat, 1); + [Test] + public void TestAlmostEqualWithTooHighFloat() { + Assert.Throws( + delegate() { AssertHelper.AreAlmostEqual(exactFloat, plusTwoFloat, 1); } + ); } /// @@ -71,18 +75,22 @@ namespace Nuclex.Support { /// Tests whether the almost equal check detects a double precision floating point /// value that is just barely too low /// - [Test, ExpectedException(typeof(AssertionException))] - public void TestThrowOnAlmostEqualWithTooLowDouble() { - AssertHelper.AreAlmostEqual(exactDouble, minusTwoDouble, 1); + [Test] + public void TestAlmostEqualWithTooLowDouble() { + Assert.Throws( + delegate() { AssertHelper.AreAlmostEqual(exactDouble, minusTwoDouble, 1); } + ); } /// /// Tests whether the almost equal check detects a double precision floating point /// value that is just barely too high /// - [Test, ExpectedException(typeof(AssertionException))] - public void TestThrowOnAlmostEqualWithTooHighDouble() { - AssertHelper.AreAlmostEqual(exactDouble, plusTwoDouble, 1); + [Test] + public void TestAlmostEqualWithTooHighDouble() { + Assert.Throws( + delegate() { AssertHelper.AreAlmostEqual(exactDouble, plusTwoDouble, 1); } + ); } /// @@ -112,24 +120,28 @@ namespace Nuclex.Support { /// Verifies that the AreAlmostEqual() helper throws an exception if two arrays /// of different length are compared to each other /// - [Test, ExpectedException(typeof(AssertionException))] - public void TestThrowOnAlmostEqualWithFloatArraysOfDifferentLength() { + [Test] + public void TestAlmostEqualWithFloatArraysOfDifferentLength() { float[] referenceArray = new float[] { exactFloat, exactFloat, exactFloat }; float[] testArray = new float[] { exactFloat, exactFloat }; - AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); + Assert.Throws( + delegate() { AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); } + ); } /// /// Verifies that the AreAlmostEqual() helper throws an exception if the two /// arrays contain elements that deviate by more than the allowed amount /// - [Test, ExpectedException(typeof(AssertionException))] + [Test] public void TestThrowOnAlmostEqualWithBarelyDifferingFloatArrays() { float[] referenceArray = new float[] { exactFloat, exactFloat, exactFloat }; float[] testArray = new float[] { plusOneFloat, minusOneFloat, plusTwoFloat }; - AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); + Assert.Throws( + delegate() { AssertHelper.AreAlmostEqual(referenceArray, testArray, 1); } + ); } ///