Browse Source

Tests: Use Assert.That for exception tests

provider
Christoph Ruegg 13 years ago
parent
commit
b8ccb66a9d
  1. 2
      src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs
  2. 2
      src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs
  3. 20
      src/UnitTests/DistributionTests/Continuous/BetaTests.cs
  4. 6
      src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
  5. 6
      src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
  6. 4
      src/UnitTests/DistributionTests/Continuous/ChiTests.cs
  7. 10
      src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
  8. 8
      src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
  9. 4
      src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
  10. 6
      src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
  11. 12
      src/UnitTests/DistributionTests/Continuous/GammaTests.cs
  12. 6
      src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
  13. 4
      src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
  14. 8
      src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
  15. 12
      src/UnitTests/DistributionTests/Continuous/NormalTests.cs
  16. 6
      src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
  17. 4
      src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
  18. 10
      src/UnitTests/DistributionTests/Continuous/StableTests.cs
  19. 6
      src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
  20. 10
      src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
  21. 10
      src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
  22. 4
      src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs
  23. 6
      src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
  24. 4
      src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs
  25. 10
      src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs
  26. 6
      src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs
  27. 6
      src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
  28. 2
      src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs
  29. 4
      src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs
  30. 8
      src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs
  31. 4
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs
  32. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs
  33. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs
  34. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs
  35. 4
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs
  36. 4
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs
  37. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs
  38. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs
  39. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs
  40. 4
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs
  41. 40
      src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs
  42. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs
  43. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs
  44. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs
  45. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs
  46. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs
  47. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs
  48. 8
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs
  49. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/FailureStopCriteriumTest.cs
  50. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs
  51. 20
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs
  52. 2
      src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs
  53. 4
      src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs
  54. 26
      src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs
  55. 20
      src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs
  56. 2
      src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs
  57. 4
      src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs
  58. 8
      src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs
  59. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs
  60. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs
  61. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs
  62. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs
  63. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs
  64. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs
  65. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs
  66. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs
  67. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs
  68. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs
  69. 40
      src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs
  70. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs
  71. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs
  72. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs
  73. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs
  74. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs
  75. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs
  76. 8
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs
  77. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/FailureStopCriteriumTest.cs
  78. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs
  79. 20
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs
  80. 2
      src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs
  81. 4
      src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs
  82. 26
      src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs
  83. 20
      src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs
  84. 2
      src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs
  85. 4
      src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs
  86. 8
      src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs
  87. 4
      src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs
  88. 2
      src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs
  89. 2
      src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs
  90. 2
      src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs
  91. 4
      src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs
  92. 4
      src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs
  93. 2
      src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs
  94. 2
      src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs
  95. 2
      src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs
  96. 4
      src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs
  97. 40
      src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs
  98. 4
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs
  99. 4
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs
  100. 4
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs

2
src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs

@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests
[Test]
public void IfMissingClosingParenParseThrowsFormatException()
{
Assert.Throws<FormatException>(() => Complex32.Parse("(1,2"));
Assert.That(() => Complex32.Parse("(1,2"), Throws.TypeOf<FormatException>());
}
/// <summary>

2
src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs

@ -108,7 +108,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests
[Test]
public void IfMissingClosingParenParseThrowsFormatException()
{
Assert.Throws<FormatException>(() => "(1,2".ToComplex());
Assert.That(() => "(1,2".ToComplex(), Throws.TypeOf<FormatException>());
}
/// <summary>

20
src/UnitTests/DistributionTests/Continuous/BetaTests.cs

