Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/PropertyClasses/WaterLevelCalculationsForUserDefinedTargetProbabilityPropertiesTest.cs
===================================================================
diff -u
--- Riskeer/Common/test/Riskeer.Common.Forms.Test/PropertyClasses/WaterLevelCalculationsForUserDefinedTargetProbabilityPropertiesTest.cs (revision 0)
+++ Riskeer/Common/test/Riskeer.Common.Forms.Test/PropertyClasses/WaterLevelCalculationsForUserDefinedTargetProbabilityPropertiesTest.cs (revision af6988c1d9a38cd7e550ed280813cd02d619d075)
@@ -0,0 +1,156 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.ComponentModel;
+using Core.Common.TestUtil;
+using Core.Gui.Converters;
+using Core.Gui.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Forms.PropertyClasses;
+using Riskeer.Common.Forms.TypeConverters;
+
+namespace Riskeer.Common.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class WaterLevelCalculationsForUserDefinedTargetProbabilityPropertiesTest
+ {
+ private const int targetProbabilityPropertyIndex = 0;
+ private const int calculationsPropertyIndex = 1;
+
+ [Test]
+ public void Constructor_HydraulicBoundaryLocationCalculationsForTargetProbabilityNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var targetProbabilityChangeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => new WaterLevelCalculationsForUserDefinedTargetProbabilityProperties(
+ null, targetProbabilityChangeHandler);
+
+ // Assert
+ string paramName = Assert.Throws(Call).ParamName;
+ Assert.AreEqual("calculationsForTargetProbability", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_TargetProbabilityChangeHandlerNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => new WaterLevelCalculationsForUserDefinedTargetProbabilityProperties(
+ new HydraulicBoundaryLocationCalculationsForTargetProbability(), null);
+
+ // Assert
+ string paramName = Assert.Throws(Call).ParamName;
+ Assert.AreEqual("targetProbabilityChangeHandler", paramName);
+ }
+
+ [Test]
+ public void Constructor_ValidParameters_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var targetProbabilityChangeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability();
+
+ // Call
+ var properties = new WaterLevelCalculationsForUserDefinedTargetProbabilityProperties(
+ calculationsForTargetProbability, targetProbabilityChangeHandler);
+
+ // Assert
+ Assert.IsInstanceOf(properties);
+ Assert.AreSame(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations, properties.Data);
+ TestHelper.AssertTypeConverter(
+ nameof(WaterLevelCalculationsForUserDefinedTargetProbabilityProperties.Calculations));
+ TestHelper.AssertTypeConverter(
+ nameof(WaterLevelCalculationsForUserDefinedTargetProbabilityProperties.TargetProbability));
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var targetProbabilityChangeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ var properties = new WaterLevelCalculationsForUserDefinedTargetProbabilityProperties(
+ new HydraulicBoundaryLocationCalculationsForTargetProbability(), targetProbabilityChangeHandler);
+
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(2, dynamicProperties.Count);
+
+ PropertyDescriptor targetProbabilityProperty = dynamicProperties[targetProbabilityPropertyIndex];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty,
+ "Algemeen",
+ "Doelkans [1/jaar]",
+ "Overschrijdingskans waarvoor de waterstanden worden berekend.");
+
+ PropertyDescriptor locationsProperty = dynamicProperties[calculationsPropertyIndex];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationsProperty,
+ "Algemeen",
+ "Locaties",
+ "Locaties uit de hydraulische belastingendatabase.",
+ true);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GetProperties_WithData_ReturnExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var targetProbabilityChangeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability
+ {
+ HydraulicBoundaryLocationCalculations =
+ {
+ new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
+ }
+ };
+
+ // Call
+ var properties = new WaterLevelCalculationsForUserDefinedTargetProbabilityProperties(
+ calculationsForTargetProbability, targetProbabilityChangeHandler);
+
+ // Assert
+ Assert.AreEqual(calculationsForTargetProbability.TargetProbability, properties.TargetProbability);
+ Assert.AreEqual(1, properties.Calculations.Length);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file