From 006ba46c95714c2c6070e458b9aa76c887f2ceaf Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sat, 23 Sep 2017 17:12:16 +0200 Subject: [PATCH] Tests: work around a weird NUnit issue --- src/UnitTests/DistanceTests.cs | 30 +++++++++++++++--------------- src/UnitTests/UnitTests.csproj | 3 --- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/UnitTests/DistanceTests.cs b/src/UnitTests/DistanceTests.cs index fc3588ac..248d91ef 100644 --- a/src/UnitTests/DistanceTests.cs +++ b/src/UnitTests/DistanceTests.cs @@ -87,9 +87,9 @@ namespace MathNet.Numerics.UnitTests [Test] public void Jaccard() { - Assert.Throws(() => Distance.Jaccard(_dp0, _dq4)); - Assert.Throws(() => Distance.Jaccard(null, _dq4)); - Assert.Throws(() => Distance.Jaccard(_dp0, null)); + Assert.That(() => Distance.Jaccard(_dp0, _dq4), Throws.ArgumentException); + Assert.That(() => Distance.Jaccard(null, _dq4), Throws.ArgumentNullException); + Assert.That(() => Distance.Jaccard(_dp0, null), Throws.ArgumentNullException); Assert.That(Distance.Jaccard(_dp0, _dq0), Is.EqualTo(1)); Assert.That(Distance.Jaccard(_dp1, _dq1), Is.EqualTo(1)); @@ -97,10 +97,10 @@ namespace MathNet.Numerics.UnitTests Assert.That(Distance.Jaccard(_dp3, _dq3), Is.EqualTo(0)); Assert.That(Distance.Jaccard(_dp4, _dq4), Is.EqualTo(0.66666).Within(0.00001)); Assert.That(Distance.Jaccard(_dp5, _dq5), Is.EqualTo(0.9).Within(0.1)); - - Assert.Throws(() => Distance.Jaccard(_fp0, _fq4)); - Assert.Throws(() => Distance.Jaccard(null, _fq4)); - Assert.Throws(() => Distance.Jaccard(_fp0, null)); + + Assert.That(() => Distance.Jaccard(_fp0, _fq4), Throws.ArgumentException); + Assert.That(() => Distance.Jaccard(null, _fq4), Throws.ArgumentNullException); + Assert.That(() => Distance.Jaccard(_fp0, null), Throws.ArgumentNullException); Assert.That(Distance.Jaccard(_fp0, _fq0), Is.EqualTo(1)); Assert.That(Distance.Jaccard(_fp1, _fq1), Is.EqualTo(1)); @@ -113,7 +113,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void Euclidean() { - Assert.Throws(() => Distance.Euclidean(_dp0, _dq4)); + Assert.That(() => Distance.Euclidean(_dp0, _dq4), Throws.ArgumentException); Assert.That(Distance.Euclidean(_dp0, _dq0), Is.EqualTo(.70711).Within(0.00001)); Assert.That(Distance.Euclidean(_dp1, _dq1), Is.EqualTo(1.11803).Within(0.00001)); @@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests Assert.That(Distance.Euclidean(_dp4, _dq4), Is.EqualTo(2.39792).Within(0.00001)); Assert.That(Distance.Euclidean(_dp5, _dq5), Is.EqualTo(4.24264).Within(0.00001)); - Assert.Throws(() => Distance.Euclidean(_fp0, _fq4)); + Assert.That(() => Distance.Euclidean(_fp0, _fq4), Throws.ArgumentException); Assert.That(Distance.Euclidean(_fp0, _fq0), Is.EqualTo(.70711).Within(0.00001)); Assert.That(Distance.Euclidean(_fp1, _fq1), Is.EqualTo(1.11803).Within(0.00001)); @@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void Manhattan() { - Assert.Throws(() => Distance.Manhattan(_dp0, _dq4)); + Assert.That(() => Distance.Manhattan(_dp0, _dq4), Throws.ArgumentException); Assert.That(Distance.Manhattan(_dp0, _dq0), Is.EqualTo(1)); Assert.That(Distance.Manhattan(_dp1, _dq1), Is.EqualTo(1.5)); @@ -143,8 +143,8 @@ namespace MathNet.Numerics.UnitTests Assert.That(Distance.Manhattan(_dp3, _dq3), Is.EqualTo(0)); Assert.That(Distance.Manhattan(_dp4, _dq4), Is.EqualTo(4.5)); Assert.That(Distance.Manhattan(_dp5, _dq5), Is.EqualTo(12)); - - Assert.Throws(() => Distance.Manhattan(_fp0, _fq4)); + + Assert.That(() => Distance.Manhattan(_fp0, _fq4), Throws.ArgumentException); Assert.That(Distance.Manhattan(_fp0, _fq0), Is.EqualTo(1)); Assert.That(Distance.Manhattan(_fp1, _fq1), Is.EqualTo(1.5)); @@ -157,7 +157,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void Cosine() { - Assert.Throws(() => Distance.Cosine(_dp0, _dq4)); + Assert.That(() => Distance.Cosine(_dp0, _dq4), Throws.ArgumentException); Assert.That(Distance.Cosine(_dp0, _dq0), Is.EqualTo(0.2).Within(0.00001)); Assert.That(Distance.Cosine(_dp1, _dq1), Is.EqualTo(0.029857).Within(0.00001)); @@ -165,8 +165,8 @@ namespace MathNet.Numerics.UnitTests Assert.That(Distance.Cosine(_dp3, _dq3), Is.EqualTo(0).Within(0.00001)); Assert.That(Distance.Cosine(_dp4, _dq4), Is.EqualTo(0.039354).Within(0.00001)); Assert.That(Distance.Cosine(_dp5, _dq5), Is.EqualTo(0.031026).Within(0.00001)); - - Assert.Throws(() => Distance.Cosine(_fp0, _fq4)); + + Assert.That(() => Distance.Cosine(_fp0, _fq4), Throws.ArgumentException); Assert.That(Distance.Cosine(_fp0, _fq0), Is.EqualTo(0.2).Within(0.00001)); Assert.That(Distance.Cosine(_fp1, _fq1), Is.EqualTo(0.029857).Within(0.00001)); diff --git a/src/UnitTests/UnitTests.csproj b/src/UnitTests/UnitTests.csproj index bfc7b620..9e790dbb 100644 --- a/src/UnitTests/UnitTests.csproj +++ b/src/UnitTests/UnitTests.csproj @@ -440,9 +440,6 @@ - - -