@ -71,12 +71,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void BetaCreateFailsWithBadParameters()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Beta(Double.NaN, 1.0));
Assert.Throws<ArgumentOutOfRangeException>(() => new Beta(1.0, Double.NaN));
Assert.Throws<ArgumentOutOfRangeException>(() => new Beta(Double.NaN, Double.NaN));
Assert.Throws<ArgumentOutOfRangeException>(() => new Beta(1.0, -1.0));
Assert.Throws<ArgumentOutOfRangeException>(() => new Beta(-1.0, 1.0));
Assert.Throws<ArgumentOutOfRangeException>(() => new Beta(-1.0, -1.0));
Assert.That(() => new Beta(Double.NaN, 1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(1.0, Double.NaN), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(Double.NaN, Double.NaN), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(-1.0, 1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(-1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeAFailsWithNegativeA()
{
var n = new Beta(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.A = -1.0);
Assert.That(() => n.A = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -142,7 +142,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeBFailsWithNegativeB()
{
var n = new Beta(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.B = -1.0);
Assert.That(() => n.B = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -288,7 +288,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Beta.Sample(new Random(0), 1.0, -1.0));
Assert.That(() => Beta.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -297,7 +297,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Beta.Samples(new Random(0), 1.0, -1.0).First());
Assert.That(() => Beta.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Continuous/CauchyTests.cs

@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void CauchyCreateFailsWithBadParameters(double location, double scale)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Cauchy(location, scale));
Assert.That(() => new Cauchy(location, scale), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -118,7 +118,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadLocationFail()
{
var n = new Cauchy();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Location = Double.NaN);
Assert.That(() => n.Location = Double.NaN, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadScaleFail()
{
var n = new Cauchy();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = -1.0);
Assert.That(() => n.Scale = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.NaN)]
public void ChiSquareCreateFailsWithBadParameters(double dof)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new ChiSquared(dof));
Assert.That(() => new ChiSquared(dof), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new ChiSquared(1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom = dof);
Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -293,7 +293,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => ChiSquared.Sample(new Random(0), -1.0));
Assert.That(() => ChiSquared.Sample(new Random(0), -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/DistributionTests/Continuous/ChiTests.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.NaN)]
public void ChiCreateFailsWithBadParameters(double dof)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Chi(dof));
Assert.That(() => new Chi(dof), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new Chi(1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom = dof);
Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

10
src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs

@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void ContinuousUniformCreateFailsWithBadParameters(double lower, double upper)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new ContinuousUniform(lower, upper));
Assert.That(() => new ContinuousUniform(lower, upper), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadLowerFails()
{
var n = new ContinuousUniform();
Assert.Throws<ArgumentOutOfRangeException>(() => n.LowerBound = 3.0);
Assert.That(() => n.LowerBound = 3.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -146,7 +146,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadUpperFails()
{
var n = new ContinuousUniform();
Assert.Throws<ArgumentOutOfRangeException>(() => n.UpperBound = -1.0);
Assert.That(() => n.UpperBound = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -336,7 +336,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0));
Assert.That(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -345,7 +345,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First());
Assert.That(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First(), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

8
src/UnitTests/DistributionTests/Continuous/ErlangTests.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-1, Double.NaN)]
public void ErlangCreateFailsWithBadParameters(int shape, double invScale)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Erlang(shape, invScale));
Assert.That(() => new Erlang(shape, invScale), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape()
{
var n = new Erlang(1, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Shape = -1);
Assert.That(() => n.Shape = -1, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -171,7 +171,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale()
{
var n = new Erlang(1, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = -1.0);
Assert.That(() => n.Scale = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -199,7 +199,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetInvScaleFailsWithNegativeInvScale()
{
var n = new Erlang(1, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Rate = -1.0);
Assert.That(() => n.Rate = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-10.0)]
public void ExponentialCreateFailsWithBadParameters(double lambda)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Exponential(lambda));
Assert.That(() => new Exponential(lambda), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -103,7 +103,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetLambdaFailsWithNegativeLambda()
{
var n = new Exponential(1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Rate = -1.0);
Assert.That(() => n.Rate = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs

@ -88,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-10.0, -10.0)]
public void FisherSnedecorCreateFailsWithBadParameters(double d1, double d2)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new FisherSnedecor(d1, d2));
Assert.That(() => new FisherSnedecor(d1, d2), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDegreesOfFreedom1FailsWithNegativeDegreeOfFreedom()
{
var n = new FisherSnedecor(1.0, 2.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom1 = -1.0);
Assert.That(() => n.DegreesOfFreedom1 = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -150,7 +150,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDegreesOfFreedom2FailsWithNegativeDegreeOfFreedom()
{
var n = new FisherSnedecor(1.0, 2.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom2 = -1.0);
Assert.That(() => n.DegreesOfFreedom2 = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

12
src/UnitTests/DistributionTests/Continuous/GammaTests.cs

@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-1.0, Double.NaN)]
public void GammaCreateFailsWithBadParameters(double shape, double invScale)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Gamma(shape, invScale));
Assert.That(() => new Gamma(shape, invScale), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -147,7 +147,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape()
{
var n = new Gamma(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Shape = -1.0);
Assert.That(() => n.Shape = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -175,7 +175,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale()
{
var n = new Gamma(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = -1.0);
Assert.That(() => n.Scale = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -203,7 +203,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetInvScaleFailsWithNegativeInvScale()
{
var n = new Gamma(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Rate = -1.0);
Assert.That(() => n.Rate = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -433,7 +433,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Normal.Sample(new Random(0), 1.0, -1.0));
Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -442,7 +442,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Normal.Samples(new Random(0), 1.0, -1.0).First());
Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs

@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, Double.NaN)]
public void InverseGammaCreateFailsWithBadParameters(double a, double b)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new InverseGamma(a, b));
Assert.That(() => new InverseGamma(a, b), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -112,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetAFailsWithNonPositiveA(double a)
{
var n = new InverseGamma(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Shape = a);
Assert.That(() => n.Shape = a, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -141,7 +141,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBFailsWithNonPositiveB(double b)
{
var n = new InverseGamma(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = b);
Assert.That(() => n.Scale = b, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs

@ -105,7 +105,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetLocationFailsWithNegativeLocation()
{
var n = new Laplace();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Location = Double.NaN);
Assert.That(() => n.Location = Double.NaN, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -136,7 +136,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale(double scale)
{
var n = new Laplace();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale);
Assert.That(() => n.Scale = scale, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

8
src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs

@ -72,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, -1.0)]
public void LogNormalCreateFailsWithBadParameters(double mu, double sigma)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new LogNormal(mu, sigma));
Assert.That(() => new LogNormal(mu, sigma), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -110,7 +110,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetSigmaFailsWithNegativeSigma()
{
var n = new LogNormal(1.0, 2.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Sigma = -1.0);
Assert.That(() => n.Sigma = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -443,7 +443,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => { var d = LogNormal.Sample(new Random(0), 0.0, -1.0); });
Assert.That(() => { var d = LogNormal.Sample(new Random(0), 0.0, -1.0); }, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -452,7 +452,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => { var ied = LogNormal.Samples(new Random(0), 0.0, -1.0).First(); });
Assert.That(() => { var ied = LogNormal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

12
src/UnitTests/DistributionTests/Continuous/NormalTests.cs

@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, -1.0)]
public void NormalCreateFailsWithBadParameters(double mean, double sdev)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Normal(mean, sdev));
Assert.That(() => new Normal(mean, sdev), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -175,7 +175,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetPrecisionFailsWithNegativePrecision()
{
var n = new Normal();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Precision = -1.0);
Assert.That(() => n.Precision = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetVarianceFailsWithNegativeVariance()
{
var n = new Normal();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Variance = -1.0);
Assert.That(() => n.Variance = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -235,7 +235,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetStdDevFailsWithNegativeStdDev()
{
var n = new Normal();
Assert.Throws<ArgumentOutOfRangeException>(() => n.StdDev = -1.0);
Assert.That(() => n.StdDev = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -416,7 +416,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => { var d = Normal.Sample(new Random(0), 0.0, -1.0); });
Assert.That(() => { var d = Normal.Sample(new Random(0), 0.0, -1.0); }, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -425,7 +425,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => { var ied = Normal.Samples(new Random(0), 0.0, -1.0).First(); });
Assert.That(() => { var ied = Normal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Continuous/ParetoTests.cs

@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void ParetoCreateFailsWithBadParameters(double scale, double shape)
{
Assert.Throws<ArgumentOutOfRangeException>(() => { var n = new Pareto(scale, shape); });
Assert.That(() => { var n = new Pareto(scale, shape); }, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -109,7 +109,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale()
{
var n = new Pareto(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = -1.0);
Assert.That(() => n.Scale = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape()
{
var n = new Pareto(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Shape = -1.0);
Assert.That(() => n.Shape = -1.0, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/DistributionTests/Continuous/RayleighTests.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(0.0)]
public void RayleighCreateFailsWithBadParameters(double scale)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Rayleigh(scale));
Assert.That(() => new Rayleigh(scale), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale(double scale)
{
var n = new Rayleigh(1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale);
Assert.That(() => n.Scale = scale, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

10
src/UnitTests/DistributionTests/Continuous/StableTests.cs

@ -89,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(2.1, 1.0, 1.0, 1.0)]
public void StableCreateFailsWithBadParameters(double alpha, double beta, double location, double scale)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Stable(alpha, beta, location, scale));
Assert.That(() => new Stable(alpha, beta, location, scale), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -130,7 +130,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetAlphaFail(double alpha)
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Alpha = alpha);
Assert.That(() => n.Alpha = alpha, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -163,7 +163,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBetaFail(double beta)
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Beta = beta);
Assert.That(() => n.Beta = beta, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -191,7 +191,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFail(double scale)
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale);
Assert.That(() => n.Scale = scale, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -221,7 +221,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetLocationFail()
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Location = Double.NaN);
Assert.That(() => n.Location = Double.NaN, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Continuous/StudentTTests.cs

@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(0.0, 10.0, -1.0)]
public void StudentTCreateFailsWithBadParameters(double location, double scale, double dof)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new StudentT(location, scale, dof));
Assert.That(() => new StudentT(location, scale, dof), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -144,7 +144,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNonPositiveScale(double scale)
{
var n = new StudentT();
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale);
Assert.That(() => n.Scale = scale, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -173,7 +173,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new StudentT();
Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom = dof);
Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

10
src/UnitTests/DistributionTests/Continuous/WeibullTests.cs

@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void WeibullCreateFailsWithBadParameters(double shape, double scale)
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Weibull(shape, scale));
Assert.That(() => new Weibull(shape, scale), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape(double shape)
{
var n = new Weibull(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Shape = shape);
Assert.That(() => n.Shape = shape, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale(double scale)
{
var n = new Weibull(1.0, 1.0);
Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale);
Assert.That(() => n.Scale = scale, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -337,7 +337,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Normal.Sample(new Random(0), 1.0, -1.0));
Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -346,7 +346,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Normal.Samples(new Random(0), 1.0, -1.0).First());
Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

10
src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs

@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void CategoricalCreateFailsWithNullHistogram()
{
Histogram h = null;
Assert.Throws<ArgumentNullException>(() => new Categorical(h));
Assert.That(() => new Categorical(h), Throws.TypeOf<ArgumentNullException>());
}
/// <summary>
@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void CategoricalCreateFailsWithNegativeRatios()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Categorical(_badP));
Assert.That(() => new Categorical(_badP), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void CategoricalCreateFailsWithAllZeroRatios()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Categorical(_badP2));
Assert.That(() => new Categorical(_badP2), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -156,7 +156,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityFails()
{
var b = new Categorical(_largeP);
Assert.Throws<ArgumentOutOfRangeException>(() => b.P = _badP);
Assert.That(() => b.P = _badP, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP));
Assert.That(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs

@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailCreateDirichlet()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Dirichlet(0.0, 5));
Assert.Throws<ArgumentOutOfRangeException>(() => new Dirichlet(-0.1, 5));
Assert.That(() => new Dirichlet(0.0, 5), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Dirichlet(-0.1, 5), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs

@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
matrix[0, 0] = 0.0;
Assert.Throws<ArgumentOutOfRangeException>(() => new InverseWishart(nu, matrix));
Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -96,7 +96,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void FailNuCreateInverseWishart(double nu, int order)
{
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
Assert.Throws<ArgumentOutOfRangeException>(() => new InverseWishart(nu, matrix));
Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -312,7 +312,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix<double>.Build.RandomPositiveDefinite(2, 1)));
Assert.That(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix<double>.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
}

4
src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs

@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrixV = Matrix<double>.Build.Random(rowsOfV, columnsOfV, 1);
var matrixK = Matrix<double>.Build.Random(rowsOfK, columnsOfK, 1);
Assert.Throws<ArgumentOutOfRangeException>(() => new MatrixNormal(matrixM, matrixV, matrixK));
Assert.That(() => new MatrixNormal(matrixM, matrixV, matrixK), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -343,7 +343,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[TestCase(5, 2, 5, 5, 2, 3)]
public void FailSampleStatic(int rowsOfM, int columnsOfM, int rowsOfV, int columnsOfV, int rowsOfK, int columnsOfK)
{
Assert.Throws<ArgumentOutOfRangeException>(() => MatrixNormal.Sample(new System.Random(0), Matrix<double>.Build.Random(rowsOfM, columnsOfM, 1), Matrix<double>.Build.Random(rowsOfV, columnsOfV, 1), Matrix<double>.Build.Random(rowsOfK, columnsOfK, 1)));
Assert.That(() => MatrixNormal.Sample(new System.Random(0), Matrix<double>.Build.Random(rowsOfM, columnsOfM, 1), Matrix<double>.Build.Random(rowsOfV, columnsOfV, 1), Matrix<double>.Build.Random(rowsOfK, columnsOfK, 1)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
}

10
src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs

@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void MultinomialCreateFailsWithNullHistogram()
{
Histogram h = null;
Assert.Throws<ArgumentNullException>(() => new Categorical(h));
Assert.That(() => new Categorical(h), Throws.TypeOf<ArgumentNullException>());
}
/// <summary>
@ -113,7 +113,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void MultinomialCreateFailsWithNegativeRatios()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Multinomial(_badP, 4));
Assert.That(() => new Multinomial(_badP, 4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void MultinomialCreateFailsWithAllZeroRatios()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new Multinomial(_badP2, 4));
Assert.That(() => new Multinomial(_badP2, 4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void SetProbabilityFails()
{
var b = new Multinomial(_largeP, 4);
Assert.Throws<ArgumentOutOfRangeException>(() => b.P = _badP);
Assert.That(() => b.P = _badP, Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -254,7 +254,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Multinomial.Sample(new Random(0), _badP, 4));
Assert.That(() => Multinomial.Sample(new Random(0), _badP, 4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs

@ -77,9 +77,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void NormalGammaConstructorFailsWithInvalidParams()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new NormalGamma(1.0, -1.3, 2.0, 2.0));
Assert.Throws<ArgumentOutOfRangeException>(() => new NormalGamma(1.0, 1.0, -1.0, 1.0));
Assert.Throws<ArgumentOutOfRangeException>(() => new NormalGamma(1.0, 1.0, 1.0, -1.0));
Assert.That(() => new NormalGamma(1.0, -1.3, 2.0, 2.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new NormalGamma(1.0, 1.0, -1.0, 1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new NormalGamma(1.0, 1.0, 1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

6
src/UnitTests/DistributionTests/Multivariate/WishartTests.cs

@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
matrix[0, 0] = 0.0;
Assert.Throws<ArgumentOutOfRangeException>(() => new Wishart(nu, matrix));
Assert.That(() => new Wishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -98,7 +98,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void FailNuCreateWishart(double nu, int order)
{
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
Assert.Throws<ArgumentOutOfRangeException>(() => new InverseWishart(nu, matrix));
Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -304,7 +304,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailSampleStatic()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Wishart.Sample(new System.Random(0), -1.0, Matrix<double>.Build.RandomPositiveDefinite(2, 1)));
Assert.That(() => Wishart.Sample(new System.Random(0), -1.0, Matrix<double>.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
}

2
src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs

@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => DenseMatrix.CreateIdentity(order));
Assert.That(() => DenseMatrix.CreateIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
}

4
src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs

@ -89,8 +89,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void ParseIfMissingClosingParenThrowsFormatException()
{
Assert.Throws<FormatException>(() => DenseVector.Parse("(1"));
Assert.Throws<FormatException>(() => DenseVector.Parse("[1"));
Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf<FormatException>());
Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf<FormatException>());
}
/// <summary>

8
src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs

@ -185,7 +185,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => DiagonalMatrix.CreateIdentity(order));
Assert.That(() => DiagonalMatrix.CreateIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -220,7 +220,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
var permutation = new Permutation(new[] {2, 0, 1});
Assert.Throws<InvalidOperationException>(() => matrixp.PermuteRows(permutation));
Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException);
}
/// <summary>
@ -231,7 +231,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
var permutation = new Permutation(new[] {2, 0, 1});
Assert.Throws<InvalidOperationException>(() => matrixp.PermuteColumns(permutation));
Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException);
}
/// <summary>
@ -352,7 +352,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void DeterminantNotSquareMatrixThrowsArgumentException()
{
var matrix = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentException>(() => matrix.Determinant());
Assert.That(() => matrix.Determinant(), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs

@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
{
var matrixI = DenseMatrix.CreateIdentity(8);
matrixI[3, 3] = -4.0;
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>
@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
public void CholeskyFailsWithNonSquareMatrix()
{
var matrix = new DenseMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrix.Cholesky());
Assert.That(() => matrix.Cholesky(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs

@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)));
Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs

@ -87,7 +87,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
public void LUFailsWithNonSquareMatrix()
{
var matrix = new DenseMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrix.LU());
Assert.That(() => matrix.LU(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs

@ -51,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserQR.Create(new DenseMatrix(3, 4)));
Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs

@ -196,7 +196,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
var factorSvd = matrixA.Svd(false);
var matrixB = Matrix<Complex>.Build.Random(10, 9, 1);
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(matrixB));
Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException);
}
/// <summary>
@ -209,7 +209,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
var factorSvd = matrixA.Svd(false);
var vectorb = Vector<Complex>.Build.Random(9, 1);
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(vectorb));
Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs

@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
{
var matrixI = UserDefinedMatrix.Identity(8);
matrixI[3, 3] = -4.0;
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>
@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
public void CholeskyFailsWithNonSquareMatrix()
{
var matrixI = new UserDefinedMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs

@ -49,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)));
Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs

@ -86,7 +86,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
public void LUFailsWithNonSquareMatrix()
{
var matrix = new UserDefinedMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrix.LU());
Assert.That(() => matrix.LU(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs

@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserQR.Create(new UserDefinedMatrix(3, 4)));
Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs

@ -195,7 +195,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
var factorSvd = matrixA.Svd(false);
var matrixB = new UserDefinedMatrix(Matrix<Complex>.Build.Random(10, 9, 1).ToArray());
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(matrixB));
Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException);
}
/// <summary>
@ -208,7 +208,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
var factorSvd = matrixA.Svd(false);
var vectorb = new UserDefinedVector(Vector<Complex>.Build.Random(9, 1).ToArray());
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(vectorb));
Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException);
}
/// <summary>

40
src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs

@ -136,7 +136,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1) });
Vector<Complex> y = new DenseVector(4);
Assert.Throws<ArgumentException>(() => matrix.Multiply(x, y));
Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException);
}
/// <summary>
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3, result));
Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException);
}
/// <summary>
@ -225,7 +225,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1);
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3, result));
Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException);
}
/// <summary>
@ -259,7 +259,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Add(other));
Assert.That(() => matrix.Add(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -270,7 +270,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Add(other));
Assert.That(() => matrix.Add(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -348,7 +348,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Subtract(other));
Assert.That(() => matrix.Subtract(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -359,7 +359,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Subtract(other));
Assert.That(() => matrix.Subtract(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -502,7 +502,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException);
}
/// <summary>
@ -642,7 +642,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1) });
Vector<Complex> y = new DenseVector(4);
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(x, y));
Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException);
}
/// <summary>
@ -679,7 +679,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Wide2x3"];
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException);
}
/// <summary>
@ -767,7 +767,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Negate(target));
Assert.That(() => matrix.Negate(target), Throws.ArgumentException);
}
/// <summary>
@ -778,7 +778,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = TestMatrices["Singular3x3"];
var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Negate(target));
Assert.That(() => matrix.Negate(target), Throws.ArgumentException);
}
/// <summary>
@ -853,7 +853,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => TestMatrices["Square4x4"].NormalizeColumns(-4));
Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -878,7 +878,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => TestMatrices["Square4x4"].NormalizeRows(-4));
Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -924,7 +924,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var matrix = TestMatrices["Wide2x3"];
var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
var result = matrix.Clone();
Assert.Throws<ArgumentException>(() => matrix.PointwiseMultiply(other, result));
Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException);
}
/// <summary>
@ -936,7 +936,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.PointwiseMultiply(other, result));
Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException);
}
/// <summary>
@ -976,7 +976,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var matrix = TestMatrices["Wide2x3"];
var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
var result = matrix.Clone();
Assert.Throws<ArgumentException>(() => matrix.PointwiseDivide(other, result));
Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException);
}
/// <summary>
@ -988,7 +988,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.PointwiseDivide(other, result));
Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException);
}
/// <summary>
@ -999,7 +999,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[TestCase(-2)]
public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows)
{
Assert.Throws<ArgumentOutOfRangeException>(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()));
Assert.That(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -1020,7 +1020,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void TraceOfNonSquareMatrixThrowsArgumentException()
{
var matrix = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentException>(() => matrix.Trace());
Assert.That(() => matrix.Trace(), Throws.ArgumentException);
}
}
}

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs

