diff --git a/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs b/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs index 56df452d..3a071262 100644 --- a/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs +++ b/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs @@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests [Test] public void IfMissingClosingParenParseThrowsFormatException() { - Assert.Throws(() => Complex32.Parse("(1,2")); + Assert.That(() => Complex32.Parse("(1,2"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs b/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs index d8495a21..3d7cbddf 100644 --- a/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs +++ b/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs @@ -108,7 +108,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests [Test] public void IfMissingClosingParenParseThrowsFormatException() { - Assert.Throws(() => "(1,2".ToComplex()); + Assert.That(() => "(1,2".ToComplex(), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs index 630ac0a3..63f4fb70 100644 --- a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs @@ -71,12 +71,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void BetaCreateFailsWithBadParameters() { - Assert.Throws(() => new Beta(Double.NaN, 1.0)); - Assert.Throws(() => new Beta(1.0, Double.NaN)); - Assert.Throws(() => new Beta(Double.NaN, Double.NaN)); - Assert.Throws(() => new Beta(1.0, -1.0)); - Assert.Throws(() => new Beta(-1.0, 1.0)); - Assert.Throws(() => new Beta(-1.0, -1.0)); + Assert.That(() => new Beta(Double.NaN, 1.0), Throws.TypeOf()); + Assert.That(() => new Beta(1.0, Double.NaN), Throws.TypeOf()); + Assert.That(() => new Beta(Double.NaN, Double.NaN), Throws.TypeOf()); + Assert.That(() => new Beta(1.0, -1.0), Throws.TypeOf()); + Assert.That(() => new Beta(-1.0, 1.0), Throws.TypeOf()); + Assert.That(() => new Beta(-1.0, -1.0), Throws.TypeOf()); } /// @@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetShapeAFailsWithNegativeA() { var n = new Beta(1.0, 1.0); - Assert.Throws(() => n.A = -1.0); + Assert.That(() => n.A = -1.0, Throws.TypeOf()); } /// @@ -142,7 +142,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetShapeBFailsWithNegativeB() { var n = new Beta(1.0, 1.0); - Assert.Throws(() => n.B = -1.0); + Assert.That(() => n.B = -1.0, Throws.TypeOf()); } /// @@ -288,7 +288,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => Beta.Sample(new Random(0), 1.0, -1.0)); + Assert.That(() => Beta.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf()); } /// @@ -297,7 +297,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleSequenceStatic() { - Assert.Throws(() => Beta.Samples(new Random(0), 1.0, -1.0).First()); + Assert.That(() => Beta.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs index 907c3c25..198fab6c 100644 --- a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs +++ b/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(() => new Cauchy(location, scale)); + Assert.That(() => new Cauchy(location, scale), Throws.TypeOf()); } /// @@ -118,7 +118,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetBadLocationFail() { var n = new Cauchy(); - Assert.Throws(() => n.Location = Double.NaN); + Assert.That(() => n.Location = Double.NaN, Throws.TypeOf()); } /// @@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetBadScaleFail() { var n = new Cauchy(); - Assert.Throws(() => n.Scale = -1.0); + Assert.That(() => n.Scale = -1.0, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs index aa7a8ca3..e661d227 100644 --- a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs +++ b/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(() => new ChiSquared(dof)); + Assert.That(() => new ChiSquared(dof), Throws.TypeOf()); } /// @@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetDofFailsWithNonPositiveDoF(double dof) { var n = new ChiSquared(1.0); - Assert.Throws(() => n.DegreesOfFreedom = dof); + Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf()); } /// @@ -293,7 +293,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => ChiSquared.Sample(new Random(0), -1.0)); + Assert.That(() => ChiSquared.Sample(new Random(0), -1.0), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs index 1a240b4c..31c0c38b 100644 --- a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs +++ b/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(() => new Chi(dof)); + Assert.That(() => new Chi(dof), Throws.TypeOf()); } /// @@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetDofFailsWithNonPositiveDoF(double dof) { var n = new Chi(1.0); - Assert.Throws(() => n.DegreesOfFreedom = dof); + Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs index f8513218..394fb48b 100644 --- a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs +++ b/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(() => new ContinuousUniform(lower, upper)); + Assert.That(() => new ContinuousUniform(lower, upper), Throws.TypeOf()); } /// @@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetBadLowerFails() { var n = new ContinuousUniform(); - Assert.Throws(() => n.LowerBound = 3.0); + Assert.That(() => n.LowerBound = 3.0, Throws.TypeOf()); } /// @@ -146,7 +146,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetBadUpperFails() { var n = new ContinuousUniform(); - Assert.Throws(() => n.UpperBound = -1.0); + Assert.That(() => n.UpperBound = -1.0, Throws.TypeOf()); } /// @@ -336,7 +336,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0)); + Assert.That(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0), Throws.TypeOf()); } /// @@ -345,7 +345,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleSequenceStatic() { - Assert.Throws(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First()); + Assert.That(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First(), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs index bc72b55f..08f6f71f 100644 --- a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs +++ b/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(() => new Erlang(shape, invScale)); + Assert.That(() => new Erlang(shape, invScale), Throws.TypeOf()); } /// @@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetShapeFailsWithNegativeShape() { var n = new Erlang(1, 1.0); - Assert.Throws(() => n.Shape = -1); + Assert.That(() => n.Shape = -1, Throws.TypeOf()); } /// @@ -171,7 +171,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetScaleFailsWithNegativeScale() { var n = new Erlang(1, 1.0); - Assert.Throws(() => n.Scale = -1.0); + Assert.That(() => n.Scale = -1.0, Throws.TypeOf()); } /// @@ -199,7 +199,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetInvScaleFailsWithNegativeInvScale() { var n = new Erlang(1, 1.0); - Assert.Throws(() => n.Rate = -1.0); + Assert.That(() => n.Rate = -1.0, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs index 4d8ed138..e32ed0c8 100644 --- a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs +++ b/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(() => new Exponential(lambda)); + Assert.That(() => new Exponential(lambda), Throws.TypeOf()); } /// @@ -103,7 +103,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetLambdaFailsWithNegativeLambda() { var n = new Exponential(1.0); - Assert.Throws(() => n.Rate = -1.0); + Assert.That(() => n.Rate = -1.0, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs index e9c27f8d..902cc969 100644 --- a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs +++ b/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(() => new FisherSnedecor(d1, d2)); + Assert.That(() => new FisherSnedecor(d1, d2), Throws.TypeOf()); } /// @@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetDegreesOfFreedom1FailsWithNegativeDegreeOfFreedom() { var n = new FisherSnedecor(1.0, 2.0); - Assert.Throws(() => n.DegreesOfFreedom1 = -1.0); + Assert.That(() => n.DegreesOfFreedom1 = -1.0, Throws.TypeOf()); } /// @@ -150,7 +150,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetDegreesOfFreedom2FailsWithNegativeDegreeOfFreedom() { var n = new FisherSnedecor(1.0, 2.0); - Assert.Throws(() => n.DegreesOfFreedom2 = -1.0); + Assert.That(() => n.DegreesOfFreedom2 = -1.0, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs index 6efe0760..19beaea3 100644 --- a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs +++ b/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(() => new Gamma(shape, invScale)); + Assert.That(() => new Gamma(shape, invScale), Throws.TypeOf()); } /// @@ -147,7 +147,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetShapeFailsWithNegativeShape() { var n = new Gamma(1.0, 1.0); - Assert.Throws(() => n.Shape = -1.0); + Assert.That(() => n.Shape = -1.0, Throws.TypeOf()); } /// @@ -175,7 +175,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetScaleFailsWithNegativeScale() { var n = new Gamma(1.0, 1.0); - Assert.Throws(() => n.Scale = -1.0); + Assert.That(() => n.Scale = -1.0, Throws.TypeOf()); } /// @@ -203,7 +203,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetInvScaleFailsWithNegativeInvScale() { var n = new Gamma(1.0, 1.0); - Assert.Throws(() => n.Rate = -1.0); + Assert.That(() => n.Rate = -1.0, Throws.TypeOf()); } /// @@ -433,7 +433,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => Normal.Sample(new Random(0), 1.0, -1.0)); + Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf()); } /// @@ -442,7 +442,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleSequenceStatic() { - Assert.Throws(() => Normal.Samples(new Random(0), 1.0, -1.0).First()); + Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs index 8023e551..0936c359 100644 --- a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs +++ b/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(() => new InverseGamma(a, b)); + Assert.That(() => new InverseGamma(a, b), Throws.TypeOf()); } /// @@ -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(() => n.Shape = a); + Assert.That(() => n.Shape = a, Throws.TypeOf()); } /// @@ -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(() => n.Scale = b); + Assert.That(() => n.Scale = b, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs index 491e851b..15fdd5e8 100644 --- a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs +++ b/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(() => n.Location = Double.NaN); + Assert.That(() => n.Location = Double.NaN, Throws.TypeOf()); } /// @@ -136,7 +136,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetScaleFailsWithNegativeScale(double scale) { var n = new Laplace(); - Assert.Throws(() => n.Scale = scale); + Assert.That(() => n.Scale = scale, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs index 2abd854b..168341b9 100644 --- a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs +++ b/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(() => new LogNormal(mu, sigma)); + Assert.That(() => new LogNormal(mu, sigma), Throws.TypeOf()); } /// @@ -110,7 +110,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetSigmaFailsWithNegativeSigma() { var n = new LogNormal(1.0, 2.0); - Assert.Throws(() => n.Sigma = -1.0); + Assert.That(() => n.Sigma = -1.0, Throws.TypeOf()); } /// @@ -443,7 +443,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => { 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()); } /// @@ -452,7 +452,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleSequenceStatic() { - Assert.Throws(() => { 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()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs index 86d7e148..a9bd6972 100644 --- a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs +++ b/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(() => new Normal(mean, sdev)); + Assert.That(() => new Normal(mean, sdev), Throws.TypeOf()); } /// @@ -175,7 +175,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetPrecisionFailsWithNegativePrecision() { var n = new Normal(); - Assert.Throws(() => n.Precision = -1.0); + Assert.That(() => n.Precision = -1.0, Throws.TypeOf()); } /// @@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetVarianceFailsWithNegativeVariance() { var n = new Normal(); - Assert.Throws(() => n.Variance = -1.0); + Assert.That(() => n.Variance = -1.0, Throws.TypeOf()); } /// @@ -235,7 +235,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetStdDevFailsWithNegativeStdDev() { var n = new Normal(); - Assert.Throws(() => n.StdDev = -1.0); + Assert.That(() => n.StdDev = -1.0, Throws.TypeOf()); } /// @@ -416,7 +416,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => { 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()); } /// @@ -425,7 +425,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleSequenceStatic() { - Assert.Throws(() => { 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()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs index bb046e36..99df604b 100644 --- a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs +++ b/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(() => { var n = new Pareto(scale, shape); }); + Assert.That(() => { var n = new Pareto(scale, shape); }, Throws.TypeOf()); } /// @@ -109,7 +109,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetScaleFailsWithNegativeScale() { var n = new Pareto(1.0, 1.0); - Assert.Throws(() => n.Scale = -1.0); + Assert.That(() => n.Scale = -1.0, Throws.TypeOf()); } /// @@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetShapeFailsWithNegativeShape() { var n = new Pareto(1.0, 1.0); - Assert.Throws(() => n.Shape = -1.0); + Assert.That(() => n.Shape = -1.0, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs index 34870515..9064e2ea 100644 --- a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs +++ b/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(() => new Rayleigh(scale)); + Assert.That(() => new Rayleigh(scale), Throws.TypeOf()); } /// @@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetScaleFailsWithNegativeScale(double scale) { var n = new Rayleigh(1.0); - Assert.Throws(() => n.Scale = scale); + Assert.That(() => n.Scale = scale, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/StableTests.cs b/src/UnitTests/DistributionTests/Continuous/StableTests.cs index 1159f142..1e0da246 100644 --- a/src/UnitTests/DistributionTests/Continuous/StableTests.cs +++ b/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(() => new Stable(alpha, beta, location, scale)); + Assert.That(() => new Stable(alpha, beta, location, scale), Throws.TypeOf()); } /// @@ -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(() => n.Alpha = alpha); + Assert.That(() => n.Alpha = alpha, Throws.TypeOf()); } /// @@ -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(() => n.Beta = beta); + Assert.That(() => n.Beta = beta, Throws.TypeOf()); } /// @@ -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(() => n.Scale = scale); + Assert.That(() => n.Scale = scale, Throws.TypeOf()); } /// @@ -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(() => n.Location = Double.NaN); + Assert.That(() => n.Location = Double.NaN, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs index 6adb52bd..2dcad435 100644 --- a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs +++ b/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(() => new StudentT(location, scale, dof)); + Assert.That(() => new StudentT(location, scale, dof), Throws.TypeOf()); } /// @@ -144,7 +144,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetScaleFailsWithNonPositiveScale(double scale) { var n = new StudentT(); - Assert.Throws(() => n.Scale = scale); + Assert.That(() => n.Scale = scale, Throws.TypeOf()); } /// @@ -173,7 +173,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void SetDofFailsWithNonPositiveDoF(double dof) { var n = new StudentT(); - Assert.Throws(() => n.DegreesOfFreedom = dof); + Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs index 62cfa54b..04034f0a 100644 --- a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs +++ b/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(() => new Weibull(shape, scale)); + Assert.That(() => new Weibull(shape, scale), Throws.TypeOf()); } /// @@ -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(() => n.Shape = shape); + Assert.That(() => n.Shape = shape, Throws.TypeOf()); } /// @@ -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(() => n.Scale = scale); + Assert.That(() => n.Scale = scale, Throws.TypeOf()); } /// @@ -337,7 +337,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleStatic() { - Assert.Throws(() => Normal.Sample(new Random(0), 1.0, -1.0)); + Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf()); } /// @@ -346,7 +346,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous [Test] public void FailSampleSequenceStatic() { - Assert.Throws(() => Normal.Samples(new Random(0), 1.0, -1.0).First()); + Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs b/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs index ca22f482..493e4b18 100644 --- a/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs @@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete public void CategoricalCreateFailsWithNullHistogram() { Histogram h = null; - Assert.Throws(() => new Categorical(h)); + Assert.That(() => new Categorical(h), Throws.TypeOf()); } /// @@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete [Test] public void CategoricalCreateFailsWithNegativeRatios() { - Assert.Throws(() => new Categorical(_badP)); + Assert.That(() => new Categorical(_badP), Throws.TypeOf()); } /// @@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete [Test] public void CategoricalCreateFailsWithAllZeroRatios() { - Assert.Throws(() => new Categorical(_badP2)); + Assert.That(() => new Categorical(_badP2), Throws.TypeOf()); } /// @@ -156,7 +156,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete public void SetProbabilityFails() { var b = new Categorical(_largeP); - Assert.Throws(() => b.P = _badP); + Assert.That(() => b.P = _badP, Throws.TypeOf()); } /// @@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete [Test] public void FailSampleStatic() { - Assert.Throws(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP)); + Assert.That(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs b/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs index 6e5818b8..8b6e1d97 100644 --- a/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs @@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void FailCreateDirichlet() { - Assert.Throws(() => new Dirichlet(0.0, 5)); - Assert.Throws(() => new Dirichlet(-0.1, 5)); + Assert.That(() => new Dirichlet(0.0, 5), Throws.TypeOf()); + Assert.That(() => new Dirichlet(-0.1, 5), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs index 432b7295..ce5d3b45 100644 --- a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs @@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate var matrix = Matrix.Build.RandomPositiveDefinite(order, 1); matrix[0, 0] = 0.0; - Assert.Throws(() => new InverseWishart(nu, matrix)); + Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf()); } /// @@ -96,7 +96,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate public void FailNuCreateInverseWishart(double nu, int order) { var matrix = Matrix.Build.RandomPositiveDefinite(order, 1); - Assert.Throws(() => new InverseWishart(nu, matrix)); + Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf()); } /// @@ -312,7 +312,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void FailSampleStatic() { - Assert.Throws(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1))); + Assert.That(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf()); } } } diff --git a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs index 4ca2b160..0588a9b1 100644 --- a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs @@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate var matrixV = Matrix.Build.Random(rowsOfV, columnsOfV, 1); var matrixK = Matrix.Build.Random(rowsOfK, columnsOfK, 1); - Assert.Throws(() => new MatrixNormal(matrixM, matrixV, matrixK)); + Assert.That(() => new MatrixNormal(matrixM, matrixV, matrixK), Throws.TypeOf()); } /// @@ -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(() => MatrixNormal.Sample(new System.Random(0), Matrix.Build.Random(rowsOfM, columnsOfM, 1), Matrix.Build.Random(rowsOfV, columnsOfV, 1), Matrix.Build.Random(rowsOfK, columnsOfK, 1))); + Assert.That(() => MatrixNormal.Sample(new System.Random(0), Matrix.Build.Random(rowsOfM, columnsOfM, 1), Matrix.Build.Random(rowsOfV, columnsOfV, 1), Matrix.Build.Random(rowsOfK, columnsOfK, 1)), Throws.TypeOf()); } } } diff --git a/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs b/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs index c8d01617..79b93d8d 100644 --- a/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs @@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate public void MultinomialCreateFailsWithNullHistogram() { Histogram h = null; - Assert.Throws(() => new Categorical(h)); + Assert.That(() => new Categorical(h), Throws.TypeOf()); } /// @@ -113,7 +113,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void MultinomialCreateFailsWithNegativeRatios() { - Assert.Throws(() => new Multinomial(_badP, 4)); + Assert.That(() => new Multinomial(_badP, 4), Throws.TypeOf()); } /// @@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void MultinomialCreateFailsWithAllZeroRatios() { - Assert.Throws(() => new Multinomial(_badP2, 4)); + Assert.That(() => new Multinomial(_badP2, 4), Throws.TypeOf()); } /// @@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate public void SetProbabilityFails() { var b = new Multinomial(_largeP, 4); - Assert.Throws(() => b.P = _badP); + Assert.That(() => b.P = _badP, Throws.TypeOf()); } /// @@ -254,7 +254,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void FailSampleStatic() { - Assert.Throws(() => Multinomial.Sample(new Random(0), _badP, 4)); + Assert.That(() => Multinomial.Sample(new Random(0), _badP, 4), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs b/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs index c7503553..49b1818c 100644 --- a/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs @@ -77,9 +77,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void NormalGammaConstructorFailsWithInvalidParams() { - Assert.Throws(() => new NormalGamma(1.0, -1.3, 2.0, 2.0)); - Assert.Throws(() => new NormalGamma(1.0, 1.0, -1.0, 1.0)); - Assert.Throws(() => new NormalGamma(1.0, 1.0, 1.0, -1.0)); + Assert.That(() => new NormalGamma(1.0, -1.3, 2.0, 2.0), Throws.TypeOf()); + Assert.That(() => new NormalGamma(1.0, 1.0, -1.0, 1.0), Throws.TypeOf()); + Assert.That(() => new NormalGamma(1.0, 1.0, 1.0, -1.0), Throws.TypeOf()); } /// diff --git a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs index ca347319..a41ae0f6 100644 --- a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs @@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate var matrix = Matrix.Build.RandomPositiveDefinite(order, 1); matrix[0, 0] = 0.0; - Assert.Throws(() => new Wishart(nu, matrix)); + Assert.That(() => new Wishart(nu, matrix), Throws.TypeOf()); } /// @@ -98,7 +98,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate public void FailNuCreateWishart(double nu, int order) { var matrix = Matrix.Build.RandomPositiveDefinite(order, 1); - Assert.Throws(() => new InverseWishart(nu, matrix)); + Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf()); } /// @@ -304,7 +304,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate [Test] public void FailSampleStatic() { - Assert.Throws(() => Wishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1))); + Assert.That(() => Wishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf()); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs index 3c1c440d..13b40876 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs +++ b/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(() => DenseMatrix.CreateIdentity(order)); + Assert.That(() => DenseMatrix.CreateIdentity(order), Throws.TypeOf()); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs index f17225d4..ff6a4893 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs @@ -89,8 +89,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => DenseVector.Parse("(1")); - Assert.Throws(() => DenseVector.Parse("[1")); + Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs index 2ed3c9a5..6f0d0c5c 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs +++ b/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(() => DiagonalMatrix.CreateIdentity(order)); + Assert.That(() => DiagonalMatrix.CreateIdentity(order), Throws.TypeOf()); } /// @@ -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(() => matrixp.PermuteRows(permutation)); + Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException); } /// @@ -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(() => matrixp.PermuteColumns(permutation)); + Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException); } /// @@ -352,7 +352,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void DeterminantNotSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Determinant()); + Assert.That(() => matrix.Determinant(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs index b70b76f1..53445c49 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs +++ b/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(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrix = new DenseMatrix(3, 2); - Assert.Throws(() => matrix.Cholesky()); + Assert.That(() => matrix.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs index dd855a06..ad30ef73 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs @@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4))); + Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs index c9ca707b..2862eabd 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs +++ b/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(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs index 1b83ef0a..5b428254 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs @@ -51,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new DenseMatrix(3, 4))); + Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs index 4539cdc0..8e8c0cb6 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs +++ b/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.Build.Random(10, 9, 1); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -209,7 +209,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization var factorSvd = matrixA.Svd(false); var vectorb = Vector.Build.Random(9, 1); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs index 5fc94b85..5192b7ef 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs +++ b/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(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrixI = new UserDefinedMatrix(3, 2); - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs index 86721d4c..6b3918e7 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs @@ -49,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs index 521072c2..9161138c 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs +++ b/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(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs index 5470c4f8..78b36daf 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs @@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs index 4d8f3fd6..8728ecdf 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs +++ b/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.Build.Random(10, 9, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -208,7 +208,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization var factorSvd = matrixA.Svd(false); var vectorb = new UserDefinedVector(Vector.Build.Random(9, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs index 7c371dee..da96f1e2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs +++ b/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 y = new DenseVector(4); - Assert.Throws(() => matrix.Multiply(x, y)); + Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException); } /// @@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Multiply(2.3, result)); + Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException); } /// @@ -225,7 +225,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1); - Assert.Throws(() => matrix.Multiply(2.3, result)); + Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException); } /// @@ -259,7 +259,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -270,7 +270,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -348,7 +348,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -359,7 +359,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -502,7 +502,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); + Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException); } /// @@ -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 y = new DenseVector(4); - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); + Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException); } /// @@ -679,7 +679,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Wide2x3"]; var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); + Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException); } /// @@ -767,7 +767,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -778,7 +778,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -853,7 +853,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeColumns(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf()); } /// @@ -878,7 +878,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeRows(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf()); } /// @@ -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(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -999,7 +999,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [TestCase(-2)] public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { - Assert.Throws(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform())); + Assert.That(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf()); } /// @@ -1020,7 +1020,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void TraceOfNonSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Trace()); + Assert.That(() => matrix.Trace(), Throws.ArgumentException); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs index 392cd760..d99ca5b5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ var input = new DenseVector(3); var solver = new BiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs index 037556e3..87ef7729 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ var input = new DenseVector(3); var solver = new GpBiCg(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs index b8a20c17..7595d232 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ var input = new DenseVector(3); var solver = new MlkBiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs index 753ac4a8..8ad3d79a 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -82,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ var input = new DenseVector(3); var solver = new TFQMR(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs index 0398f145..4ebfe2b0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs @@ -77,11 +77,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers }; var iterator = new Iterator(criteria); - Assert.Throws(() => iterator.DetermineStatus( + Assert.That(() => iterator.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs index fb19072a..d0047712 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs +++ b/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(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } /// @@ -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(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index b0f16809..7c680881 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/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(() => new DivergenceStopCriterium(-0.1)); + Assert.That(() => new DivergenceStopCriterium(-0.1), Throws.TypeOf()); } /// @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new DivergenceStopCriterium(minimumIterations: 2)); + Assert.That(() => new DivergenceStopCriterium(minimumIterations: 2), Throws.TypeOf()); } /// @@ -86,11 +86,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException() { var criterium = new DivergenceStopCriterium(0.5, 15); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/FailureStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/FailureStopCriteriumTest.cs index 79043c06..2becfbbd 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/FailureStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/FailureStopCriteriumTest.cs @@ -67,7 +67,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4))); + Assert.That(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index 2228f52e..fef46afc 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/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(() => new IterationCountStopCriterium(-1)); + Assert.That(() => new IterationCountStopCriterium(-1), Throws.TypeOf()); } /// @@ -90,7 +90,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit var criterium = new IterationCountStopCriterium(10); Assert.IsNotNull(criterium, "A criterium should have been created"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index 26c0aeb1..96ed2f0e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/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(() => new ResidualStopCriterium(-0.1)); + Assert.That(() => new ResidualStopCriterium(-0.1), Throws.TypeOf()); } /// @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new ResidualStopCriterium(-1)); + Assert.That(() => new ResidualStopCriterium(-1), Throws.TypeOf()); } /// @@ -86,11 +86,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -101,11 +101,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(4, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -116,11 +116,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(4, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -131,11 +131,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(4, 4))); + Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs index 13cd0313..b8617e68 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs +++ b/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(() => SparseMatrix.CreateIdentity(order)); + Assert.That(() => SparseMatrix.CreateIdentity(order), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs index 5bbded70..2dce1647 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs @@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => SparseVector.Parse("(1")); - Assert.Throws(() => SparseVector.Parse("[1")); + Assert.That(() => SparseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => SparseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs index 4d358f08..dedd8afe 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs +++ b/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(() => vector.Add(0.0, result)); + Assert.That(() => vector.Add(0.0, result), Throws.ArgumentException); } /// @@ -112,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other)); + Assert.That(() => vector.Add(other), Throws.ArgumentException); } /// @@ -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(() => vector.Add(other, result)); + Assert.That(() => vector.Add(other, result), Throws.ArgumentException); } /// @@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a += b); + Assert.That(() => a += b, Throws.ArgumentException); } /// @@ -321,7 +321,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(0.0, result)); + Assert.That(() => vector.Subtract(0.0, result), Throws.ArgumentException); } /// @@ -332,7 +332,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other)); + Assert.That(() => vector.Subtract(other), Throws.ArgumentException); } /// @@ -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(() => vector.Subtract(other, result)); + Assert.That(() => vector.Subtract(other, result), Throws.ArgumentException); } /// @@ -355,7 +355,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a -= b); + Assert.That(() => a -= b, Throws.ArgumentException); } /// @@ -556,7 +556,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Multiply(0.0, result)); + Assert.That(() => vector.Multiply(0.0, result), Throws.ArgumentException); } /// @@ -567,7 +567,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Divide(0.0, result)); + Assert.That(() => vector.Divide(0.0, result), Throws.ArgumentException); } /// @@ -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(() => dataA.DotProduct(dataB)); + Assert.That(() => dataA.DotProduct(dataB), Throws.ArgumentException); } /// @@ -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(() => vector1.PointwiseMultiply(vector2, result)); + Assert.That(() => vector1.PointwiseMultiply(vector2, result), Throws.ArgumentException); } /// @@ -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(() => vector1.PointwiseDivide(vector2, result)); + Assert.That(() => vector1.PointwiseDivide(vector2, result), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs index 6b597e08..41c45774 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs @@ -215,8 +215,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void SizeIsNotPositiveThrowsArgumentOutOfRangeException() { - Assert.Throws(() => CreateVector(-1)); - Assert.Throws(() => CreateVector(0)); + Assert.That(() => CreateVector(-1), Throws.TypeOf()); + Assert.That(() => CreateVector(0), Throws.TypeOf()); } /// @@ -356,7 +356,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); - Assert.Throws(() => vector.SubVector(index, length)); + Assert.That(() => vector.SubVector(index, length), Throws.TypeOf()); } /// @@ -414,7 +414,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void FindMaximumIndexThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.MaximumIndex(); }); + Assert.That(() => { var actual = vector.MaximumIndex(); }, Throws.TypeOf()); } /// @@ -424,7 +424,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void FindMaximumThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.Maximum(); }); + Assert.That(() => { var actual = vector.Maximum(); }, Throws.TypeOf()); } /// @@ -434,7 +434,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void FindMinimumIndexThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.MinimumIndex(); }); + Assert.That(() => { var actual = vector.MinimumIndex(); }, Throws.TypeOf()); } /// @@ -444,7 +444,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void FindMinimumThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.Minimum(); }); + Assert.That(() => { var actual = vector.Minimum(); }, Throws.TypeOf()); } /// @@ -480,7 +480,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void SetValuesWithNullParameterThrowsArgumentException() { var vector = CreateVector(Data); - Assert.Throws(() => vector.SetValues(null)); + Assert.That(() => vector.SetValues(null), Throws.TypeOf()); } /// @@ -490,7 +490,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void SetValuesWithNonEqualDataLengthThrowsArgumentException() { var vector = CreateVector(Data.Length + 2); - Assert.Throws(() => vector.SetValues(Data)); + Assert.That(() => vector.SetValues(Data), Throws.TypeOf()); } /// @@ -499,7 +499,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void RandomWithNumberOfElementsLessThanZeroThrowsArgumentException() { - Assert.Throws(() => DenseVector.CreateRandom(-2, new ContinuousUniform())); + Assert.That(() => DenseVector.CreateRandom(-2, new ContinuousUniform()), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs index 47a60430..a1b62e49 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs +++ b/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(() => DenseMatrix.CreateIdentity(order)); + Assert.That(() => DenseMatrix.CreateIdentity(order), Throws.TypeOf()); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs index 9d01cbd7..dde03fa5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs @@ -89,8 +89,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => DenseVector.Parse("(1")); - Assert.Throws(() => DenseVector.Parse("[1")); + Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs index 89589d70..bffa92cc 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs +++ b/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(() => DiagonalMatrix.CreateIdentity(order)); + Assert.That(() => DiagonalMatrix.CreateIdentity(order), Throws.TypeOf()); } /// @@ -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(() => matrixp.PermuteRows(permutation)); + Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException); } /// @@ -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(() => matrixp.PermuteColumns(permutation)); + Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException); } /// @@ -348,7 +348,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void DeterminantNotSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Determinant()); + Assert.That(() => matrix.Determinant(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs index 40f360e5..0ff118b2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs +++ b/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(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrix = new DenseMatrix(3, 1); - Assert.Throws(() => matrix.Cholesky()); + Assert.That(() => matrix.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs index 7341b9b8..a7fdf554 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs @@ -46,7 +46,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4))); + Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs index 4d7fcb8e..e6a22b1a 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs +++ b/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(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs index 4eff16d4..0b3b9470 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs @@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new DenseMatrix(3, 4))); + Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs index 1f3ca418..6f7336a5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs +++ b/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.Build.Random(10, 3, 1); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -206,7 +206,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization var factorSvd = matrixA.Svd(false); var vectorb = Vector.Build.Random(3, 1); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs index aa9b0f0b..4827ef9e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs +++ b/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(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrixI = new UserDefinedMatrix(3, 1); - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs index 7d87cf17..0f814d5f 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs @@ -45,7 +45,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs index 53c64f9a..e9b7de13 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs +++ b/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(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs index dedd79ee..dcc873a9 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs @@ -46,7 +46,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs index 38bb66f3..43dad8d5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs +++ b/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.Build.Random(10, 3, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization var factorSvd = matrixA.Svd(false); var vectorb = new UserDefinedVector(Vector.Build.Random(3, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs index 71688d77..48f7ebeb 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs +++ b/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 y = new DenseVector(4); - Assert.Throws(() => matrix.Multiply(x, y)); + Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException); } /// @@ -210,7 +210,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Multiply(2.3f, result)); + Assert.That(() => matrix.Multiply(2.3f, result), Throws.ArgumentException); } /// @@ -221,7 +221,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1); - Assert.Throws(() => matrix.Multiply(2.3f, result)); + Assert.That(() => matrix.Multiply(2.3f, result), Throws.ArgumentException); } /// @@ -255,7 +255,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -266,7 +266,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -344,7 +344,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -355,7 +355,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -498,7 +498,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); + Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException); } /// @@ -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 y = new DenseVector(4); - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); + Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException); } /// @@ -675,7 +675,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Wide2x3"]; var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); + Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException); } /// @@ -763,7 +763,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -774,7 +774,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -849,7 +849,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeColumns(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf()); } /// @@ -874,7 +874,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeRows(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf()); } /// @@ -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(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -991,7 +991,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [TestCase(-2)] public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { - Assert.Throws(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform())); + Assert.That(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf()); } /// @@ -1012,7 +1012,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void TraceOfNonSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Trace()); + Assert.That(() => matrix.Trace(), Throws.ArgumentException); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs index 03a14506..46749baf 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var input = new DenseVector(3); var solver = new BiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs index 2906d9a1..1fec972d 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var input = new DenseVector(3); var solver = new GpBiCg(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs index 19e291b3..ecab3c7a 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var input = new DenseVector(3); var solver = new MlkBiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs index 6421f5a6..51ce8573 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var input = new DenseVector(3); var solver = new TFQMR(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs index e7f8855d..5798f6ed 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs @@ -73,11 +73,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers }; var iterator = new Iterator(criteria); - Assert.Throws(() => iterator.DetermineStatus( + Assert.That(() => iterator.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs index 146bdcf7..9f30543b 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs +++ b/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(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } /// @@ -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(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index 3d07d396..535a96ea 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/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(() => new DivergenceStopCriterium(-0.1)); + Assert.That(() => new DivergenceStopCriterium(-0.1), Throws.TypeOf()); } /// @@ -59,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new DivergenceStopCriterium(minimumIterations: 2)); + Assert.That(() => new DivergenceStopCriterium(minimumIterations: 2), Throws.TypeOf()); } /// @@ -82,11 +82,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException() { var criterium = new DivergenceStopCriterium(0.5, 15); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/FailureStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/FailureStopCriteriumTest.cs index 98213e11..cabf9f70 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/FailureStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/FailureStopCriteriumTest.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4))); + Assert.That(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index efb4bb41..31f031bc 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/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(() => new IterationCountStopCriterium(-1)); + Assert.That(() => new IterationCountStopCriterium(-1), Throws.TypeOf()); } /// @@ -86,7 +86,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr var criterium = new IterationCountStopCriterium(10); Assert.IsNotNull(criterium, "A criterium should have been created"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index 207e0301..06468b95 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/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(() => new ResidualStopCriterium(-0.1f)); + Assert.That(() => new ResidualStopCriterium(-0.1f), Throws.TypeOf()); } /// @@ -59,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new ResidualStopCriterium(-1)); + Assert.That(() => new ResidualStopCriterium(-1), Throws.TypeOf()); } /// @@ -82,11 +82,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -97,11 +97,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(4, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -112,11 +112,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(4, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -127,11 +127,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 4), - DenseVector.Create(4, i => 4))); + DenseVector.Create(4, i => 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs index 498751d5..7528fba0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs +++ b/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(() => SparseMatrix.CreateIdentity(order)); + Assert.That(() => SparseMatrix.CreateIdentity(order), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs index ac0dc3ae..104c2388 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs @@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => SparseVector.Parse("(1")); - Assert.Throws(() => SparseVector.Parse("[1")); + Assert.That(() => SparseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => SparseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs index e1aac74d..4f1dc0a7 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs +++ b/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(() => vector.Add(0.0f, result)); + Assert.That(() => vector.Add(0.0f, result), Throws.ArgumentException); } /// @@ -108,7 +108,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other)); + Assert.That(() => vector.Add(other), Throws.ArgumentException); } /// @@ -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(() => vector.Add(other, result)); + Assert.That(() => vector.Add(other, result), Throws.ArgumentException); } /// @@ -131,7 +131,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a += b); + Assert.That(() => a += b, Throws.ArgumentException); } /// @@ -317,7 +317,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(0.0f, result)); + Assert.That(() => vector.Subtract(0.0f, result), Throws.ArgumentException); } /// @@ -328,7 +328,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other)); + Assert.That(() => vector.Subtract(other), Throws.ArgumentException); } /// @@ -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(() => vector.Subtract(other, result)); + Assert.That(() => vector.Subtract(other, result), Throws.ArgumentException); } /// @@ -351,7 +351,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a -= b); + Assert.That(() => a -= b, Throws.ArgumentException); } /// @@ -552,7 +552,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Multiply(0.0f, result)); + Assert.That(() => vector.Multiply(0.0f, result), Throws.ArgumentException); } /// @@ -563,7 +563,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Divide(0.0f, result)); + Assert.That(() => vector.Divide(0.0f, result), Throws.ArgumentException); } /// @@ -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(() => dataA.DotProduct(dataB)); + Assert.That(() => dataA.DotProduct(dataB), Throws.ArgumentException); } /// @@ -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(() => vector1.PointwiseMultiply(vector2, result)); + Assert.That(() => vector1.PointwiseMultiply(vector2, result), Throws.ArgumentException); } /// @@ -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(() => vector1.PointwiseDivide(vector2, result)); + Assert.That(() => vector1.PointwiseDivide(vector2, result), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs index d40a45ba..fefe3a91 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs @@ -211,8 +211,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void SizeIsNotPositiveThrowsArgumentOutOfRangeException() { - Assert.Throws(() => CreateVector(-1)); - Assert.Throws(() => CreateVector(0)); + Assert.That(() => CreateVector(-1), Throws.TypeOf()); + Assert.That(() => CreateVector(0), Throws.TypeOf()); } /// @@ -352,7 +352,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); - Assert.Throws(() => vector.SubVector(index, length)); + Assert.That(() => vector.SubVector(index, length), Throws.TypeOf()); } /// @@ -410,7 +410,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void FindMaximumIndexThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.MaximumIndex(); }); + Assert.That(() => { var actual = vector.MaximumIndex(); }, Throws.TypeOf()); } /// @@ -420,7 +420,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void FindMaximumThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.Maximum(); }); + Assert.That(() => { var actual = vector.Maximum(); }, Throws.TypeOf()); } /// @@ -430,7 +430,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void FindMinimumIndexThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.MinimumIndex(); }); + Assert.That(() => { var actual = vector.MinimumIndex(); }, Throws.TypeOf()); } /// @@ -440,7 +440,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void FindMinimumThrowsNotSupportedException() { var vector = CreateVector(Data); - Assert.Throws(() => { var actual = vector.Minimum(); }); + Assert.That(() => { var actual = vector.Minimum(); }, Throws.TypeOf()); } /// @@ -476,7 +476,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void SetValuesWithNullParameterThrowsArgumentException() { var vector = CreateVector(Data); - Assert.Throws(() => vector.SetValues(null)); + Assert.That(() => vector.SetValues(null), Throws.TypeOf()); } /// @@ -486,7 +486,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void SetValuesWithNonEqualDataLengthThrowsArgumentException() { var vector = CreateVector(Data.Length + 2); - Assert.Throws(() => vector.SetValues(Data)); + Assert.That(() => vector.SetValues(Data), Throws.TypeOf()); } /// @@ -495,7 +495,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void RandomWithNumberOfElementsLessThanZeroThrowsArgumentException() { - Assert.Throws(() => DenseVector.CreateRandom(-2, new ContinuousUniform())); + Assert.That(() => DenseVector.CreateRandom(-2, new ContinuousUniform()), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs index aaa19624..02289517 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs +++ b/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(() => Matrix.Build.DenseIdentity(order)); + Assert.That(() => Matrix.Build.DenseIdentity(order), Throws.TypeOf()); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs index 49fdf747..f83d2c5d 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs @@ -100,8 +100,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => DenseVector.Parse("(1")); - Assert.Throws(() => DenseVector.Parse("[1")); + Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs index 829f55a2..82c120b7 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs +++ b/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(() => Matrix.Build.DiagonalIdentity(order)); + Assert.That(() => Matrix.Build.DiagonalIdentity(order), Throws.TypeOf()); } /// @@ -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(() => matrixp.PermuteRows(permutation)); + Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException); } /// @@ -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(() => matrixp.PermuteColumns(permutation)); + Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException); } /// @@ -347,7 +347,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public void DeterminantNotSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Determinant()); + Assert.That(() => matrix.Determinant(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs index 1ae881aa..b9b6fc2b 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs @@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization { var matrixI = Matrix.Build.DenseIdentity(10); matrixI[3, 3] = -4.0; - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrix = new DenseMatrix(3, 2); - Assert.Throws(() => matrix.Cholesky()); + Assert.That(() => matrix.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs index 46758225..454821ba 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs @@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4))); + Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs index c281d3f3..c360e28c 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs +++ b/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(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs index e1bb6e93..a185457f 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs @@ -45,7 +45,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new DenseMatrix(3, 4))); + Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs index a8501414..30811477 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs +++ b/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.Build.Random(10, 10, 1); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -203,7 +203,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization var factorSvd = matrixA.Svd(false); var vectorb = Vector.Build.Random(10, 1); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs index 8bdb9216..e30af49f 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs +++ b/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(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrixI = new UserDefinedMatrix(3, 2); - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs index e3ea8a6c..39d108ee 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs @@ -43,7 +43,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs index 073c09f0..ec0d5686 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs +++ b/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(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs index db22dfe5..a35efbaa 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs @@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs index cef3a355..ccc68b24 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs +++ b/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.Build.Random(10, 10, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -202,7 +202,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization var factorSvd = matrixA.Svd(false); var vectorb = new UserDefinedVector(Vector.Build.Random(10, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs index 74293d6c..5cef153a 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs +++ b/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 y = new DenseVector(4); - Assert.Throws(() => matrix.Multiply(x, y)); + Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException); } /// @@ -204,7 +204,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Multiply(2.3, result)); + Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException); } /// @@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1); - Assert.Throws(() => matrix.Multiply(2.3, result)); + Assert.That(() => matrix.Multiply(2.3, result), Throws.ArgumentException); } /// @@ -249,7 +249,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -260,7 +260,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -338,7 +338,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -492,7 +492,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); + Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException); } /// @@ -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 y = new DenseVector(4); - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); + Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException); } /// @@ -669,7 +669,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Wide2x3"]; var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); + Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException); } /// @@ -757,7 +757,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -768,7 +768,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -843,7 +843,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeColumns(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf()); } /// @@ -868,7 +868,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeRows(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf()); } /// @@ -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(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -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(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -985,7 +985,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [TestCase(-2)] public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { - Assert.Throws(() => Matrix.Build.Random(numberOfRows, 4, new ContinuousUniform())); + Assert.That(() => Matrix.Build.Random(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf()); } /// @@ -1006,7 +1006,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public void TraceOfNonSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Trace()); + Assert.That(() => matrix.Trace(), Throws.ArgumentException); } [Test] diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs index 48aa9a85..0d00b74d 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative var input = new DenseVector(3); var solver = new BiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs index b2ae1650..57059585 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative var input = new DenseVector(3); var solver = new GpBiCg(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs index e33e21ef..3c6a3073 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/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(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative var input = new DenseVector(3); var solver = new MlkBiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs index 10ed3716..4dc42030 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative var input = new DenseVector(2); var solver = new TFQMR(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative var input = new DenseVector(3); var solver = new TFQMR(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs index a9b66d01..0382fdca 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs @@ -71,11 +71,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers }; var iterator = new Iterator(criteria); - Assert.Throws(() => iterator.DetermineStatus( + Assert.That(() => iterator.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs index 28a3bca9..1d2759d1 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs @@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit preconditioner.Initialize(newMatrix); var result = new DenseVector(vector.Count + 10); - Assert.Throws(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } /// @@ -137,7 +137,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit var vector = CreateStandardBcVector(Size); var preconditioner = CreatePreconditioner(); var result = new DenseVector(vector.Count); - Assert.Throws(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index 79f04b72..ce158300 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs @@ -48,7 +48,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite [Test] public void CreateWithNegativeMaximumIncreaseThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new DivergenceStopCriterium(-0.1)); + Assert.That(() => new DivergenceStopCriterium(-0.1), Throws.TypeOf()); } /// @@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new DivergenceStopCriterium(minimumIterations: 2)); + Assert.That(() => new DivergenceStopCriterium(minimumIterations: 2), Throws.TypeOf()); } /// @@ -80,11 +80,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException() { var criterium = new DivergenceStopCriterium(0.5, 15); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/FailureStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/FailureStopCriteriumTest.cs index 08451203..309e9210 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/FailureStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/FailureStopCriteriumTest.cs @@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4))); + Assert.That(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index a4f54af1..648480f0 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new IterationCountStopCriterium(-1)); + Assert.That(() => new IterationCountStopCriterium(-1), Throws.TypeOf()); } /// @@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite var criterium = new IterationCountStopCriterium(10); Assert.IsNotNull(criterium, "A criterium should have been created"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index 9fb44733..e17beba3 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs @@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite [Test] public void CreateWithNegativeMaximumThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new ResidualStopCriterium(-0.1)); + Assert.That(() => new ResidualStopCriterium(-0.1), Throws.TypeOf()); } /// @@ -56,7 +56,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new ResidualStopCriterium(-1)); + Assert.That(() => new ResidualStopCriterium(-1), Throws.TypeOf()); } /// @@ -79,11 +79,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -94,11 +94,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(4, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -109,11 +109,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(4, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -124,11 +124,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-8, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(4, 4))); + Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs index 849e5780..23e9fd50 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs @@ -154,7 +154,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [TestCase(-1)] public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { - Assert.Throws(() => Matrix.Build.SparseIdentity(order)); + Assert.That(() => Matrix.Build.SparseIdentity(order), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs index f396f30b..4edd092e 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs @@ -99,8 +99,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => SparseVector.Parse("(1")); - Assert.Throws(() => SparseVector.Parse("[1")); + Assert.That(() => SparseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => SparseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs index 86e94502..05119056 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs @@ -95,7 +95,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(0.0, result)); + Assert.That(() => vector.Add(0.0, result), Throws.ArgumentException); } /// @@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other)); + Assert.That(() => vector.Add(other), Throws.ArgumentException); } /// @@ -118,7 +118,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other, result)); + Assert.That(() => vector.Add(other, result), Throws.ArgumentException); } /// @@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a += b); + Assert.That(() => a += b, Throws.ArgumentException); } /// @@ -315,7 +315,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(0.0, result)); + Assert.That(() => vector.Subtract(0.0, result), Throws.ArgumentException); } /// @@ -326,7 +326,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other)); + Assert.That(() => vector.Subtract(other), Throws.ArgumentException); } /// @@ -338,7 +338,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other, result)); + Assert.That(() => vector.Subtract(other, result), Throws.ArgumentException); } /// @@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a -= b); + Assert.That(() => a -= b, Throws.ArgumentException); } /// @@ -550,7 +550,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Multiply(0.0, result)); + Assert.That(() => vector.Multiply(0.0, result), Throws.ArgumentException); } /// @@ -561,7 +561,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Divide(0.0, result)); + Assert.That(() => vector.Divide(0.0, result), Throws.ArgumentException); } /// @@ -641,7 +641,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double var dataA = CreateVector(Data); var dataB = CreateVector(new double[] { 1, 2, 3, 4, 5, 6 }); - Assert.Throws(() => dataA.DotProduct(dataB)); + Assert.That(() => dataA.DotProduct(dataB), Throws.ArgumentException); } /// @@ -708,7 +708,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double var vector1 = CreateVector(Data); var vector2 = vector1.Clone(); var result = CreateVector(vector1.Count + 1); - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); + Assert.That(() => vector1.PointwiseMultiply(vector2, result), Throws.ArgumentException); } /// @@ -751,7 +751,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double var vector1 = CreateVector(Data); var vector2 = vector1.Clone(); var result = CreateVector(vector1.Count + 1); - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); + Assert.That(() => vector1.PointwiseDivide(vector2, result), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs index 3363bdaa..4565067b 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs @@ -208,8 +208,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void SizeIsNotPositiveThrowsArgumentOutOfRangeException() { - Assert.Throws(() => CreateVector(-1)); - Assert.Throws(() => CreateVector(0)); + Assert.That(() => CreateVector(-1), Throws.TypeOf()); + Assert.That(() => CreateVector(0), Throws.TypeOf()); } /// @@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); - Assert.Throws(() => vector.SubVector(index, length)); + Assert.That(() => vector.SubVector(index, length), Throws.TypeOf()); } /// @@ -489,7 +489,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public void SetValuesWithNullParameterThrowsArgumentException() { var vector = CreateVector(Data); - Assert.Throws(() => vector.SetValues(null)); + Assert.That(() => vector.SetValues(null), Throws.TypeOf()); } /// @@ -499,7 +499,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public void SetValuesWithNonEqualDataLengthThrowsArgumentException() { var vector = CreateVector(Data.Length + 2); - Assert.Throws(() => vector.SetValues(Data)); + Assert.That(() => vector.SetValues(Data), Throws.TypeOf()); } /// @@ -508,7 +508,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void RandomWithNumberOfElementsLessThanZeroThrowsArgumentException() { - Assert.Throws(() => Vector.Build.Random(-2, new ContinuousUniform())); + Assert.That(() => Vector.Build.Random(-2, new ContinuousUniform()), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs index a21b68a8..d0c8e2ae 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs @@ -168,7 +168,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [TestCase(-1)] public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { - Assert.Throws(() => DenseMatrix.CreateIdentity(order)); + Assert.That(() => DenseMatrix.CreateIdentity(order), Throws.TypeOf()); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs index 13bdb974..f918efa8 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs @@ -100,8 +100,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => DenseVector.Parse("(1")); - Assert.Throws(() => DenseVector.Parse("[1")); + Assert.That(() => DenseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => DenseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs index eb651e9a..c28ce158 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs @@ -179,7 +179,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [TestCase(-1)] public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { - Assert.Throws(() => DiagonalMatrix.CreateIdentity(order)); + Assert.That(() => DiagonalMatrix.CreateIdentity(order), Throws.TypeOf()); } /// @@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]); var permutation = new Permutation(new[] {2, 0, 1}); - Assert.Throws(() => matrixp.PermuteRows(permutation)); + Assert.That(() => matrixp.PermuteRows(permutation), Throws.InvalidOperationException); } /// @@ -225,7 +225,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrixp = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]); var permutation = new Permutation(new[] {2, 0, 1}); - Assert.Throws(() => matrixp.PermuteColumns(permutation)); + Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException); } /// @@ -346,7 +346,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public void DeterminantNotSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Determinant()); + Assert.That(() => matrix.Determinant(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs index 3c755d05..35a48d11 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs @@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization { var matrixI = DenseMatrix.CreateIdentity(10); matrixI[3, 3] = -4.0f; - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrix = new DenseMatrix(3, 2); - Assert.Throws(() => matrix.Cholesky()); + Assert.That(() => matrix.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs index 4fe61664..174a32a4 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs @@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4))); + Assert.That(() => DenseGramSchmidt.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs index 037109ca..75189c27 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs @@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization public void LUFailsWithNonSquareMatrix() { var matrix = new DenseMatrix(3, 2); - Assert.Throws(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs index f533847f..9fea9be5 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs @@ -45,7 +45,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new DenseMatrix(3, 4))); + Assert.That(() => UserQR.Create(new DenseMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs index ebe08989..27b613af 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs @@ -190,7 +190,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization var factorSvd = matrixA.Svd(false); var matrixB = Matrix.Build.Random(10, 10, 1); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -203,7 +203,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization var factorSvd = matrixA.Svd(false); var vectorb = Vector.Build.Random(10, 1); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs index 093a22c1..1cd5a92d 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs @@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization { var matrixI = UserDefinedMatrix.Identity(10); matrixI[3, 3] = -4.0f; - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// @@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization public void CholeskyFailsWithNonSquareMatrix() { var matrixI = new UserDefinedMatrix(3, 2); - Assert.Throws(() => matrixI.Cholesky()); + Assert.That(() => matrixI.Cholesky(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs index 7c7dd1a8..87ca1caf 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs @@ -43,7 +43,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserGramSchmidt.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs index 376e4700..ea8b8f1e 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs @@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization public void LUFailsWithNonSquareMatrix() { var matrix = new UserDefinedMatrix(3, 2); - Assert.Throws(() => matrix.LU()); + Assert.That(() => matrix.LU(), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs index 14b2b192..793346c0 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs @@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization [Test] public void ConstructorWideMatrixThrowsInvalidMatrixOperationException() { - Assert.Throws(() => UserQR.Create(new UserDefinedMatrix(3, 4))); + Assert.That(() => UserQR.Create(new UserDefinedMatrix(3, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs index 47884acb..44f0f7e3 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs @@ -189,7 +189,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization var factorSvd = matrixA.Svd(false); var matrixB = new UserDefinedMatrix(Matrix.Build.Random(10, 10, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(matrixB)); + Assert.That(() => factorSvd.Solve(matrixB), Throws.InvalidOperationException); } /// @@ -202,7 +202,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization var factorSvd = matrixA.Svd(false); var vectorb = new UserDefinedVector(Vector.Build.Random(10, 1).ToArray()); - Assert.Throws(() => factorSvd.Solve(vectorb)); + Assert.That(() => factorSvd.Solve(vectorb), Throws.InvalidOperationException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs index eafb1d8c..f693dd16 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs @@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var matrix = TestMatrices["Singular3x3"]; var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f }); Vector y = new DenseVector(4); - Assert.Throws(() => matrix.Multiply(x, y)); + Assert.That(() => matrix.Multiply(x, y), Throws.ArgumentException); } /// @@ -204,7 +204,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Multiply(2.3f, result)); + Assert.That(() => matrix.Multiply(2.3f, result), Throws.ArgumentException); } /// @@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var result = CreateMatrix(matrix.RowCount, matrix.ColumnCount + 1); - Assert.Throws(() => matrix.Multiply(2.3f, result)); + Assert.That(() => matrix.Multiply(2.3f, result), Throws.ArgumentException); } /// @@ -249,7 +249,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -260,7 +260,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Add(other)); + Assert.That(() => matrix.Add(other), Throws.TypeOf()); } /// @@ -338,7 +338,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Subtract(other)); + Assert.That(() => matrix.Subtract(other), Throws.TypeOf()); } /// @@ -492,7 +492,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var other = TestMatrices["Tall3x2"]; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); + Assert.That(() => matrix.TransposeAndMultiply(other), Throws.ArgumentException); } /// @@ -626,7 +626,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var matrix = TestMatrices["Singular3x3"]; var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f }); Vector y = new DenseVector(4); - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); + Assert.That(() => matrix.TransposeThisAndMultiply(x, y), Throws.ArgumentException); } /// @@ -663,7 +663,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Wide2x3"]; var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); + Assert.That(() => matrix.TransposeThisAndMultiply(other), Throws.ArgumentException); } /// @@ -751,7 +751,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -762,7 +762,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var matrix = TestMatrices["Singular3x3"]; var target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.Negate(target)); + Assert.That(() => matrix.Negate(target), Throws.ArgumentException); } /// @@ -837,7 +837,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void NormalizeColumnsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeColumns(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeColumns(-4), Throws.TypeOf()); } /// @@ -862,7 +862,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void NormalizeRowsWithWrongParameterThrowsArgumentOutOfRangeException() { - Assert.Throws(() => TestMatrices["Square4x4"].NormalizeRows(-4)); + Assert.That(() => TestMatrices["Square4x4"].NormalizeRows(-4), Throws.TypeOf()); } /// @@ -904,7 +904,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var matrix = TestMatrices["Wide2x3"]; var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -916,7 +916,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var matrix = TestMatrices["Wide2x3"]; var other = matrix.Clone(); var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.PointwiseMultiply(other, result)); + Assert.That(() => matrix.PointwiseMultiply(other, result), Throws.ArgumentException); } /// @@ -956,7 +956,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var matrix = TestMatrices["Wide2x3"]; var other = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -968,7 +968,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var matrix = TestMatrices["Wide2x3"]; var other = matrix.Clone(); var result = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount); - Assert.Throws(() => matrix.PointwiseDivide(other, result)); + Assert.That(() => matrix.PointwiseDivide(other, result), Throws.ArgumentException); } /// @@ -979,7 +979,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [TestCase(-2)] public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { - Assert.Throws(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform())); + Assert.That(() => DenseMatrix.CreateRandom(numberOfRows, 4, new ContinuousUniform()), Throws.TypeOf()); } /// @@ -1000,7 +1000,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public void TraceOfNonSquareMatrixThrowsArgumentException() { var matrix = TestMatrices["Wide2x3"]; - Assert.Throws(() => matrix.Trace()); + Assert.That(() => matrix.Trace(), Throws.ArgumentException); } [Test] diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs index 7a53c697..ead673ab 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(2); var solver = new BiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(3); var solver = new BiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs index dba555a9..628deb2b 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(2); var solver = new GpBiCg(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(3); var solver = new GpBiCg(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs index 6f4976c4..ea7be08f 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(2); var solver = new MlkBiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(3); var solver = new MlkBiCgStab(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs index 51eaaff3..806570d7 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(2); var solver = new TFQMR(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// @@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var input = new DenseVector(3); var solver = new TFQMR(); - Assert.Throws(() => matrix.SolveIterative(input, solver)); + Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs index 0aa5ffe5..26c6caf9 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs @@ -71,11 +71,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers }; var iterator = new Iterator(criteria); - Assert.Throws(() => iterator.DetermineStatus( + Assert.That(() => iterator.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs index e1ecdca4..c66a7ee0 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs @@ -126,7 +126,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit preconditioner.Initialize(newMatrix); var result = new DenseVector(vector.Count + 10); - Assert.Throws(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } /// @@ -139,7 +139,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit var vector = CreateStandardBcVector(Size); var preconditioner = CreatePreconditioner(); var result = new DenseVector(vector.Count); - Assert.Throws(() => preconditioner.Approximate(vector, result)); + Assert.That(() => preconditioner.Approximate(vector, result), Throws.ArgumentException); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index 3a8a2b57..2a2b47e4 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs @@ -48,7 +48,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite [Test] public void CreateWithNegativeMaximumIncreaseThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new DivergenceStopCriterium(-0.1)); + Assert.That(() => new DivergenceStopCriterium(-0.1), Throws.TypeOf()); } /// @@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new DivergenceStopCriterium(minimumIterations: 2)); + Assert.That(() => new DivergenceStopCriterium(minimumIterations: 2), Throws.TypeOf()); } /// @@ -80,11 +80,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException() { var criterium = new DivergenceStopCriterium(0.5, 15); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/FailureStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/FailureStopCriteriumTest.cs index 2d0e1137..64e99e82 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/FailureStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/FailureStopCriteriumTest.cs @@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite var criterium = new FailureStopCriterium(); Assert.IsNotNull(criterium, "There should be a criterium"); - Assert.Throws(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4))); + Assert.That(() => criterium.DetermineStatus(1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 6), Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index e5a4c403..1ebbc06c 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new IterationCountStopCriterium(-1)); + Assert.That(() => new IterationCountStopCriterium(-1), Throws.TypeOf()); } /// @@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite var criterium = new IterationCountStopCriterium(10); Assert.IsNotNull(criterium, "A criterium should have been created"); - Assert.Throws(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3))); + Assert.That(() => criterium.DetermineStatus(-1, Vector.Build.Dense(3, 1), Vector.Build.Dense(3, 2), Vector.Build.Dense(3, 3)), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index d8d468bb..0b206c14 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs @@ -48,7 +48,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite [Test] public void CreateWithNegativeMaximumThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new ResidualStopCriterium(-0.1f)); + Assert.That(() => new ResidualStopCriterium(-0.1f), Throws.TypeOf()); } /// @@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite [Test] public void CreateWithIllegalMinimumIterationsThrowsArgumentOutOfRangeException() { - Assert.Throws(() => new ResidualStopCriterium(-1)); + Assert.That(() => new ResidualStopCriterium(-1), Throws.TypeOf()); } /// @@ -80,11 +80,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( -1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 5), - Vector.Build.Dense(3, 6))); + Vector.Build.Dense(3, 6)), Throws.TypeOf()); } /// @@ -95,11 +95,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(4, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -110,11 +110,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(4, 4), - Vector.Build.Dense(3, 4))); + Vector.Build.Dense(3, 4)), Throws.ArgumentException); } /// @@ -125,11 +125,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { var criterium = new ResidualStopCriterium(1e-6f, 50); - Assert.Throws(() => criterium.DetermineStatus( + Assert.That(() => criterium.DetermineStatus( 1, Vector.Build.Dense(3, 4), Vector.Build.Dense(3, 4), - Vector.Build.Dense(4, 4))); + Vector.Build.Dense(4, 4)), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs index 5511c6e4..8e2b685b 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs @@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [TestCase(-1)] public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { - Assert.Throws(() => SparseMatrix.CreateIdentity(order)); + Assert.That(() => SparseMatrix.CreateIdentity(order), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs index 603846d0..30386410 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs @@ -99,8 +99,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void ParseIfMissingClosingParenThrowsFormatException() { - Assert.Throws(() => SparseVector.Parse("(1")); - Assert.Throws(() => SparseVector.Parse("[1")); + Assert.That(() => SparseVector.Parse("(1"), Throws.TypeOf()); + Assert.That(() => SparseVector.Parse("[1"), Throws.TypeOf()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs index ddfeec60..ac0d9c01 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs @@ -95,7 +95,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(0.0f, result)); + Assert.That(() => vector.Add(0.0f, result), Throws.ArgumentException); } /// @@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other)); + Assert.That(() => vector.Add(other), Throws.ArgumentException); } /// @@ -118,7 +118,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other, result)); + Assert.That(() => vector.Add(other, result), Throws.ArgumentException); } /// @@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a += b); + Assert.That(() => a += b, Throws.ArgumentException); } /// @@ -315,7 +315,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(0.0f, result)); + Assert.That(() => vector.Subtract(0.0f, result), Throws.ArgumentException); } /// @@ -326,7 +326,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other)); + Assert.That(() => vector.Subtract(other), Throws.ArgumentException); } /// @@ -338,7 +338,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var vector = CreateVector(Data.Length); var other = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other, result)); + Assert.That(() => vector.Subtract(other, result), Throws.ArgumentException); } /// @@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var a = CreateVector(Data.Length); var b = CreateVector(Data.Length + 1); - Assert.Throws(() => a -= b); + Assert.That(() => a -= b, Throws.ArgumentException); } /// @@ -550,7 +550,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Multiply(0.0f, result)); + Assert.That(() => vector.Multiply(0.0f, result), Throws.ArgumentException); } /// @@ -561,7 +561,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var vector = CreateVector(Data.Length); var result = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Divide(0.0f, result)); + Assert.That(() => vector.Divide(0.0f, result), Throws.ArgumentException); } /// @@ -641,7 +641,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var dataA = CreateVector(Data); var dataB = CreateVector(new float[] { 1, 2, 3, 4, 5, 6 }); - Assert.Throws(() => dataA.DotProduct(dataB)); + Assert.That(() => dataA.DotProduct(dataB), Throws.ArgumentException); } /// @@ -708,7 +708,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var vector1 = CreateVector(Data); var vector2 = vector1.Clone(); var result = CreateVector(vector1.Count + 1); - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); + Assert.That(() => vector1.PointwiseMultiply(vector2, result), Throws.ArgumentException); } /// @@ -751,7 +751,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var vector1 = CreateVector(Data); var vector2 = vector1.Clone(); var result = CreateVector(vector1.Count + 1); - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); + Assert.That(() => vector1.PointwiseDivide(vector2, result), Throws.ArgumentException); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs index 88cd7ee4..f51cee7a 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs @@ -208,8 +208,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void SizeIsNotPositiveThrowsArgumentOutOfRangeException() { - Assert.Throws(() => CreateVector(-1)); - Assert.Throws(() => CreateVector(0)); + Assert.That(() => CreateVector(-1), Throws.TypeOf()); + Assert.That(() => CreateVector(0), Throws.TypeOf()); } /// @@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); - Assert.Throws(() => vector.SubVector(index, length)); + Assert.That(() => vector.SubVector(index, length), Throws.TypeOf()); } /// @@ -489,7 +489,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public void SetValuesWithNullParameterThrowsArgumentException() { var vector = CreateVector(Data); - Assert.Throws(() => vector.SetValues(null)); + Assert.That(() => vector.SetValues(null), Throws.TypeOf()); } /// @@ -499,7 +499,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public void SetValuesWithNonEqualDataLengthThrowsArgumentException() { var vector = CreateVector(Data.Length + 2); - Assert.Throws(() => vector.SetValues(Data)); + Assert.That(() => vector.SetValues(Data), Throws.TypeOf()); } /// @@ -508,7 +508,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void RandomWithNumberOfElementsLessThanZeroThrowsArgumentException() { - Assert.Throws(() => DenseVector.CreateRandom(-2, new ContinuousUniform())); + Assert.That(() => DenseVector.CreateRandom(-2, new ContinuousUniform()), Throws.TypeOf()); } /// diff --git a/src/UnitTests/PermutationTest.cs b/src/UnitTests/PermutationTest.cs index c87dfccf..9a995a38 100644 --- a/src/UnitTests/PermutationTest.cs +++ b/src/UnitTests/PermutationTest.cs @@ -58,7 +58,7 @@ namespace MathNet.Numerics.UnitTests [TestCase(new[] { 5, 4, 3, 2, 1, 7 })] public void CreatePermutationFailsWhenGivenBadIndexSet(int[] idx) { - Assert.Throws(() => new Permutation(idx)); + Assert.That(() => new Permutation(idx), Throws.ArgumentException); } /// diff --git a/src/UnitTests/PrecisionTest.cs b/src/UnitTests/PrecisionTest.cs index 604dfa10..5e355e8c 100644 --- a/src/UnitTests/PrecisionTest.cs +++ b/src/UnitTests/PrecisionTest.cs @@ -281,7 +281,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void RangeOfMatchingFloatingPointNumbersWithNegativeUlps() { - Assert.Throws(() => Precision.RangeOfMatchingFloatingPointNumbers(10, -1)); + Assert.That(() => Precision.RangeOfMatchingFloatingPointNumbers(10, -1), Throws.TypeOf()); } /// @@ -442,7 +442,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void RangeOfMatchingUlpsWithNegativeRelativeDifferenceThrows() { - Assert.Throws(() => 1d.RangeOfMatchingNumbers(-1d)); + Assert.That(() => 1d.RangeOfMatchingNumbers(-1d), Throws.TypeOf()); } /// @@ -451,7 +451,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void RangeOfMatchingUlpsWithValueAtInfinityThrows() { - Assert.Throws(() => double.PositiveInfinity.RangeOfMatchingNumbers(-1d)); + Assert.That(() => double.PositiveInfinity.RangeOfMatchingNumbers(-1d), Throws.TypeOf()); } /// @@ -460,7 +460,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void RangeOfMatchingUlpsWithValueAtNaNThrows() { - Assert.Throws(() => double.NaN.RangeOfMatchingNumbers(-1d)); + Assert.That(() => double.NaN.RangeOfMatchingNumbers(-1d), Throws.TypeOf()); } /// @@ -537,7 +537,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void AlmostEqualWithMaxNumbersBetweenWithLessThanOneNumberThrows() { - Assert.Throws(() => Precision.AlmostEqualNumbersBetween(1, 2, 0)); + Assert.That(() => Precision.AlmostEqualNumbersBetween(1, 2, 0), Throws.TypeOf()); } [Test] @@ -751,7 +751,7 @@ namespace MathNet.Numerics.UnitTests [Test] public void AlmostEqualRelativeDecimalPlacesWithNegativeDecimalPlacesThrows() { - Assert.Throws(() => Precision.AlmostEqualRelative(1, 2, -1)); + Assert.That(() => Precision.AlmostEqualRelative(1, 2, -1), Throws.TypeOf()); Assert.DoesNotThrow(() => Precision.AlmostEqual(1, 2, -1)); } @@ -991,7 +991,7 @@ namespace MathNet.Numerics.UnitTests public void CompareToWithMaxNumbersBetweenWithNegativeNumberThrows() { const double Value = 10.0; - Assert.Throws(() => Value.CompareToNumbersBetween(Value, -1)); + Assert.That(() => Value.CompareToNumbersBetween(Value, -1), Throws.TypeOf()); } /// @@ -1001,7 +1001,7 @@ namespace MathNet.Numerics.UnitTests public void CompareToWithMaxNumbersBetweenWithZeroNumberThrows() { const double Value = 10.0; - Assert.Throws(() => Value.CompareToNumbersBetween(Value, 0)); + Assert.That(() => Value.CompareToNumbersBetween(Value, 0), Throws.TypeOf()); } /// diff --git a/src/UnitTests/Random/PalfTests.cs b/src/UnitTests/Random/PalfTests.cs index bf0147d1..5f24ba59 100644 --- a/src/UnitTests/Random/PalfTests.cs +++ b/src/UnitTests/Random/PalfTests.cs @@ -53,7 +53,7 @@ namespace MathNet.Numerics.UnitTests.Random [Test] public void ThrowsArgumentExceptionWhenShortLagIsNonPositive() { - Assert.Throws(() => new Palf(1, true, 0, 10)); + Assert.That(() => new Palf(1, true, 0, 10), Throws.ArgumentException); } /// @@ -62,7 +62,7 @@ namespace MathNet.Numerics.UnitTests.Random [Test] public void ThrowsArgumentExceptionWhenLongLagIsNotGreaterThanShortLag() { - Assert.Throws(() => new Palf(1, true, 10, 10)); + Assert.That(() => new Palf(1, true, 10, 10), Throws.ArgumentException); } [Test] diff --git a/src/UnitTests/RootFindingTests/BisectionTest.cs b/src/UnitTests/RootFindingTests/BisectionTest.cs index 4fdd920a..b095729e 100644 --- a/src/UnitTests/RootFindingTests/BisectionTest.cs +++ b/src/UnitTests/RootFindingTests/BisectionTest.cs @@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests public void NoRoot() { Func f1 = x => x * x + 4; - Assert.Throws(() => Bisection.FindRoot(f1, -5, 5, 1e-14)); + Assert.That(() => Bisection.FindRoot(f1, -5, 5, 1e-14), Throws.TypeOf()); } [Test] diff --git a/src/UnitTests/RootFindingTests/BrentTest.cs b/src/UnitTests/RootFindingTests/BrentTest.cs index 9a60b5d4..5ac9a8ad 100644 --- a/src/UnitTests/RootFindingTests/BrentTest.cs +++ b/src/UnitTests/RootFindingTests/BrentTest.cs @@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests public void NoRoot() { Func f1 = x => x * x + 4; - Assert.Throws(() => Brent.FindRoot(f1, -5, 5, 1e-14, 50)); + Assert.That(() => Brent.FindRoot(f1, -5, 5, 1e-14, 50), Throws.TypeOf()); } [Test] @@ -153,7 +153,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests // Test case from http://www.polymath-software.com/library/nle/Oneeq3.htm // not solvable with this method Func f1 = T => Math.Exp(21000 / T) / (T * T) - 1.11e11; - Assert.Throws(() => Brent.FindRoot(f1, 550, 560, 1e-2)); + Assert.That(() => Brent.FindRoot(f1, 550, 560, 1e-2), Throws.TypeOf()); } [Test] @@ -213,7 +213,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return R * T / V + Beta / (V * V) + Gama / (V * V * V) + Delta / (V * V * V * V) - P; }; - Assert.Throws(() => Brent.FindRoot(f1, 0.1, 1)); + Assert.That(() => Brent.FindRoot(f1, 0.1, 1), Throws.TypeOf()); } [Test] @@ -248,7 +248,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests // Test case from http://www.polymath-software.com/library/nle/Oneeq7.htm // not solvable with this method Func f1 = x => x / (1 - x) - 5 * Math.Log(0.4 * (1 - x) / (0.4 - 0.5 * x)) + 4.45977; - Assert.Throws(() => Brent.FindRoot(f1, 0, 0.79, 1e-2)); + Assert.That(() => Brent.FindRoot(f1, 0, 0.79, 1e-2), Throws.TypeOf()); } [Test] @@ -265,7 +265,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return a * v * v + b * Math.Pow(v, 7 / 4) - c; }; - Assert.Throws(() => Brent.FindRoot(f1, 0.01, 1, 1e-2)); + Assert.That(() => Brent.FindRoot(f1, 0.01, 1, 1e-2), Throws.TypeOf()); } [Test] diff --git a/src/UnitTests/RootFindingTests/BroydenTest.cs b/src/UnitTests/RootFindingTests/BroydenTest.cs index 652e7c61..c2c846e4 100644 --- a/src/UnitTests/RootFindingTests/BroydenTest.cs +++ b/src/UnitTests/RootFindingTests/BroydenTest.cs @@ -63,8 +63,8 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests { // Method cannot get out of local minima. Func f1 = x => x * x * x - 2 * x + 2; - Assert.Throws(() => BroydenFindRoot(f1, -5, 5, 1e-14)); - Assert.Throws(() => BroydenFindRoot(f1, -2, 4, 1e-14)); + Assert.That(() => BroydenFindRoot(f1, -5, 5, 1e-14), Throws.TypeOf()); + Assert.That(() => BroydenFindRoot(f1, -2, 4, 1e-14), Throws.TypeOf()); Assert.AreEqual(0, f1(BroydenFindRoot(f1, -2, -1, 1e-14)), 1e-14); } @@ -72,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests public void NoRoot() { Func f1 = x => x * x + 4; - Assert.Throws(() => BroydenFindRoot(f1, -5, 5, 1e-14)); + Assert.That(() => BroydenFindRoot(f1, -5, 5, 1e-14), Throws.TypeOf()); } [Test] @@ -201,7 +201,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return R * T / V + Beta / (V * V) + Gama / (V * V * V) + Delta / (V * V * V * V) - P; }; - Assert.Throws(() => BroydenFindRoot(f1, 0.1, 1)); + Assert.That(() => BroydenFindRoot(f1, 0.1, 1), Throws.TypeOf()); } [Test] @@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests // Test case from http://www.polymath-software.com/library/nle/Oneeq7.htm // not solvable with this method Func f1 = x => x / (1 - x) - 5 * Math.Log(0.4 * (1 - x) / (0.4 - 0.5 * x)) + 4.45977; - Assert.Throws(() => BroydenFindRoot(f1, 0, 0.79, 1e-2)); + Assert.That(() => BroydenFindRoot(f1, 0, 0.79, 1e-2), Throws.TypeOf()); } [Test] @@ -286,7 +286,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests // method fails if started too far away from the root Func f1 = x => (1.0 / 63.0) * Math.Log(x) + (64.0 / 63.0) * Math.Log(1 / (1 - x)) + Math.Log(0.95 - x) - Math.Log(0.9); - Assert.Throws(() => BroydenFindRoot(f1, .01, 0.35)); + Assert.That(() => BroydenFindRoot(f1, .01, 0.35), Throws.TypeOf()); double r = BroydenFindRoot(f1, .01, 0.04, 1e-14); Assert.AreEqual(0.036210083704, r, 1e-5); Assert.AreEqual(0, f1(r), 1e-14); @@ -480,7 +480,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests // method fails if started too far away from the root Func f1 = rp => rp - 0.327 * Math.Pow(0.06 - 161 * rp, 0.804) * Math.Exp(-5230 / (1.987 * (373 + 1.84e6 * rp))); - Assert.Throws(() => BroydenFindRoot(f1, 0, 0.00035)); + Assert.That(() => BroydenFindRoot(f1, 0, 0.00035), Throws.TypeOf()); double x = BroydenFindRoot(f1, 0.0003, 0.00035, 1e-14); Assert.AreEqual(0.000340568862275, x, 1e-5); Assert.AreEqual(0, f1(x), 1e-14); @@ -604,7 +604,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return z * z * z - z * z - Q * z - r; }; - Assert.Throws(() => BroydenFindRoot(f1, -0.5, 1.2)); + Assert.That(() => BroydenFindRoot(f1, -0.5, 1.2), Throws.TypeOf()); double x = BroydenFindRoot(f1, 0.5, 1.2, 1e-14); Assert.AreEqual(1.06831213384200, x, 1e-7); Assert.AreEqual(0, f1(x), 1e-14); @@ -629,7 +629,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return -ra / FA0; }; - Assert.Throws(() => BroydenFindRoot(f1, 0.75, 1.02)); + Assert.That(() => BroydenFindRoot(f1, 0.75, 1.02), Throws.TypeOf()); double x = BroydenFindRoot(f1, 0.98, 1.02, 1e-14); Assert.AreEqual(0.999251497006000, x, 1e-3); Assert.AreEqual(0, f1(x), 1e-14); @@ -697,7 +697,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return -tg * sg * al + tl * sl * ag - ti * si * (al + ag) + d * (rol - rog) * al * ag * g; }; - Assert.Throws(() => BroydenFindRoot(f1, 0, 0.3)); + Assert.That(() => BroydenFindRoot(f1, 0, 0.3), Throws.TypeOf()); double x = BroydenFindRoot(f1, 0, 0.01, 1e-14); Assert.AreEqual(0.00596133169486, x, 1e-5); Assert.AreEqual(0, f1(x), 1e-14); @@ -743,7 +743,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return -tg * sg * al + tl * sl * ag - ti * si * (al + ag) + d * (rol - rog) * al * ag * g; }; - Assert.Throws(() => BroydenFindRoot(f1, 0, 0.1)); + Assert.That(() => BroydenFindRoot(f1, 0, 0.1), Throws.TypeOf()); double x = BroydenFindRoot(f1, 0, 0.01, 1e-14); Assert.AreEqual(0.00602268958797, x, 1e-5); Assert.AreEqual(0, f1(x), 1e-14); @@ -1704,7 +1704,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return new double[6] { fCA, fCB, fCC, fCD, fCE, fT }; }; - Assert.Throws(() => Broyden.FindRoot(fa1, new double[6] { 0.5, 0.01, 1, 0.01, 1, 420 }, 1e1)); + Assert.That(() => Broyden.FindRoot(fa1, new double[6] { 0.5, 0.01, 1, 0.01, 1, 420 }, 1e1), Throws.TypeOf()); } [Test] @@ -2140,7 +2140,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return new double[10] { fx1, fx2, fx3, fx4, fx5, fx6, fx7, fx8, fx9, fx10 }; }; - Assert.Throws(() => Broyden.FindRoot(fa1, new double[10] { 1, 1, 10, 1, 1, 1, 0, 0, 0, 0 }, 1e-1)); + Assert.That(() => Broyden.FindRoot(fa1, new double[10] { 1, 1, 10, 1, 1, 1, 0, 0, 0, 0 }, 1e-1), Throws.TypeOf()); double[] r = Broyden.FindRoot(fa1, new double[10] { 3, 4, 20, 0.1, 0.1, 0.01, 0.01, 0.01, 0.1, 0.001 }, 1e-14); Assert.AreEqual(2.88010599840556, r[0], 1e-5); Assert.AreEqual(3.95067493980017, r[1], 1e-5); @@ -2196,7 +2196,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return new double[10] { fx1, fx2, fx3, fx4, fx5, fx6, fx7, fx8, fx9, fx10 }; }; - Assert.Throws(() => Broyden.FindRoot(fa1, new double[10] { 2, 5, 80, 1, 0, 0, 0, 0, 20, 5 }, 1e-5)); + Assert.That(() => Broyden.FindRoot(fa1, new double[10] { 2, 5, 80, 1, 0, 0, 0, 0, 20, 5 }, 1e-5), Throws.TypeOf()); double[] r = Broyden.FindRoot(fa1, new double[10] { 3, 4, 80, 0.001, 0.001, 0.001, 0.01, 4, 26, 0.01 }, 1e-14); Assert.AreEqual(2.99763549788728, r[0], 1e-5); Assert.AreEqual(3.96642685827836, r[1], 1e-5); @@ -2259,7 +2259,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return new double[10] { fn1, fn2, fn3, fn4, fn5, fn6, fn7, fn8, fn9, fn10 }; }; - Assert.Throws(() => Broyden.FindRoot(fa1, new double[10] { 1.5, 2, 35, 0.5, 0.05, 0.005, 0.04, 0.003, 0.02, 5 }, 1e-5)); + Assert.That(() => Broyden.FindRoot(fa1, new double[10] { 1.5, 2, 35, 0.5, 0.05, 0.005, 0.04, 0.003, 0.02, 5 }, 1e-5), Throws.TypeOf()); double[] r = Broyden.FindRoot(fa1, new double[10] { 3, 4, 20, 0.1, 0.01, 0.001, 0.04, 0.003, 0.03, 0.03 }, 1e-14); Assert.AreEqual(2.91572542389522, r[0], 1e-5); Assert.AreEqual(3.96094281080888, r[1], 1e-5); @@ -2322,7 +2322,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests return new double[10] { fn1, fn2, fn3, fn4, fn5, fn6, fn7, fn8, fn9, fn10 }; }; - Assert.Throws(() => Broyden.FindRoot(fa1, new double[10] { 1.5, 2, 35, 0.5, 0.05, 0.005, 0.04, 0.003, 0.02, 5 }, 1e-5)); + Assert.That(() => Broyden.FindRoot(fa1, new double[10] { 1.5, 2, 35, 0.5, 0.05, 0.005, 0.04, 0.003, 0.02, 5 }, 1e-5), Throws.TypeOf()); double[] r = Broyden.FindRoot(fa1, new double[10] { 3, 4, 80, 0.01, 0.002, 0.0006, 0.1, 0.004, 0.1, 15 }, 1e-14); //Assert.AreEqual(2.91572542389522, r[0], 1e-5); //Assert.AreEqual(3.96094281080888, r[1], 1e-5); diff --git a/src/UnitTests/RootFindingTests/FindRootsTest.cs b/src/UnitTests/RootFindingTests/FindRootsTest.cs index 7355f0bf..8c54d708 100644 --- a/src/UnitTests/RootFindingTests/FindRootsTest.cs +++ b/src/UnitTests/RootFindingTests/FindRootsTest.cs @@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests public void NoRoot() { Func f1 = x => x * x + 4; - Assert.Throws(() => FindRoots.OfFunction(f1, -5, 5, 1e-14)); + Assert.That(() => FindRoots.OfFunction(f1, -5, 5, 1e-14), Throws.TypeOf()); } [Test] diff --git a/src/UnitTests/RootFindingTests/NewtonRaphsonTest.cs b/src/UnitTests/RootFindingTests/NewtonRaphsonTest.cs index 32ac7e32..59768684 100644 --- a/src/UnitTests/RootFindingTests/NewtonRaphsonTest.cs +++ b/src/UnitTests/RootFindingTests/NewtonRaphsonTest.cs @@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests { Func f1 = x => x * x + 4; Func df1 = x => 2 * x; - Assert.Throws(() => NewtonRaphson.FindRoot(f1, df1, -5, 5, 1e-14, 50)); + Assert.That(() => NewtonRaphson.FindRoot(f1, df1, -5, 5, 1e-14, 50), Throws.TypeOf()); } } } diff --git a/src/UnitTests/RootFindingTests/RobustNewtonRaphsonTest.cs b/src/UnitTests/RootFindingTests/RobustNewtonRaphsonTest.cs index 4986898f..a6f34460 100644 --- a/src/UnitTests/RootFindingTests/RobustNewtonRaphsonTest.cs +++ b/src/UnitTests/RootFindingTests/RobustNewtonRaphsonTest.cs @@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests { Func f1 = x => x * x + 4; Func df1 = x => 2 * x; - Assert.Throws(() => RobustNewtonRaphson.FindRoot(f1, df1, -5, 5, 1e-14, 50, 20)); + Assert.That(() => RobustNewtonRaphson.FindRoot(f1, df1, -5, 5, 1e-14, 50, 20), Throws.TypeOf()); } } } diff --git a/src/UnitTests/SpecialFunctionsTests/FactorialTest.cs b/src/UnitTests/SpecialFunctionsTests/FactorialTest.cs index bd4752ea..6b81bf20 100644 --- a/src/UnitTests/SpecialFunctionsTests/FactorialTest.cs +++ b/src/UnitTests/SpecialFunctionsTests/FactorialTest.cs @@ -69,9 +69,9 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests [Test] public void ThrowsOnNegativeArgument() { - Assert.Throws(() => SpecialFunctions.Factorial(Int32.MinValue)); - Assert.Throws(() => SpecialFunctions.Factorial(-1)); - Assert.Throws(() => SpecialFunctions.FactorialLn(-1)); + Assert.That(() => SpecialFunctions.Factorial(Int32.MinValue), Throws.TypeOf()); + Assert.That(() => SpecialFunctions.Factorial(-1), Throws.TypeOf()); + Assert.That(() => SpecialFunctions.FactorialLn(-1), Throws.TypeOf()); } /// diff --git a/src/UnitTests/StatisticsTests/CorrelationTests.cs b/src/UnitTests/StatisticsTests/CorrelationTests.cs index 329f1ab5..bc34cbcf 100644 --- a/src/UnitTests/StatisticsTests/CorrelationTests.cs +++ b/src/UnitTests/StatisticsTests/CorrelationTests.cs @@ -97,7 +97,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests { var dataA = _data["lottery"].Data; var dataB = _data["lew"].Data; - Assert.Throws(() => Correlation.Pearson(dataA, dataB)); + Assert.That(() => Correlation.Pearson(dataA, dataB), Throws.TypeOf()); } /// @@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests { var dataA = _data["lottery"].Data; var dataB = _data["lew"].Data; - Assert.Throws(() => Correlation.Spearman(dataA, dataB)); + Assert.That(() => Correlation.Spearman(dataA, dataB), Throws.TypeOf()); } } #endif diff --git a/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs b/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs index bfe0dcc2..b99e2eb3 100644 --- a/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs +++ b/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs @@ -74,10 +74,10 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests const IEnumerable Data = null; const IEnumerable NullableData = null; - Assert.Throws(() => new DescriptiveStatistics(Data)); - Assert.Throws(() => new DescriptiveStatistics(Data, true)); - Assert.Throws(() => new DescriptiveStatistics(NullableData)); - Assert.Throws(() => new DescriptiveStatistics(NullableData, true)); + Assert.That(() => new DescriptiveStatistics(Data), Throws.TypeOf()); + Assert.That(() => new DescriptiveStatistics(Data, true), Throws.TypeOf()); + Assert.That(() => new DescriptiveStatistics(NullableData), Throws.TypeOf()); + Assert.That(() => new DescriptiveStatistics(NullableData, true), Throws.TypeOf()); } /// diff --git a/src/UnitTests/StatisticsTests/HistogramTests.cs b/src/UnitTests/StatisticsTests/HistogramTests.cs index 8752fac2..d2c48273 100644 --- a/src/UnitTests/StatisticsTests/HistogramTests.cs +++ b/src/UnitTests/StatisticsTests/HistogramTests.cs @@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests [Test] public void EmptyBucketWithBadBoundsFails() { - Assert.Throws(() => new Bucket(1.0, 0.5)); + Assert.That(() => new Bucket(1.0, 0.5), Throws.TypeOf()); } /// @@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests [Test] public void EmptyBucketWithBadCountFails() { - Assert.Throws(() => new Bucket(1.0, 0.5, -1.0)); + Assert.That(() => new Bucket(1.0, 0.5, -1.0), Throws.TypeOf()); } /// @@ -189,8 +189,8 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests h.AddBucket(new Bucket(2.0, 3.0)); h.AddBucket(new Bucket(3.0, 20.0)); h.AddBucket(new Bucket(20.0, Double.PositiveInfinity)); - Assert.Throws(() => { var i = h.GetBucketIndexOf(0.0); }); - Assert.Throws(() => { var i = h.GetBucketIndexOf(-1.0); }); + Assert.That(() => { var i = h.GetBucketIndexOf(0.0); }, Throws.ArgumentException); + Assert.That(() => { var i = h.GetBucketIndexOf(-1.0); }, Throws.ArgumentException); } /// @@ -276,7 +276,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests [Test] public void FailCreateEqualSpacedHistogramWithNoData() { - Assert.Throws(() => new Histogram(new List(), 10)); + Assert.That(() => new Histogram(new List(), 10), Throws.ArgumentException); } /// diff --git a/src/UnitTests/StatisticsTests/MCMCTests/MCMCDiagnosticsTest.cs b/src/UnitTests/StatisticsTests/MCMCTests/MCMCDiagnosticsTest.cs index 75b9edee..69cf31f6 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/MCMCDiagnosticsTest.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/MCMCDiagnosticsTest.cs @@ -98,7 +98,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests { const int length = 10; var series = new double[length]; - Assert.Throws(() => MCMCDiagnostics.ACF(series, 11, x=>x)); + Assert.That(() => MCMCDiagnostics.ACF(series, 11, x=>x), Throws.TypeOf()); } /// @@ -107,7 +107,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests [Test] public void LagNegative() { - Assert.Throws(() => MCMCDiagnostics.ACF(new double[10], -1, x=>x)); + Assert.That(() => MCMCDiagnostics.ACF(new double[10], -1, x=>x), Throws.TypeOf()); } /// diff --git a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs index 896a4126..a04a3742 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs @@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests var random = MersenneTwister.Default; var normal = new Normal(0.0, 1.0, random); var ms = new MetropolisHastingsSampler(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(random, x, 0.1), 10); - Assert.Throws(() => ms.RandomSource = null); + Assert.That(() => ms.RandomSource = null, Throws.TypeOf()); } } } diff --git a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs index c6d6756e..a7d00911 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs @@ -102,7 +102,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests { var normal = new Normal(0.0, 1.0); var ms = new MetropolisSampler(0.2, normal.Density, x => Normal.Sample(new Random(0), x, 0.1), 10); - Assert.Throws(() => ms.RandomSource = null); + Assert.That(() => ms.RandomSource = null, Throws.TypeOf()); } } } diff --git a/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs index 1b2f8084..13569a37 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs @@ -96,7 +96,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests { var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1)); var rs = new RejectionSampler(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample); - Assert.Throws(() => rs.Sample()); + Assert.That(() => rs.Sample(), Throws.TypeOf()); } /// @@ -107,7 +107,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests { var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1)); var rs = new RejectionSampler(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample); - Assert.Throws(() => rs.RandomSource = null); + Assert.That(() => rs.RandomSource = null, Throws.TypeOf()); } } } diff --git a/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs index 49fa32fe..01fc4471 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs @@ -88,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests [Test] public void InvalidScale() { - Assert.Throws(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, 5, -1.0)); + Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, 5, -1.0), Throws.TypeOf()); } /// @@ -97,7 +97,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests [Test] public void InvalidBurn() { - Assert.Throws(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, -5, 1.0)); + Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, -5, 1.0), Throws.TypeOf()); } } }