Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Contribution/FailureMechanismContributionTest.cs =================================================================== diff -u -recf136a787efcd5d3f171f8aee8930f84a89e80a -r753480c9461b7b5bb10eb7abe78224f24160a536 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Contribution/FailureMechanismContributionTest.cs (.../FailureMechanismContributionTest.cs) (revision ecf136a787efcd5d3f171f8aee8930f84a89e80a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Contribution/FailureMechanismContributionTest.cs (.../FailureMechanismContributionTest.cs) (revision 753480c9461b7b5bb10eb7abe78224f24160a536) @@ -49,7 +49,7 @@ // Setup var random = new Random(21); var contribution = random.Next(1, 100); - var norm = random.Next(1, int.MaxValue); + var norm = random.NextDouble(); // Call TestDelegate test = () => new FailureMechanismContribution(null, contribution, norm); @@ -65,7 +65,7 @@ // Setup var random = new Random(21); var contribution = random.Next(1, 100); - var norm = random.Next(1, int.MaxValue); + var norm = random.NextDouble(); // Call TestDelegate test = () => new FailureMechanismContribution(new IFailureMechanism[] @@ -79,10 +79,8 @@ } [Test] - [TestCase(0)] - [TestCase(-1)] - [TestCase(-200)] - public void Constructor_WithInvalidNorm_ThrowsArgumentOutOfRangeException(int norm) + public void Constructor_WithInvalidNorm_ThrowsArgumentOutOfRangeException( + [Values(-1e-6, -150)] double norm) { // Setup var random = new Random(21); @@ -105,13 +103,13 @@ { // Setup var random = new Random(21); - var norm = random.Next(1, int.MaxValue); + var norm = random.NextDouble(); // Call TestDelegate test = () => new FailureMechanismContribution(Enumerable.Empty(), contribution, norm); // Assert - var expectedMessage = Resources.Contribution_Value_should_be_in_interval_0_100; + const string expectedMessage = "De waarde voor de toegestane bijdrage aan de faalkans moet in het bereik [0, 100] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } @@ -123,7 +121,7 @@ { // Setup var random = new Random(21); - var norm = random.Next(1, int.MaxValue); + var norm = random.NextDouble(); // Call var result = new FailureMechanismContribution(Enumerable.Empty(), contribution, norm); @@ -149,7 +147,7 @@ // Setup var random = new Random(21); var otherContribution = random.Next(1, 100); - var norm = random.Next(1, int.MaxValue); + var norm = random.NextDouble(); var failureMechanismNames = new Collection(); var failureMechanismContributions = new Collection(); @@ -199,7 +197,7 @@ // Setup IEnumerable failureMechanisms = Enumerable.Empty(); - const int norm = 30000; + const double norm = 1.0/30000; var failureMechanismContribution = new FailureMechanismContribution(failureMechanisms, 12.34, norm); // Call @@ -244,7 +242,7 @@ failureMechanism2 }; - const int norm = 30000; + const double norm = 1.0/30000; const double otherContribution = 12.34; var failureMechanismContribution = new FailureMechanismContribution(failureMechanisms, otherContribution, norm); @@ -303,7 +301,7 @@ var random = new Random(21); var otherContribution = random.Next(1, 100); const double norm = 1.0/20000; - const double newNorm = 1.0 / 30000; + const double newNorm = 1.0/30000; var failureMechanism = mockRepository.Stub(); @@ -322,7 +320,7 @@ mockRepository.VerifyAll(); } - private static void AssertFailureProbabilitySpace(double newOtherContribution, int norm, double probabilitySpace) + private static void AssertFailureProbabilitySpace(double newOtherContribution, double norm, double probabilitySpace) { double expectedProbabilitySpace = (1.0/norm/newOtherContribution)*100.0; Assert.AreEqual(expectedProbabilitySpace, probabilitySpace);