@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs

@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs

@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs

@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs

@ -77,11 +77,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers
};
var iterator = new Iterator<Complex>(criteria);
Assert.Throws<ArgumentOutOfRangeException>(() => iterator.DetermineStatus(
Assert.That(() => iterator.DetermineStatus(
-1,
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(3, 5),
Vector<Complex>.Build.Dense(3, 6)));
Vector<Complex>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs

@ -133,7 +133,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
preconditioner.Initialize(newMatrix);
var result = new DenseVector(vector.Count + 10);
Assert.Throws<ArgumentException>(() => preconditioner.Approximate(vector, result));
Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException);
}
/// <summary>
@ -146,7 +146,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
var vector = CreateStandardBcVector(Size);
var preconditioner = CreatePreconditioner();
var result = new DenseVector(vector.Count);
Assert.Throws<ArgumentException>(() => preconditioner.Approximate(vector, result));
Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException);
}
}
}

8
src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs

@ -54,7 +54,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
[Test]
public void CreateWithNegativeMaximumIncreaseThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new DivergenceStopCriterium<Complex>(-0.1));
Assert.That(() => new DivergenceStopCriterium<Complex>(-0.1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
[Test]
public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new DivergenceStopCriterium<Complex>(minimumIterations: 2));
Assert.That(() => new DivergenceStopCriterium<Complex>(minimumIterations: 2), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -86,11 +86,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
{
var criterium = new DivergenceStopCriterium<Complex>(0.5, 15);
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
-1,
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(3, 5),
Vector<Complex>.Build.Dense(3, 6)));
Vector<Complex>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/FailureStopCriteriumTest.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
var criterium = new FailureStopCriterium<Complex>();
Assert.IsNotNull(criterium, "There should be a criterium");
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(-1, Vector<Complex>.Build.Dense(3, 4), Vector<Complex>.Build.Dense(3, 5), Vector<Complex>.Build.Dense(3, 6)));
Assert.That(() => criterium.DetermineStatus(-1, Vector<Complex>.Build.Dense(3, 4), Vector<Complex>.Build.Dense(3, 5), Vector<Complex>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
var criterium = new FailureStopCriterium<Complex>();
Assert.IsNotNull(criterium, "There should be a criterium");
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(1, Vector<Complex>.Build.Dense(3, 4), Vector<Complex>.Build.Dense(3, 6), Vector<Complex>.Build.Dense(4, 4)));
Assert.That(() => criterium.DetermineStatus(1, Vector<Complex>.Build.Dense(3, 4), Vector<Complex>.Build.Dense(3, 6), Vector<Complex>.Build.Dense(4, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs

@ -53,7 +53,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
[Test]
public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new IterationCountStopCriterium<Complex>(-1));
Assert.That(() => new IterationCountStopCriterium<Complex>(-1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -90,7 +90,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
var criterium = new IterationCountStopCriterium<Complex>(10);
Assert.IsNotNull(criterium, "A criterium should have been created");
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(-1, Vector<Complex>.Build.Dense(3, 1), Vector<Complex>.Build.Dense(3, 2), Vector<Complex>.Build.Dense(3, 3)));
Assert.That(() => criterium.DetermineStatus(-1, Vector<Complex>.Build.Dense(3, 1), Vector<Complex>.Build.Dense(3, 2), Vector<Complex>.Build.Dense(3, 3)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

20
src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs

@ -54,7 +54,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
[Test]
public void CreateWithNegativeMaximumThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new ResidualStopCriterium<Complex>(-0.1));
Assert.That(() => new ResidualStopCriterium<Complex>(-0.1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
[Test]
public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new ResidualStopCriterium<Complex>(-1));
Assert.That(() => new ResidualStopCriterium<Complex>(-1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -86,11 +86,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
{
var criterium = new ResidualStopCriterium<Complex>(1e-8, 50);
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
-1,
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(3, 5),
Vector<Complex>.Build.Dense(3, 6)));
Vector<Complex>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -101,11 +101,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
{
var criterium = new ResidualStopCriterium<Complex>(1e-8, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
1,
Vector<Complex>.Build.Dense(4, 4),
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(3, 4)));
Vector<Complex>.Build.Dense(3, 4)), Throws.ArgumentException);
}
/// <summary>
@ -116,11 +116,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
{
var criterium = new ResidualStopCriterium<Complex>(1e-8, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
1,
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(4, 4),
Vector<Complex>.Build.Dense(3, 4)));
Vector<Complex>.Build.Dense(3, 4)), Throws.ArgumentException);
}
/// <summary>
@ -131,11 +131,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit
{
var criterium = new ResidualStopCriterium<Complex>(1e-8, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
1,
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(3, 4),
Vector<Complex>.Build.Dense(4, 4)));
Vector<Complex>.Build.Dense(4, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs

@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => SparseMatrix.CreateIdentity(order));
Assert.That(() => SparseMatrix.CreateIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs

@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void ParseIfMissingClosingParenThrowsFormatException()
{
Assert.Throws<FormatException>(() => SparseVector.Parse("(1"));
Assert.Throws<FormatException>(() => SparseVector.Parse("[1"));
Assert.That(() => SparseVector.Parse("(1"), Throws.TypeOf<FormatException>());
Assert.That(() => SparseVector.Parse("[1"), Throws.TypeOf<FormatException>());
}
/// <summary>

26
src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs

@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Add(0.0, result));
Assert.That(() => vector.Add(0.0, result), Throws.ArgumentException);
}
/// <summary>
@ -112,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Add(other));
Assert.That(() => vector.Add(other), Throws.ArgumentException);
}
/// <summary>
@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Add(other, result));
Assert.That(() => vector.Add(other, result), Throws.ArgumentException);
}
/// <summary>
@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var a = CreateVector(Data.Length);
var b = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => a += b);
Assert.That(() => a += b, Throws.ArgumentException);
}
/// <summary>
@ -321,7 +321,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Subtract(0.0, result));
Assert.That(() => vector.Subtract(0.0, result), Throws.ArgumentException);
}
/// <summary>
@ -332,7 +332,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Subtract(other));
Assert.That(() => vector.Subtract(other), Throws.ArgumentException);
}
/// <summary>
@ -344,7 +344,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Subtract(other, result));
Assert.That(() => vector.Subtract(other, result), Throws.ArgumentException);
}
/// <summary>
@ -355,7 +355,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var a = CreateVector(Data.Length);
var b = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => a -= b);
Assert.That(() => a -= b, Throws.ArgumentException);
}
/// <summary>
@ -556,7 +556,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Multiply(0.0, result));
Assert.That(() => vector.Multiply(0.0, result), Throws.ArgumentException);
}
/// <summary>
@ -567,7 +567,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Divide(0.0, result));
Assert.That(() => vector.Divide(0.0, result), Throws.ArgumentException);
}
/// <summary>
@ -647,7 +647,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var dataA = CreateVector(Data);
var dataB = CreateVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1), new Complex(4, 1), new Complex(5, 1), new Complex(6, 1) });
Assert.Throws<ArgumentException>(() => dataA.DotProduct(dataB));
Assert.That(() => dataA.DotProduct(dataB), Throws.ArgumentException);
}
/// <summary>
@ -714,7 +714,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
var result = CreateVector(vector1.Count + 1);
Assert.Throws<ArgumentException>(() => vector1.PointwiseMultiply(vector2, result));
Assert.That(() => vector1.PointwiseMultiply(vector2, result), Throws.ArgumentException);
}
/// <summary>
@ -757,7 +757,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
var result = CreateVector(vector1.Count + 1);
Assert.Throws<ArgumentException>(() => vector1.PointwiseDivide(vector2, result));
Assert.That(() => vector1.PointwiseDivide(vector2, result), Throws.ArgumentException);
}
/// <summary>

