Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructureSectionResultRowTest.cs =================================================================== diff -u -rbd3056331b8727d6f9758d1f4e5979694d439398 -rce94b8228bc7e51779b3754217580f13cb35e475 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructureSectionResultRowTest.cs (.../ClosingStructureSectionResultRowTest.cs) (revision bd3056331b8727d6f9758d1f4e5979694d439398) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/ClosingStructureSectionResultRowTest.cs (.../ClosingStructureSectionResultRowTest.cs) (revision ce94b8228bc7e51779b3754217580f13cb35e475) @@ -23,17 +23,19 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.TestUtil; +using Core.Common.Utils.Reflection; + using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms.Views.SectionResultRows; using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; namespace Ringtoets.Integration.Forms.Test.Views.SectionResultRows { @@ -64,18 +66,17 @@ // Assert Assert.AreEqual(section.Name, row.Name); Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne); - - var expected2AValue = (RoundedDouble) (1 / result.AssessmentLayerTwoA); - var expected2AValueString = string.Format( - CoreCommonBaseResources.ProbabilityPerYearFormat, - expected2AValue + Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA ); - Assert.AreEqual( - expected2AValueString, - row.AssessmentLayerTwoA - ); Assert.AreEqual(result.AssessmentLayerThree, row.AssessmentLayerThree); + + Assert.IsTrue(TypeUtils.HasTypeConverter( + r => r.AssessmentLayerTwoA)); + Assert.IsTrue(TypeUtils.HasTypeConverter( + r => r.AssessmentLayerThree)); } [Test] @@ -118,12 +119,10 @@ var row = new ClosingStructureSectionResultRow(result); // Call - row.AssessmentLayerTwoA = newValue.ToString(); + row.AssessmentLayerTwoA = newValue; // Assert - var expected = string.Format(CoreCommonBaseResources.ProbabilityPerYearFormat, newValue); - var actual = string.Format(CoreCommonBaseResources.ProbabilityPerYearFormat, result.AssessmentLayerTwoA); - Assert.AreEqual(expected, actual); + Assert.AreEqual(newValue, row.AssessmentLayerTwoA); } [Test] @@ -140,76 +139,15 @@ var row = new ClosingStructureSectionResultRow(result); // Call - TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + TestDelegate test = () => row.AssessmentLayerTwoA = newValue; // Assert var message = Assert.Throws(test).Message; - Assert.AreEqual( - Common.Data.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, - message - ); + Assert.AreEqual(RingtoetsCommonDataResources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message); } [Test] - [TestCase(double.MaxValue + 1)] - [TestCase(double.MinValue - 1)] - public void AssessmentLayerTwoA_ForTooLargeValues_ThrowsArgumentException(double value) - { - // Setup - var newValue = (RoundedDouble)value; - var section = CreateSection(); - var result = new ClosingStructureFailureMechanismSectionResult(section); - var row = new ClosingStructureSectionResultRow(result); - - // Call - TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); - - // Assert - var message = Assert.Throws(test).Message; - Assert.AreEqual( - RingtoetsCommonFormsResources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large, - message - ); - } - - [Test] - [TestCase("many")] - [TestCase("")] - public void AssessmentLayerTwoA_ForNonNumericValues_ThrowsArgumentException(string value) - { - // Setup - var section = CreateSection(); - var result = new ClosingStructureFailureMechanismSectionResult(section); - var row = new ClosingStructureSectionResultRow(result); - - // Call - TestDelegate test = () => row.AssessmentLayerTwoA = value; - - // Assert - var message = Assert.Throws(test).Message; - Assert.AreEqual( - RingtoetsCommonFormsResources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_value, - message - ); - } - - [Test] - public void AssessmentLayerTwoA_ForNullValue_ThrowsArgumentException() - { - // Setup - var section = CreateSection(); - var result = new ClosingStructureFailureMechanismSectionResult(section); - var row = new ClosingStructureSectionResultRow(result); - - // Call - TestDelegate test = () => row.AssessmentLayerTwoA = (string) null; - - // Assert - var expectedMessage = RingtoetsCommonFormsResources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); - } - - [Test] public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() { // Setup