Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilProfileTransformerTest.cs =================================================================== diff -u -r74be63b9f6ac8bc60a6754667a3bcee0485853a0 -r30baf70ea42def18e66d1ec3c71aa0e54a89229a --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilProfileTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilProfileTransformerTest.cs) (revision 74be63b9f6ac8bc60a6754667a3bcee0485853a0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilProfileTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilProfileTransformerTest.cs) (revision 30baf70ea42def18e66d1ec3c71aa0e54a89229a) @@ -22,10 +22,11 @@ using System; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.TestUtil; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.IO.SoilProfiles; -using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.IO.Test.SoilProfiles { @@ -57,7 +58,7 @@ var soilProfile = mocks.Stub(); mocks.ReplayAll(); - var stochasticSoilProfile = new StochasticSoilProfile(0, soilProfile); + StochasticSoilProfile stochasticSoilProfile = StochasticSoilProfileTestFactory.CreateStochasticSoilProfileWithValidProbability(soilProfile); // Call TestDelegate call = () => MacroStabilityInwardsStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, null); @@ -68,17 +69,43 @@ mocks.VerifyAll(); } + [Test] + [TestCase(double.NaN)] + [TestCase(1.1)] + [TestCase(-0.1)] + public void Transform_StochasticSoilProfileWithInvalidProbability_ThrowsImportedDataTransformException(double probability) + { + // Setup + var mocks = new MockRepository(); + var soilProfile = mocks.Stub(); + var macroStabilityInwardsSoilProfile = mocks.Stub(); + mocks.ReplayAll(); + var stochasticSoilProfile = new StochasticSoilProfile(probability, soilProfile); + + // Call + TestDelegate call = () => MacroStabilityInwardsStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, macroStabilityInwardsSoilProfile); + + // Assert + var exception = Assert.Throws(call); + + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + [Test] public void Transform_ValidData_ReturnExpectedMacroStabilityInwardsStochasticSoilProfile() { // Setup + var random = new Random(21); + var mocks = new MockRepository(); var soilProfile = mocks.Stub(); var macroStabilityInwardsSoilProfile = mocks.Stub(); mocks.ReplayAll(); - var stochasticSoilProfile = new StochasticSoilProfile(new Random(9).NextDouble(), soilProfile); + var stochasticSoilProfile = new StochasticSoilProfile(random.NextDouble(), soilProfile); // Call MacroStabilityInwardsStochasticSoilProfile macroStabilityInwardsStochasticSoilProfile