20
src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs

@ -215,8 +215,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void SizeIsNotPositiveThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => CreateVector(-1));
Assert.Throws<ArgumentOutOfRangeException>(() => CreateVector(0));
Assert.That(() => CreateVector(-1), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => CreateVector(0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -356,7 +356,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length)
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentOutOfRangeException>(() => vector.SubVector(index, length));
Assert.That(() => vector.SubVector(index, length), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -414,7 +414,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void FindMaximumIndexThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.MaximumIndex(); });
Assert.That(() => { var actual = vector.MaximumIndex(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -424,7 +424,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void FindMaximumThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.Maximum(); });
Assert.That(() => { var actual = vector.Maximum(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -434,7 +434,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void FindMinimumIndexThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.MinimumIndex(); });
Assert.That(() => { var actual = vector.MinimumIndex(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -444,7 +444,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void FindMinimumThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.Minimum(); });
Assert.That(() => { var actual = vector.Minimum(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -480,7 +480,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void SetValuesWithNullParameterThrowsArgumentException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.SetValues(null));
Assert.That(() => vector.SetValues(null), Throws.TypeOf<ArgumentNullException>());
}
/// <summary>
@ -490,7 +490,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public void SetValuesWithNonEqualDataLengthThrowsArgumentException()
{
var vector = CreateVector(Data.Length + 2);
Assert.Throws<ArgumentOutOfRangeException>(() => vector.SetValues(Data));
Assert.That(() => vector.SetValues(Data), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -499,7 +499,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void RandomWithNumberOfElementsLessThanZeroThrowsArgumentException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => DenseVector.CreateRandom(-2, new ContinuousUniform()));
Assert.That(() => DenseVector.CreateRandom(-2, new ContinuousUniform()), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs

@ -170,7 +170,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => DenseMatrix.CreateIdentity(order));
Assert.That(() => DenseMatrix.CreateIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
}

4
src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs

@ -89,8 +89,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void ParseIfMissingClosingParenThrowsFormatException()
{
Assert.Throws<FormatException>(() => DenseVector.Parse("(1"));
Assert.Throws<FormatException>(() => DenseVector.Parse("[1"));
Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf<FormatException>());
Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf<FormatException>());
}
/// <summary>

8
src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs

@ -181,7 +181,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => DiagonalMatrix.CreateIdentity(order));
Assert.That(() => DiagonalMatrix.CreateIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -216,7 +216,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
var permutation = new Permutation(new[] {2, 0, 1});
Assert.Throws<InvalidOperationException>(() => matrixp.PermuteRows(permutation));
Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException);
}
/// <summary>
@ -227,7 +227,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
var permutation = new Permutation(new[] {2, 0, 1});
Assert.Throws<InvalidOperationException>(() => matrixp.PermuteColumns(permutation));
Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException);
}
/// <summary>
@ -348,7 +348,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void DeterminantNotSquareMatrixThrowsArgumentException()
{
var matrix = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentException>(() => matrix.Determinant());
Assert.That(() => matrix.Determinant(), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
{
var matrixI = DenseMatrix.CreateIdentity(10);
matrixI[3, 3] = -4.0f;
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>
@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
public void CholeskyFailsWithNonSquareMatrix()
{
var matrix = new DenseMatrix(3, 1);
Assert.Throws<ArgumentException>(() => matrix.Cholesky());
Assert.That(() => matrix.Cholesky(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs

@ -46,7 +46,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)));
Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs

@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
public void LUFailsWithNonSquareMatrix()
{
var matrix = new DenseMatrix(3, 1);
Assert.Throws<ArgumentException>(() => matrix.LU());
Assert.That(() => matrix.LU(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs

@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserQR.Create(new DenseMatrix(3, 4)));
Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs

@ -193,7 +193,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
var factorSvd = matrixA.Svd(false);
var matrixB = Matrix<Complex32>.Build.Random(10, 3, 1);
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(matrixB));
Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException);
}
/// <summary>
@ -206,7 +206,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
var factorSvd = matrixA.Svd(false);
var vectorb = Vector<Complex32>.Build.Random(3, 1);
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(vectorb));
Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
{
var matrixI = UserDefinedMatrix.Identity(10);
matrixI[3, 3] = -4.0f;
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>
@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
public void CholeskyFailsWithNonSquareMatrix()
{
var matrixI = new UserDefinedMatrix(3, 1);
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs

@ -45,7 +45,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)));
Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs

@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
public void LUFailsWithNonSquareMatrix()
{
var matrix = new UserDefinedMatrix(3, 1);
Assert.Throws<ArgumentException>(() => matrix.LU());
Assert.That(() => matrix.LU(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs

@ -46,7 +46,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserQR.Create(new UserDefinedMatrix(3, 4)));
Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs

@ -192,7 +192,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
var factorSvd = matrixA.Svd(false);
var matrixB = new UserDefinedMatrix(Matrix<Complex32>.Build.Random(10, 3, 1).ToArray());
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(matrixB));
Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException);
}
/// <summary>
@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization
var factorSvd = matrixA.Svd(false);
var vectorb = new UserDefinedVector(Vector<Complex32>.Build.Random(3, 1).ToArray());
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(vectorb));
Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException);
}
/// <summary>

40
src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs

@ -132,7 +132,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1) });
Vector<Complex32> y = new DenseVector(4);
Assert.Throws<ArgumentException>(() => matrix.Multiply(x, y));
Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException);
}
/// <summary>
@ -210,7 +210,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3f, result));
Assert.That(() => matrix.Multiply(2.3f, result), Throws.ArgumentException);
}
/// <summary>
@ -221,7 +221,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1);
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3f, result));
Assert.That(() => matrix.Multiply(2.3f, result), Throws.ArgumentException);
}
/// <summary>
@ -255,7 +255,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Add(other));
Assert.That(() => matrix.Add(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -266,7 +266,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Add(other));
Assert.That(() => matrix.Add(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -344,7 +344,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Subtract(other));
Assert.That(() => matrix.Subtract(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -355,7 +355,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Subtract(other));
Assert.That(() => matrix.Subtract(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -498,7 +498,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException);
}
/// <summary>
@ -638,7 +638,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1) });
Vector<Complex32> y = new DenseVector(4);
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(x, y));
Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException);
}
/// <summary>
@ -675,7 +675,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Wide2x3"];
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException);
}
/// <summary>
@ -763,7 +763,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Negate(target));
Assert.That(() => matrix.Negate(target), Throws.ArgumentException);
}
/// <summary>
@ -774,7 +774,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = TestMatrices["Singular3x3"];
var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Negate(target));
Assert.That(() => matrix.Negate(target), Throws.ArgumentException);
}
/// <summary>
@ -849,7 +849,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => TestMatrices["Square4x4"].NormalizeColumns(-4));
Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -874,7 +874,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => TestMatrices["Square4x4"].NormalizeRows(-4));
Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -916,7 +916,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var matrix = TestMatrices["Wide2x3"];
var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
var result = matrix.Clone();
Assert.Throws<ArgumentException>(() => matrix.PointwiseMultiply(other, result));
Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException);
}
/// <summary>
@ -928,7 +928,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.PointwiseMultiply(other, result));
Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException);
}
/// <summary>
@ -968,7 +968,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var matrix = TestMatrices["Wide2x3"];
var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
var result = matrix.Clone();
Assert.Throws<ArgumentException>(() => matrix.PointwiseDivide(other, result));
Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException);
}
/// <summary>
@ -980,7 +980,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.PointwiseDivide(other, result));
Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException);
}
/// <summary>
@ -991,7 +991,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[TestCase(-2)]
public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows)
{
Assert.Throws<ArgumentOutOfRangeException>(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()));
Assert.That(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -1012,7 +1012,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void TraceOfNonSquareMatrixThrowsArgumentException()
{
var matrix = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentException>(() => matrix.Trace());
Assert.That(() => matrix.Trace(), Throws.ArgumentException);
}
}
}

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs

@ -73,11 +73,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers
};
var iterator = new Iterator<Complex32>(criteria);
Assert.Throws<ArgumentOutOfRangeException>(() => iterator.DetermineStatus(
Assert.That(() => iterator.DetermineStatus(
-1,
Vector<Complex32>.Build.Dense(3, 4),
Vector<Complex32>.Build.Dense(3, 5),
Vector<Complex32>.Build.Dense(3, 6)));
Vector<Complex32>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs

@ -126,7 +126,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
preconditioner.Initialize(newMatrix);
var result = new DenseVector(vector.Count + 10);
Assert.Throws<ArgumentException>(() => preconditioner.Approximate(vector, result));
Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException);
}
/// <summary>
@ -139,7 +139,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
var vector = CreateStandardBcVector(Size);
var preconditioner = CreatePreconditioner();
var result = new DenseVector(vector.Count);
Assert.Throws<ArgumentException>(() => preconditioner.Approximate(vector, result));
Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException);
}
}
}

8
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs

@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
[Test]
public void CreateWithNegativeMaximumIncreaseThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new DivergenceStopCriterium<Complex32>(-0.1));
Assert.That(() => new DivergenceStopCriterium<Complex32>(-0.1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -59,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
[Test]
public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new DivergenceStopCriterium<Complex32>(minimumIterations: 2));
Assert.That(() => new DivergenceStopCriterium<Complex32>(minimumIterations: 2), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -82,11 +82,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
{
var criterium = new DivergenceStopCriterium<Complex32>(0.5, 15);
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
-1,
Vector<Complex32>.Build.Dense(3, 4),
Vector<Complex32>.Build.Dense(3, 5),
Vector<Complex32>.Build.Dense(3, 6)));
Vector<Complex32>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/FailureStopCriteriumTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
var criterium = new FailureStopCriterium<Complex32>();
Assert.IsNotNull(criterium, "There should be a criterium");
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(-1, Vector<Complex32>.Build.Dense(3, 4), Vector<Complex32>.Build.Dense(3, 5), Vector<Complex32>.Build.Dense(3, 6)));
Assert.That(() => criterium.DetermineStatus(-1, Vector<Complex32>.Build.Dense(3, 4), Vector<Complex32>.Build.Dense(3, 5), Vector<Complex32>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
var criterium = new FailureStopCriterium<Complex32>();
Assert.IsNotNull(criterium, "There should be a criterium");
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(1, Vector<Complex32>.Build.Dense(3, 4), Vector<Complex32>.Build.Dense(3, 6), Vector<Complex32>.Build.Dense(4, 4)));
Assert.That(() => criterium.DetermineStatus(1, Vector<Complex32>.Build.Dense(3, 4), Vector<Complex32>.Build.Dense(3, 6), Vector<Complex32>.Build.Dense(4, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs

@ -49,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
[Test]
public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new IterationCountStopCriterium<Complex32>(-1));
Assert.That(() => new IterationCountStopCriterium<Complex32>(-1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -86,7 +86,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
var criterium = new IterationCountStopCriterium<Complex32>(10);
Assert.IsNotNull(criterium, "A criterium should have been created");
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(-1, Vector<Complex32>.Build.Dense(3, 1), Vector<Complex32>.Build.Dense(3, 2), Vector<Complex32>.Build.Dense(3, 3)));
Assert.That(() => criterium.DetermineStatus(-1, Vector<Complex32>.Build.Dense(3, 1), Vector<Complex32>.Build.Dense(3, 2), Vector<Complex32>.Build.Dense(3, 3)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

20
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs

@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
[Test]
public void CreateWithNegativeMaximumThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new ResidualStopCriterium<Complex32>(-0.1f));
Assert.That(() => new ResidualStopCriterium<Complex32>(-0.1f), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -59,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
[Test]
public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new ResidualStopCriterium<Complex32>(-1));
Assert.That(() => new ResidualStopCriterium<Complex32>(-1), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -82,11 +82,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
{
var criterium = new ResidualStopCriterium<Complex32>(1e-6f, 50);
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
-1,
Vector<Complex32>.Build.Dense(3, 4),
Vector<Complex32>.Build.Dense(3, 5),
Vector<Complex32>.Build.Dense(3, 6)));
Vector<Complex32>.Build.Dense(3, 6)), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -97,11 +97,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
{
var criterium = new ResidualStopCriterium<Complex32>(1e-6f, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
1,
Vector<Complex32>.Build.Dense(4, 4),
Vector<Complex32>.Build.Dense(3, 4),
Vector<Complex32>.Build.Dense(3, 4)));
Vector<Complex32>.Build.Dense(3, 4)), Throws.ArgumentException);
}
/// <summary>
@ -112,11 +112,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
{
var criterium = new ResidualStopCriterium<Complex32>(1e-6f, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
1,
Vector<Complex32>.Build.Dense(3, 4),
Vector<Complex32>.Build.Dense(4, 4),
Vector<Complex32>.Build.Dense(3, 4)));
Vector<Complex32>.Build.Dense(3, 4)), Throws.ArgumentException);
}
/// <summary>
@ -127,11 +127,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr
{
var criterium = new ResidualStopCriterium<Complex32>(1e-6f, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
Assert.That(() => criterium.DetermineStatus(
1,
Vector<Complex32>.Build.Dense(3, 4),
Vector<Complex32>.Build.Dense(3, 4),
DenseVector.Create(4, i => 4)));
DenseVector.Create(4, i => 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs

@ -155,7 +155,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => SparseMatrix.CreateIdentity(order));
Assert.That(() => SparseMatrix.CreateIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs

@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void ParseIfMissingClosingParenThrowsFormatException()
{
Assert.Throws<FormatException>(() => SparseVector.Parse("(1"));
Assert.Throws<FormatException>(() => SparseVector.Parse("[1"));
Assert.That(() => SparseVector.Parse("(1"), Throws.TypeOf<FormatException>());
Assert.That(() => SparseVector.Parse("[1"), Throws.TypeOf<FormatException>());
}
/// <summary>

26
src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs

@ -97,7 +97,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Add(0.0f, result));
Assert.That(() => vector.Add(0.0f, result), Throws.ArgumentException);
}
/// <summary>
@ -108,7 +108,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Add(other));
Assert.That(() => vector.Add(other), Throws.ArgumentException);
}
/// <summary>
@ -120,7 +120,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Add(other, result));
Assert.That(() => vector.Add(other, result), Throws.ArgumentException);
}
/// <summary>
@ -131,7 +131,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var a = CreateVector(Data.Length);
var b = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => a += b);
Assert.That(() => a += b, Throws.ArgumentException);
}
/// <summary>
@ -317,7 +317,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Subtract(0.0f, result));
Assert.That(() => vector.Subtract(0.0f, result), Throws.ArgumentException);
}
/// <summary>
@ -328,7 +328,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Subtract(other));
Assert.That(() => vector.Subtract(other), Throws.ArgumentException);
}
/// <summary>
@ -340,7 +340,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Subtract(other, result));
Assert.That(() => vector.Subtract(other, result), Throws.ArgumentException);
}
/// <summary>
@ -351,7 +351,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var a = CreateVector(Data.Length);
var b = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => a -= b);
Assert.That(() => a -= b, Throws.ArgumentException);
}
/// <summary>
@ -552,7 +552,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Multiply(0.0f, result));
Assert.That(() => vector.Multiply(0.0f, result), Throws.ArgumentException);
}
/// <summary>
@ -563,7 +563,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var vector = CreateVector(Data.Length);
var result = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentException>(() => vector.Divide(0.0f, result));
Assert.That(() => vector.Divide(0.0f, result), Throws.ArgumentException);
}
/// <summary>
@ -643,7 +643,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var dataA = CreateVector(Data);
var dataB = CreateVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1), new Complex32(4, 1), new Complex32(5, 1), new Complex32(6, 1) });
Assert.Throws<ArgumentException>(() => dataA.DotProduct(dataB));
Assert.That(() => dataA.DotProduct(dataB), Throws.ArgumentException);
}
/// <summary>
@ -710,7 +710,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
var result = CreateVector(vector1.Count + 1);
Assert.Throws<ArgumentException>(() => vector1.PointwiseMultiply(vector2, result));
Assert.That(() => vector1.PointwiseMultiply(vector2, result), Throws.ArgumentException);
}
/// <summary>
@ -753,7 +753,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
var result = CreateVector(vector1.Count + 1);
Assert.Throws<ArgumentException>(() => vector1.PointwiseDivide(vector2, result));
Assert.That(() => vector1.PointwiseDivide(vector2, result), Throws.ArgumentException);
}
/// <summary>

20
src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs

@ -211,8 +211,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void SizeIsNotPositiveThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => CreateVector(-1));
Assert.Throws<ArgumentOutOfRangeException>(() => CreateVector(0));
Assert.That(() => CreateVector(-1), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => CreateVector(0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -352,7 +352,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length)
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentOutOfRangeException>(() => vector.SubVector(index, length));
Assert.That(() => vector.SubVector(index, length), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -410,7 +410,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void FindMaximumIndexThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.MaximumIndex(); });
Assert.That(() => { var actual = vector.MaximumIndex(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -420,7 +420,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void FindMaximumThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.Maximum(); });
Assert.That(() => { var actual = vector.Maximum(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -430,7 +430,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void FindMinimumIndexThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.MinimumIndex(); });
Assert.That(() => { var actual = vector.MinimumIndex(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -440,7 +440,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void FindMinimumThrowsNotSupportedException()
{
var vector = CreateVector(Data);
Assert.Throws<NotSupportedException>(() => { var actual = vector.Minimum(); });
Assert.That(() => { var actual = vector.Minimum(); }, Throws.TypeOf<NotSupportedException>());
}
/// <summary>
@ -476,7 +476,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void SetValuesWithNullParameterThrowsArgumentException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.SetValues(null));
Assert.That(() => vector.SetValues(null), Throws.TypeOf<ArgumentNullException>());
}
/// <summary>
@ -486,7 +486,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public void SetValuesWithNonEqualDataLengthThrowsArgumentException()
{
var vector = CreateVector(Data.Length + 2);
Assert.Throws<ArgumentOutOfRangeException>(() => vector.SetValues(Data));
Assert.That(() => vector.SetValues(Data), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -495,7 +495,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void RandomWithNumberOfElementsLessThanZeroThrowsArgumentException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => DenseVector.CreateRandom(-2, new ContinuousUniform()));
Assert.That(() => DenseVector.CreateRandom(-2, new ContinuousUniform()), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs

@ -171,7 +171,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => Matrix<double>.Build.DenseIdentity(order));
Assert.That(() => Matrix<double>.Build.DenseIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
}
}

4
src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs

@ -100,8 +100,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[Test]
public void ParseIfMissingClosingParenThrowsFormatException()
{
Assert.Throws<FormatException>(() => DenseVector.Parse("(1"));
Assert.Throws<FormatException>(() => DenseVector.Parse("[1"));
Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf<FormatException>());
Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf<FormatException>());
}
/// <summary>

8
src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs

@ -180,7 +180,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[TestCase(-1)]
public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order)
{
Assert.Throws<ArgumentOutOfRangeException>(() => Matrix<double>.Build.DiagonalIdentity(order));
Assert.That(() => Matrix<double>.Build.DiagonalIdentity(order), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
var permutation = new Permutation(new[] {2, 0, 1});
Assert.Throws<InvalidOperationException>(() => matrixp.PermuteRows(permutation));
Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException);
}
/// <summary>
@ -226,7 +226,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
var permutation = new Permutation(new[] {2, 0, 1});
Assert.Throws<InvalidOperationException>(() => matrixp.PermuteColumns(permutation));
Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException);
}
/// <summary>
@ -347,7 +347,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public void DeterminantNotSquareMatrixThrowsArgumentException()
{
var matrix = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentException>(() => matrix.Determinant());
Assert.That(() => matrix.Determinant(), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs

@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
{
var matrixI = Matrix<double>.Build.DenseIdentity(10);
matrixI[3, 3] = -4.0;
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>
@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
public void CholeskyFailsWithNonSquareMatrix()
{
var matrix = new DenseMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrix.Cholesky());
Assert.That(() => matrix.Cholesky(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs

@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)));
Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs

@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
public void LUFailsWithNonSquareMatrix()
{
var matrix = new DenseMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrix.LU());
Assert.That(() => matrix.LU(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs

@ -45,7 +45,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserQR.Create(new DenseMatrix(3, 4)));
Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs

@ -190,7 +190,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
var factorSvd = matrixA.Svd(false);
var matrixB = Matrix<double>.Build.Random(10, 10, 1);
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(matrixB));
Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException);
}
/// <summary>
@ -203,7 +203,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
var factorSvd = matrixA.Svd(false);
var vectorb = Vector<double>.Build.Random(10, 1);
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(vectorb));
Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs

@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
{
var matrixI = UserDefinedMatrix.Identity(10);
matrixI[3, 3] = -4.0;
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>
@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
public void CholeskyFailsWithNonSquareMatrix()
{
var matrixI = new UserDefinedMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrixI.Cholesky());
Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)));
Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs

@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
public void LUFailsWithNonSquareMatrix()
{
var matrix = new UserDefinedMatrix(3, 2);
Assert.Throws<ArgumentException>(() => matrix.LU());
Assert.That(() => matrix.LU(), Throws.ArgumentException);
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs

@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
[Test]
public void ConstructorWideMatrixThrowsInvalidMatrixOperationException()
{
Assert.Throws<ArgumentException>(() => UserQR.Create(new UserDefinedMatrix(3, 4)));
Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs

@ -189,7 +189,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
var factorSvd = matrixA.Svd(false);
var matrixB = new UserDefinedMatrix(Matrix<double>.Build.Random(10, 10, 1).ToArray());
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(matrixB));
Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException);
}
/// <summary>
@ -202,7 +202,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization
var factorSvd = matrixA.Svd(false);
var vectorb = new UserDefinedVector(Vector<double>.Build.Random(10, 1).ToArray());
Assert.Throws<InvalidOperationException>(() => factorSvd.Solve(vectorb));
Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException);
}
/// <summary>

40
src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs

@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0, 2.0, 3.0 });
Vector<double> y = new DenseVector(4);
Assert.Throws<ArgumentException>(() => matrix.Multiply(x, y));
Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException);
}
/// <summary>
@ -204,7 +204,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3, result));
Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException);
}
/// <summary>
@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1);
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3, result));
Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException);
}
/// <summary>
@ -249,7 +249,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Add(other));
Assert.That(() => matrix.Add(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -260,7 +260,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Add(other));
Assert.That(() => matrix.Add(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -338,7 +338,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Subtract(other));
Assert.That(() => matrix.Subtract(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Subtract(other));
Assert.That(() => matrix.Subtract(other), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -492,7 +492,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var other = TestMatrices["Tall3x2"];
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException);
}
/// <summary>
@ -632,7 +632,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0, 2.0, 3.0 });
Vector<double> y = new DenseVector(4);
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(x, y));
Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException);
}
/// <summary>
@ -669,7 +669,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Wide2x3"];
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException);
}
/// <summary>
@ -757,7 +757,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Negate(target));
Assert.That(() => matrix.Negate(target), Throws.ArgumentException);
}
/// <summary>
@ -768,7 +768,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = TestMatrices["Singular3x3"];
var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.Negate(target));
Assert.That(() => matrix.Negate(target), Throws.ArgumentException);
}
/// <summary>
@ -843,7 +843,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[Test]
public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => TestMatrices["Square4x4"].NormalizeColumns(-4));
Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -868,7 +868,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[Test]
public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(() => TestMatrices["Square4x4"].NormalizeRows(-4));
Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -910,7 +910,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var matrix = TestMatrices["Wide2x3"];
var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
var result = matrix.Clone();
Assert.Throws<ArgumentException>(() => matrix.PointwiseMultiply(other, result));
Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException);
}
/// <summary>
@ -922,7 +922,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.PointwiseMultiply(other, result));
Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException);
}
/// <summary>
@ -962,7 +962,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var matrix = TestMatrices["Wide2x3"];
var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
var result = matrix.Clone();
Assert.Throws<ArgumentException>(() => matrix.PointwiseDivide(other, result));
Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException);
}
/// <summary>
@ -974,7 +974,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
Assert.Throws<ArgumentException>(() => matrix.PointwiseDivide(other, result));
Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException);
}
/// <summary>
@ -985,7 +985,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[TestCase(-2)]
public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows)
{
Assert.Throws<ArgumentOutOfRangeException>(() => Matrix<double>.Build.Random(numberOfRows, 4, new ContinuousUniform()));
Assert.That(() => Matrix<double>.Build.Random(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf<ArgumentOutOfRangeException>());
}
/// <summary>
@ -1006,7 +1006,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public void TraceOfNonSquareMatrixThrowsArgumentException()
{
var matrix = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentException>(() => matrix.Trace());
Assert.That(() => matrix.Trace(), Throws.ArgumentException);
}
[Test]

4
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
/// <summary>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save