Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using Core.Common.Base.Data;
@@ -42,10 +43,10 @@
/// ViewModel of for properties panel.
///
public class ClosingStructuresInputContextProperties : StructuresInputBaseProperties<
- ClosingStructure,
- ClosingStructuresInput,
- StructuresCalculation,
- ClosingStructuresFailureMechanism>
+ ClosingStructure,
+ ClosingStructuresInput,
+ StructuresCalculation,
+ ClosingStructuresFailureMechanism>
{
private const int hydraulicBoundaryLocationPropertyIndex = 1;
private const int stormDurationPropertyIndex = 2;
@@ -77,24 +78,27 @@
///
/// Creates a new instance of the class.
///
- public ClosingStructuresInputContextProperties() : base(new ConstructionProperties
- {
- StructurePropertyIndex = structurePropertyIndex,
- StructureLocationPropertyIndex = structureLocationPropertyIndex,
- StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex,
- FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex,
- WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex,
- StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex,
- AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex,
- CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex,
- FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex,
- ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex,
- UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex,
- UseForeshorePropertyIndex = useForeshorePropertyIndex,
- ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex,
- HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex,
- StormDurationPropertyIndex = stormDurationPropertyIndex
- }) {}
+ /// The instance to show the properties of.
+ /// Thrown when is null.
+ public ClosingStructuresInputContextProperties(ClosingStructuresInputContext data) :
+ base(data, new ConstructionProperties
+ {
+ StructurePropertyIndex = structurePropertyIndex,
+ StructureLocationPropertyIndex = structureLocationPropertyIndex,
+ StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex,
+ FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex,
+ WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex,
+ StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex,
+ AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex,
+ CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex,
+ FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex,
+ ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex,
+ UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex,
+ UseForeshorePropertyIndex = useForeshorePropertyIndex,
+ ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex,
+ HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex,
+ StormDurationPropertyIndex = stormDurationPropertyIndex
+ }) {}
#region Hydraulic data
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs
===================================================================
diff -u -rc016f7af2a4afdc96fc19b8db86dc8d3559de023 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision c016f7af2a4afdc96fc19b8db86dc8d3559de023)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -66,7 +66,10 @@
new FailureMechanismPropertyChangeHandler())
};
yield return new PropertyInfo();
- yield return new PropertyInfo();
+ yield return new PropertyInfo
+ {
+ CreateInstance = context => new ClosingStructuresInputContextProperties(context)
+ };
}
public override IEnumerable GetViewInfos()
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -58,15 +58,64 @@
}
[Test]
- public void Constructor_ExpectedValues()
+ public void Constructor_WithoutData_ExpectedValues()
{
// Call
- var properties = new ClosingStructuresInputContextProperties();
+ TestDelegate test = () => new ClosingStructuresInputContextProperties(null);
// Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("data", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithData_ExpectedValues()
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ var calculation = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ Structure = new TestClosingStructure(ClosingStructureInflowModelType.VerticalWall)
+ }
+ };
+ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+
+ // Call
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
+
+ // Assert
Assert.IsInstanceOf, ClosingStructuresFailureMechanism>>(properties);
- Assert.IsNull(properties.Data);
+ Assert.AreSame(inputContext, properties.Data);
+
+ ClosingStructuresInput input = calculation.InputParameters;
+ var expectedProbabilityOrFrequencyOpenStructureBeforeFlooding = ProbabilityFormattingHelper.Format(input.ProbabilityOrFrequencyOpenStructureBeforeFlooding);
+ var expectedFailureProbabilityOpenStructure = ProbabilityFormattingHelper.Format(input.FailureProbabilityOpenStructure);
+ var expectedFailureProbabilityReparation = ProbabilityFormattingHelper.Format(input.FailureProbabilityReparation);
+
+ Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data);
+ Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation);
+ Assert.AreSame(input.InsideWaterLevel, properties.InsideWaterLevel.Data);
+ Assert.AreEqual(input.InflowModelType, properties.InflowModelType);
+ Assert.AreSame(input.AreaFlowApertures, properties.AreaFlowApertures.Data);
+ Assert.AreEqual(input.IdenticalApertures, properties.IdenticalApertures);
+ Assert.AreSame(input.LevelCrestStructureNotClosing, properties.LevelCrestStructureNotClosing.Data);
+ Assert.AreSame(input.ThresholdHeightOpenWeir, properties.ThresholdHeightOpenWeir.Data);
+ Assert.AreEqual(expectedProbabilityOrFrequencyOpenStructureBeforeFlooding, properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding);
+ Assert.AreEqual(expectedFailureProbabilityOpenStructure, properties.FailureProbabilityOpenStructure);
+ Assert.AreEqual(expectedFailureProbabilityReparation, properties.FailureProbabilityReparation);
+ Assert.AreSame(input.DrainCoefficient, properties.DrainCoefficient.Data);
+ Assert.AreEqual(input.FactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure);
+
+ mockRepository.VerifyAll();
}
[Test]
@@ -90,10 +139,7 @@
assessmentSectionStub);
// Call
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -189,10 +235,7 @@
assessmentSectionStub);
// Call
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -298,10 +341,7 @@
assessmentSectionStub);
// Call
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -383,48 +423,6 @@
}
[Test]
- public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new ClosingStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- var properties = new ClosingStructuresInputContextProperties();
-
- var inputContext = new ClosingStructuresInputContext(calculation.InputParameters,
- calculation,
- failureMechanism,
- assessmentSectionStub);
-
- // Call
- properties.Data = inputContext;
-
- // Assert
- ClosingStructuresInput input = calculation.InputParameters;
- var expectedProbabilityOrFrequencyOpenStructureBeforeFlooding = ProbabilityFormattingHelper.Format(input.ProbabilityOrFrequencyOpenStructureBeforeFlooding);
- var expectedFailureProbabilityOpenStructure = ProbabilityFormattingHelper.Format(input.FailureProbabilityOpenStructure);
- var expectedFailureProbabilityReparation = ProbabilityFormattingHelper.Format(input.FailureProbabilityReparation);
-
- Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data);
- Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation);
- Assert.AreSame(input.InsideWaterLevel, properties.InsideWaterLevel.Data);
- Assert.AreEqual(input.InflowModelType, properties.InflowModelType);
- Assert.AreSame(input.AreaFlowApertures, properties.AreaFlowApertures.Data);
- Assert.AreEqual(input.IdenticalApertures, properties.IdenticalApertures);
- Assert.AreSame(input.LevelCrestStructureNotClosing, properties.LevelCrestStructureNotClosing.Data);
- Assert.AreSame(input.ThresholdHeightOpenWeir, properties.ThresholdHeightOpenWeir.Data);
- Assert.AreEqual(expectedProbabilityOrFrequencyOpenStructureBeforeFlooding, properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding);
- Assert.AreEqual(expectedFailureProbabilityOpenStructure, properties.FailureProbabilityOpenStructure);
- Assert.AreEqual(expectedFailureProbabilityReparation, properties.FailureProbabilityReparation);
- Assert.AreSame(input.DrainCoefficient, properties.DrainCoefficient.Data);
- Assert.AreEqual(input.FactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles()
{
// Setup
@@ -443,10 +441,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles();
@@ -475,10 +470,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
var availableStructures = properties.GetAvailableStructures();
@@ -507,10 +499,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
input.Attach(observerMock);
@@ -618,10 +607,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
const int overflow = 1;
string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
@@ -652,10 +638,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
string newProbabilityString = newValue.ToString("r", CultureInfo.CurrentCulture);
@@ -685,10 +668,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
TestDelegate call = () => properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = newValue;
@@ -714,10 +694,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
TestDelegate call = () => properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = null;
@@ -745,10 +722,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
const int overflow = 1;
string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
@@ -779,10 +753,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
TestDelegate call = () => properties.FailureProbabilityOpenStructure = newValue;
@@ -808,10 +779,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
TestDelegate call = () => properties.FailureProbabilityOpenStructure = null;
@@ -839,10 +807,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
const int overflow = 1;
string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
@@ -873,10 +838,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
TestDelegate call = () => properties.FailureProbabilityReparation = newValue;
@@ -902,10 +864,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call
TestDelegate call = () => properties.FailureProbabilityReparation = null;
@@ -930,10 +889,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
failureMechanism.AddSection(new FailureMechanismSection("Section", new List
{
@@ -968,10 +924,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call & Assert
Assert.IsFalse(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.InsideWaterLevel)));
@@ -1005,10 +958,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call & Assert
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.InsideWaterLevel)));
@@ -1042,10 +992,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call & Assert
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.InsideWaterLevel)));
@@ -1073,10 +1020,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new ClosingStructuresInputContextProperties(inputContext);
// Call & Assert
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.InsideWaterLevel)));
@@ -1205,13 +1149,11 @@
var failureMechanism = new ClosingStructuresFailureMechanism();
- var properties = new ClosingStructuresInputContextProperties
- {
- Data = new ClosingStructuresInputContext(inputParameters,
+ var properties = new ClosingStructuresInputContextProperties( new ClosingStructuresInputContext(inputParameters,
calculation,
failureMechanism,
assessmentSection)
- };
+ );
// Call
setProperty(properties);
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/PropertyInfos/ClosingStructuresInputContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/PropertyInfos/ClosingStructuresInputContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/PropertyInfos/ClosingStructuresInputContextPropertyInfoTest.cs (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -0,0 +1,61 @@
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.ClosingStructures.Data.TestUtil;
+using Ringtoets.ClosingStructures.Forms.PresentationObjects;
+using Ringtoets.ClosingStructures.Forms.PropertyClasses;
+using Ringtoets.Common.Data.AssessmentSection;
+
+namespace Ringtoets.ClosingStructures.Plugin.Test.PropertyInfos
+{
+ public class ClosingStructuresInputContextPropertyInfoTest
+ {
+ private ClosingStructuresPlugin plugin;
+ private PropertyInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new ClosingStructuresPlugin();
+ info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(ClosingStructuresInputContextProperties));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(ClosingStructuresInputContext), info.DataType);
+ Assert.AreEqual(typeof(ClosingStructuresInputContextProperties), info.PropertyObjectType);
+ }
+
+ [Test]
+ public void CreateInstance_Always_NewPropertiesWithFailureMechanismContextAsData()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var calculation = new TestClosingStructuresCalculation();
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ var context = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection);
+
+ // Call
+ var objectProperties = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(objectProperties);
+ Assert.AreSame(context, objectProperties.Data);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -65,6 +65,7 @@
Properties\GlobalAssembly.cs
+
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs
===================================================================
diff -u -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -66,15 +66,23 @@
///
/// Creates a new instance of the class.
///
+ /// The instance to show the properties of.
/// The property values required to create an instance of .
- /// Thrown when is null.
- protected StructuresInputBaseProperties(ConstructionProperties constructionProperties)
+ /// Thrown when any parameter is null.
+ protected StructuresInputBaseProperties(
+ InputContextBase data,
+ ConstructionProperties constructionProperties)
{
+ if (data == null)
+ {
+ throw new ArgumentNullException("data");
+ }
if (constructionProperties == null)
{
throw new ArgumentNullException("constructionProperties");
}
+ Data = data;
propertyIndexLookup = new Dictionary
{
{
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -59,30 +59,110 @@
[Test]
public void Constructor_ConstructionPropertiesIsNull_ThrowsArgumentNullException()
{
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ var failureMechanismStub = mockRepository.Stub();
+
+ mockRepository.ReplayAll();
+
+ var calculation = new StructuresCalculation();
+ var inputContext = new SimpleInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanismStub,
+ assessmentSectionStub);
// Call
- TestDelegate call = () => new SimpleStructuresInputProperties(null);
+ TestDelegate call = () => new SimpleStructuresInputProperties(inputContext, null);
// Assert
string paramName = Assert.Throws(call).ParamName;
Assert.AreEqual("constructionProperties", paramName);
}
[Test]
- public void Constructor_ExpectedValues()
+ public void Constructor_DataIsNull_ThrowsArgumentNullException()
{
// Setup
var constructionProperties = GetRandomConstructionProperties();
// Call
- var properties = new SimpleStructuresInputProperties(constructionProperties);
+ TestDelegate call = () => new SimpleStructuresInputProperties(null, constructionProperties);
// Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("data", paramName);
+ }
+
+ [Test]
+ public void Constructor_ValidValues_ExpectedValues()
+ {
+ // Setup
+ var constructionProperties = GetRandomConstructionProperties();
+ var assessmentSectionStub = mockRepository.Stub();
+ var failureMechanismStub = mockRepository.Stub();
+
+ mockRepository.ReplayAll();
+
+ var calculation = new StructuresCalculation();
+ var inputContext = new SimpleInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanismStub,
+ assessmentSectionStub);
+
+ // Call
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ constructionProperties);
+
+ // Assert
Assert.IsInstanceOf, IFailureMechanism>>>(properties);
Assert.IsInstanceOf(properties);
Assert.IsInstanceOf>(properties);
Assert.IsInstanceOf(properties);
- Assert.IsNull(properties.Data);
+ Assert.AreSame(inputContext, properties.Data);
+ SimpleStructureInput input = calculation.InputParameters;
+ var expectedFailureProbabilityStructureWithErosion = ProbabilityFormattingHelper.Format(input.FailureProbabilityStructureWithErosion);
+
+ Assert.IsNull(properties.Structure);
+ Assert.IsNull(properties.StructureLocation);
+ Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data);
+ Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation);
+ Assert.AreSame(input.AllowedLevelIncreaseStorage, properties.AllowedLevelIncreaseStorage.Data);
+ Assert.AreSame(input.StorageStructureArea, properties.StorageStructureArea.Data);
+ Assert.AreSame(input.FlowWidthAtBottomProtection, properties.FlowWidthAtBottomProtection.Data);
+ Assert.AreSame(input.WidthFlowApertures, properties.WidthFlowApertures.Data);
+ Assert.AreSame(input.CriticalOvertoppingDischarge, properties.CriticalOvertoppingDischarge.Data);
+ Assert.IsNull(properties.ForeshoreProfile);
+ Assert.IsInstanceOf(properties.UseBreakWater);
+ Assert.IsInstanceOf(properties.UseForeshore);
+ Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, properties.FailureProbabilityStructureWithErosion);
+ Assert.IsNull(properties.SelectedHydraulicBoundaryLocation);
+ Assert.AreSame(input.StormDuration, properties.StormDuration.Data);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_ValidValues_PropertiesHaveExpectedAttributesValues()
+ {
+ // Setup
+ var constructionProperties = GetRandomConstructionProperties();
+ var assessmentSectionStub = mockRepository.Stub();
+ var failureMechanismStub = mockRepository.Stub();
+
+ mockRepository.ReplayAll();
+
+ var calculation = new StructuresCalculation();
+ var inputContext = new SimpleInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanismStub,
+ assessmentSectionStub);
+
+ // Call
+ var properties = new SimpleStructuresInputProperties(inputContext, constructionProperties);
+
+ // Assert
+
const string schematizationCategory = "Schematisatie";
const string hydraulicDataCategory = "Hydraulische gegevens";
const string modelSettingsCategory = "Modelinstellingen";
@@ -191,48 +271,6 @@
}
[Test]
- public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- var failureMechanismStub = mockRepository.Stub();
-
- mockRepository.ReplayAll();
-
- var calculation = new StructuresCalculation();
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
- var inputContext = new SimpleInputContext(calculation.InputParameters,
- calculation,
- failureMechanismStub,
- assessmentSectionStub);
-
- // Call
- properties.Data = inputContext;
-
- // Assert
- SimpleStructureInput input = calculation.InputParameters;
- var expectedFailureProbabilityStructureWithErosion = ProbabilityFormattingHelper.Format(input.FailureProbabilityStructureWithErosion);
-
- Assert.IsNull(properties.Structure);
- Assert.IsNull(properties.StructureLocation);
- Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data);
- Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation);
- Assert.AreSame(input.AllowedLevelIncreaseStorage, properties.AllowedLevelIncreaseStorage.Data);
- Assert.AreSame(input.StorageStructureArea, properties.StorageStructureArea.Data);
- Assert.AreSame(input.FlowWidthAtBottomProtection, properties.FlowWidthAtBottomProtection.Data);
- Assert.AreSame(input.WidthFlowApertures, properties.WidthFlowApertures.Data);
- Assert.AreSame(input.CriticalOvertoppingDischarge, properties.CriticalOvertoppingDischarge.Data);
- Assert.IsNull(properties.ForeshoreProfile);
- Assert.IsInstanceOf(properties.UseBreakWater);
- Assert.IsInstanceOf(properties.UseForeshore);
- Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, properties.FailureProbabilityStructureWithErosion);
- Assert.IsNull(properties.SelectedHydraulicBoundaryLocation);
- Assert.AreSame(input.StormDuration, properties.StormDuration.Data);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
public void SelectedHydraulicBoundaryLocation_InputNoLocation_ReturnsNull()
{
// Setup
@@ -245,10 +283,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null;
@@ -287,10 +324,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Call
var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations();
@@ -337,10 +373,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Call
var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations();
@@ -389,10 +424,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations()
.ToList();
@@ -440,10 +474,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
inputContext.Attach(observerMock);
@@ -534,10 +567,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Precondition
Assert.IsFalse(properties.AfterSettingStructureCalled);
@@ -562,10 +594,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Precondition
Assert.IsFalse(properties.AfterSettingStructureCalled);
@@ -592,10 +623,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Call
TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue.ToString(CultureInfo.InvariantCulture);
@@ -622,10 +652,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Call
TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue;
@@ -650,10 +679,9 @@
calculation,
failureMechanismStub,
assessmentSectionStub);
- var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties())
- {
- Data = inputContext
- };
+ var properties = new SimpleStructuresInputProperties(
+ inputContext,
+ new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties());
// Call
TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = null;
@@ -747,7 +775,7 @@
StructuresCalculation,
IFailureMechanism>
{
- public SimpleStructuresInputProperties(ConstructionProperties constructionProperties) : base(constructionProperties) {}
+ public SimpleStructuresInputProperties(SimpleInputContext context, ConstructionProperties constructionProperties) : base(context, constructionProperties) {}
[Browsable(false)]
public bool AfterSettingStructureCalled { get; private set; }
@@ -803,13 +831,11 @@
inputParameters.Attach(inputObserver);
- var properties = new SimpleStructuresInputProperties(GetRandomConstructionProperties())
- {
- Data = new SimpleInputContext(inputParameters,
- calculation,
- failureMechanism,
- assessmentSection)
- };
+ var properties = new SimpleStructuresInputProperties(new SimpleInputContext(inputParameters,
+ calculation,
+ failureMechanism,
+ assessmentSection),
+ GetRandomConstructionProperties());
// Call
setProperty(properties);
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using Core.Common.Gui.Attributes;
@@ -37,10 +38,10 @@
/// ViewModel of for properties panel.
///
public class HeightStructuresInputContextProperties : StructuresInputBaseProperties<
- HeightStructure,
- HeightStructuresInput,
- StructuresCalculation,
- HeightStructuresFailureMechanism>
+ HeightStructure,
+ HeightStructuresInput,
+ StructuresCalculation,
+ HeightStructuresFailureMechanism>
{
private const int structurePropertyIndex = 1;
private const int structureLocationPropertyIndex = 2;
@@ -62,25 +63,27 @@
///
/// Creates a new instance of the class.
///
- public HeightStructuresInputContextProperties() : base(
- new ConstructionProperties
- {
- StructurePropertyIndex = structurePropertyIndex,
- StructureLocationPropertyIndex = structureLocationPropertyIndex,
- StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex,
- FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex,
- WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex,
- StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex,
- AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex,
- CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex,
- FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex,
- ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex,
- UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex,
- UseForeshorePropertyIndex = useForeshorePropertyIndex,
- ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex,
- HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex,
- StormDurationPropertyIndex = stormDurationPropertyIndex
- }) {}
+ /// The instance to show the properties of.
+ /// Thrown when is null.
+ public HeightStructuresInputContextProperties(HeightStructuresInputContext data)
+ : base(data, new ConstructionProperties
+ {
+ StructurePropertyIndex = structurePropertyIndex,
+ StructureLocationPropertyIndex = structureLocationPropertyIndex,
+ StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex,
+ FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex,
+ WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex,
+ StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex,
+ AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex,
+ CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex,
+ FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex,
+ ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex,
+ UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex,
+ UseForeshorePropertyIndex = useForeshorePropertyIndex,
+ ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex,
+ HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex,
+ StormDurationPropertyIndex = stormDurationPropertyIndex
+ }) {}
#region Schematization
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs
===================================================================
diff -u -rbdfdac3498b97ecf6bf04d53c581f557e7e87795 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision bdfdac3498b97ecf6bf04d53c581f557e7e87795)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -66,7 +66,10 @@
}
};
yield return new PropertyInfo();
- yield return new PropertyInfo();
+ yield return new PropertyInfo
+ {
+ CreateInstance = context => new HeightStructuresInputContextProperties(context)
+ };
}
public override IEnumerable GetImportInfos()
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs
===================================================================
diff -u -r98f01944e8ac182e2a1e9b1ed4deb48a07952529 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 98f01944e8ac182e2a1e9b1ed4deb48a07952529)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -68,44 +68,98 @@
}
[Test]
- public void Constructor_ExpectedValues()
+ public void Constructor_WithoutData_ExpectedValues()
{
// Call
- var properties = new HeightStructuresInputContextProperties();
+ TestDelegate test = () => new HeightStructuresInputContextProperties(null);
// Assert
- Assert.IsInstanceOf, HeightStructuresFailureMechanism>>(properties);
- Assert.IsNull(properties.Data);
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("data", paramName);
}
[Test]
- public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues()
+ public void Constructor_WithData_ExpectedValues()
{
// Setup
var assessmentSectionStub = mockRepository.Stub();
mockRepository.ReplayAll();
var failureMechanism = new HeightStructuresFailureMechanism();
var calculation = new StructuresCalculation();
- var properties = new HeightStructuresInputContextProperties();
var inputContext = new HeightStructuresInputContext(calculation.InputParameters,
calculation,
failureMechanism,
assessmentSectionStub);
// Call
- properties.Data = inputContext;
+ var properties = new HeightStructuresInputContextProperties(inputContext);
// Assert
- HeightStructuresInput input = calculation.InputParameters;
+ Assert.IsInstanceOf, HeightStructuresFailureMechanism>>(properties);
+ Assert.AreSame(inputContext, properties.Data);
+ HeightStructuresInput input = calculation.InputParameters;
Assert.AreSame(input.LevelCrestStructure, properties.LevelCrestStructure.Data);
mockRepository.VerifyAll();
}
[Test]
+ public void Constructor_WithData_PropertiesHaveExpectedAttributesValues()
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new HeightStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ var inputContext = new HeightStructuresInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+
+ // Call
+ var properties = new HeightStructuresInputContextProperties(inputContext);
+
+ // Assert
+ const string schematizationCategory = "Schematisatie";
+
+ var dynamicPropertyBag = new DynamicPropertyBag(properties);
+ PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
+ {
+ new BrowsableAttribute(true)
+ });
+ Assert.AreEqual(16, dynamicProperties.Count);
+
+ PropertyDescriptor levelCrestStructureProperty = dynamicProperties[levelCrestStructurePropertyIndex];
+ Assert.IsInstanceOf(levelCrestStructureProperty.Converter);
+ Assert.AreEqual(schematizationCategory, levelCrestStructureProperty.Category);
+ Assert.AreEqual("Kerende hoogte [m+NAP]", levelCrestStructureProperty.DisplayName);
+ Assert.AreEqual("Kerende hoogte van het kunstwerk.", levelCrestStructureProperty.Description);
+
+ // Only check the order of the base properties
+ Assert.AreEqual("Kunstwerk", dynamicProperties[structurePropertyIndex].DisplayName);
+ Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[structureLocationPropertyIndex].DisplayName);
+ Assert.AreEqual("Oriëntatie [°]", dynamicProperties[structureNormalOrientationPropertyIndex].DisplayName);
+ Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[flowWidthAtBottomProtectionPropertyIndex].DisplayName);
+ Assert.AreEqual("Breedte van doorstroomopening [m]", dynamicProperties[widthFlowAperturesPropertyIndex].DisplayName);
+ Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[storageStructureAreaPropertyIndex].DisplayName);
+ Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[allowedLevelIncreaseStoragePropertyIndex].DisplayName);
+ Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[criticalOvertoppingDischargePropertyIndex].DisplayName);
+ Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[failureProbabilityStructureWithErosionPropertyIndex].DisplayName);
+ Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", dynamicProperties[modelFactorSuperCriticalFlowPropertyIndex].DisplayName);
+ Assert.AreEqual("Voorlandprofiel", dynamicProperties[foreshoreProfilePropertyIndex].DisplayName);
+ Assert.AreEqual("Dam", dynamicProperties[useBreakWaterPropertyIndex].DisplayName);
+ Assert.AreEqual("Voorlandgeometrie", dynamicProperties[useForeshorePropertyIndex].DisplayName);
+ Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[hydraulicBoundaryLocationPropertyIndex].DisplayName);
+ Assert.AreEqual("Stormduur [uur]", dynamicProperties[stormDurationPropertyIndex].DisplayName);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles()
{
// Setup
@@ -124,10 +178,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new HeightStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new HeightStructuresInputContextProperties(inputContext);
// Call
var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles();
@@ -156,10 +207,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new HeightStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new HeightStructuresInputContextProperties(inputContext);
// Call
var availableStructures = properties.GetAvailableStructures();
@@ -182,10 +230,7 @@
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new HeightStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new HeightStructuresInputContextProperties(inputContext);
failureMechanism.AddSection(new FailureMechanismSection("Section", new List
{
@@ -200,61 +245,5 @@
Assert.AreSame(calculation, failureMechanism.SectionResults.ElementAt(0).Calculation);
mockRepository.VerifyAll();
}
-
- [Test]
- public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new HeightStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- var inputContext = new HeightStructuresInputContext(calculation.InputParameters,
- calculation,
- failureMechanism,
- assessmentSectionStub);
-
- // Call
- var properties = new HeightStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Assert
- const string schematizationCategory = "Schematisatie";
-
- var dynamicPropertyBag = new DynamicPropertyBag(properties);
- PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
- {
- new BrowsableAttribute(true)
- });
- Assert.AreEqual(16, dynamicProperties.Count);
-
- PropertyDescriptor levelCrestStructureProperty = dynamicProperties[levelCrestStructurePropertyIndex];
- Assert.IsInstanceOf(levelCrestStructureProperty.Converter);
- Assert.AreEqual(schematizationCategory, levelCrestStructureProperty.Category);
- Assert.AreEqual("Kerende hoogte [m+NAP]", levelCrestStructureProperty.DisplayName);
- Assert.AreEqual("Kerende hoogte van het kunstwerk.", levelCrestStructureProperty.Description);
-
- // Only check the order of the base properties
- Assert.AreEqual("Kunstwerk", dynamicProperties[structurePropertyIndex].DisplayName);
- Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[structureLocationPropertyIndex].DisplayName);
- Assert.AreEqual("Oriëntatie [°]", dynamicProperties[structureNormalOrientationPropertyIndex].DisplayName);
- Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[flowWidthAtBottomProtectionPropertyIndex].DisplayName);
- Assert.AreEqual("Breedte van doorstroomopening [m]", dynamicProperties[widthFlowAperturesPropertyIndex].DisplayName);
- Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[storageStructureAreaPropertyIndex].DisplayName);
- Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[allowedLevelIncreaseStoragePropertyIndex].DisplayName);
- Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[criticalOvertoppingDischargePropertyIndex].DisplayName);
- Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[failureProbabilityStructureWithErosionPropertyIndex].DisplayName);
- Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", dynamicProperties[modelFactorSuperCriticalFlowPropertyIndex].DisplayName);
- Assert.AreEqual("Voorlandprofiel", dynamicProperties[foreshoreProfilePropertyIndex].DisplayName);
- Assert.AreEqual("Dam", dynamicProperties[useBreakWaterPropertyIndex].DisplayName);
- Assert.AreEqual("Voorlandgeometrie", dynamicProperties[useForeshorePropertyIndex].DisplayName);
- Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[hydraulicBoundaryLocationPropertyIndex].DisplayName);
- Assert.AreEqual("Stormduur [uur]", dynamicProperties[stormDurationPropertyIndex].DisplayName);
-
- mockRepository.VerifyAll();
- }
}
}
\ No newline at end of file
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/PropertyInfos/HeightStructuresInputContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/PropertyInfos/HeightStructuresInputContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/PropertyInfos/HeightStructuresInputContextPropertyInfoTest.cs (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -0,0 +1,61 @@
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.HeightStructures.Data.TestUtil;
+using Ringtoets.HeightStructures.Forms.PresentationObjects;
+using Ringtoets.HeightStructures.Forms.PropertyClasses;
+using Ringtoets.Common.Data.AssessmentSection;
+
+namespace Ringtoets.HeightStructures.Plugin.Test.PropertyInfos
+{
+ public class HeightStructuresInputContextPropertyInfoTest
+ {
+ private HeightStructuresPlugin plugin;
+ private PropertyInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new HeightStructuresPlugin();
+ info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(HeightStructuresInputContextProperties));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(HeightStructuresInputContext), info.DataType);
+ Assert.AreEqual(typeof(HeightStructuresInputContextProperties), info.PropertyObjectType);
+ }
+
+ [Test]
+ public void CreateInstance_Always_NewPropertiesWithFailureMechanismContextAsData()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var calculation = new TestHeightStructuresCalculation();
+ var failureMechanism = new HeightStructuresFailureMechanism();
+ var context = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection);
+
+ // Call
+ var objectProperties = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(objectProperties);
+ Assert.AreSame(context, objectProperties.Data);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -63,6 +63,7 @@
Properties\GlobalAssembly.cs
+
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs
===================================================================
diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using Core.Common.Base.Data;
@@ -90,8 +91,10 @@
///
/// Creates a new instance of the class.
///
- public StabilityPointStructuresInputContextProperties()
- : base(new ConstructionProperties
+ /// The instance to show the properties of.
+ /// Thrown when is null.
+ public StabilityPointStructuresInputContextProperties(StabilityPointStructuresInputContext data)
+ : base(data, new ConstructionProperties
{
StructurePropertyIndex = structurePropertyIndex,
StructureLocationPropertyIndex = structureLocationPropertyIndex,
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs
===================================================================
diff -u -rbdfdac3498b97ecf6bf04d53c581f557e7e87795 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision bdfdac3498b97ecf6bf04d53c581f557e7e87795)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -65,7 +65,10 @@
}
};
yield return new PropertyInfo();
- yield return new PropertyInfo();
+ yield return new PropertyInfo
+ {
+ CreateInstance = context => new StabilityPointStructuresInputContextProperties(context)
+ };
}
public override IEnumerable GetViewInfos()
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs
===================================================================
diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -57,36 +57,38 @@
}
[Test]
- public void Constructor_ExpectedValues()
+ public void Constructor_WithoutData_ExpectedValues()
{
// Call
- var properties = new StabilityPointStructuresInputContextProperties();
+ TestDelegate test = () => new StabilityPointStructuresInputContextProperties(null);
// Assert
- Assert.IsInstanceOf, StabilityPointStructuresFailureMechanism>>(properties);
- Assert.IsNull(properties.Data);
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("data", paramName);
}
[Test]
- public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues()
+ public void Constructor_WithData_ExpectedValues()
{
// Setup
var assessmentSectionStub = mockRepository.Stub();
mockRepository.ReplayAll();
var failureMechanism = new StabilityPointStructuresFailureMechanism();
var calculation = new StructuresCalculation();
- var properties = new StabilityPointStructuresInputContextProperties();
var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters,
calculation,
failureMechanism,
assessmentSectionStub);
- // Call
- properties.Data = inputContext;
+ // Call
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
// Assert
+ Assert.IsInstanceOf, StabilityPointStructuresFailureMechanism>>(properties);
+ Assert.AreSame(inputContext, properties.Data);
+
StabilityPointStructuresInput input = calculation.InputParameters;
var expectedFailureProbabilityRepairClosure = ProbabilityFormattingHelper.Format(input.FailureProbabilityRepairClosure);
var expectedProbabilityCollisionSecondaryStructure = ProbabilityFormattingHelper.Format(input.ProbabilityCollisionSecondaryStructure);
@@ -122,321 +124,6 @@
}
[Test]
- public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism
- {
- ForeshoreProfiles =
- {
- new TestForeshoreProfile()
- }
- };
- var calculation = new StructuresCalculation();
- var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Call
- var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles();
-
- // Assert
- Assert.AreSame(failureMechanism.ForeshoreProfiles, availableForeshoreProfiles);
- mockRepository.VerifyAll();
- }
-
- [Test]
- public void GetAvailableStructures_SetInputContextInstanceWithStructures_ReturnStructures()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism
- {
- StabilityPointStructures =
- {
- new TestStabilityPointStructure()
- }
- };
- var calculation = new StructuresCalculation();
- var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Call
- var availableStructures = properties.GetAvailableStructures();
-
- // Assert
- Assert.AreSame(failureMechanism.StabilityPointStructures, availableStructures);
- mockRepository.VerifyAll();
- }
-
- [Test]
- public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
- {
- // Setup
- const int numberOfChangedProperties = 9;
- var observerMock = mockRepository.StrictMock();
- var assessmentSectionStub = mockRepository.Stub();
-
- observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
-
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- input.Attach(observerMock);
-
- var random = new Random(100);
- double newVolumicWeightWater = random.NextDouble();
- double newFactorStormDurationOpenStructure = random.NextDouble();
- var newInflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert;
- var newLoadSchematizationType = LoadSchematizationType.Quadratic;
- var newLevellingCount = 2;
- double newEvaluationLevel = random.NextDouble();
- double newVerticalDistance = random.NextDouble();
-
- // Call
- properties.VolumicWeightWater = (RoundedDouble) newVolumicWeightWater;
- properties.FactorStormDurationOpenStructure = (RoundedDouble) newFactorStormDurationOpenStructure;
- properties.InflowModelType = newInflowModelType;
- properties.LoadSchematizationType = newLoadSchematizationType;
- properties.FailureProbabilityRepairClosure = "1e-2";
- properties.LevellingCount = newLevellingCount;
- properties.ProbabilityCollisionSecondaryStructure = "1e-3";
- properties.EvaluationLevel = (RoundedDouble) newEvaluationLevel;
- properties.VerticalDistance = (RoundedDouble) newVerticalDistance;
-
- // Assert
- var expectedFailureProbabilityRepairClosure = ProbabilityFormattingHelper.Format(0.01);
- var expectedProbabilityCollisionSecondaryStructure = ProbabilityFormattingHelper.Format(0.001);
-
- Assert.AreEqual(newVolumicWeightWater, properties.VolumicWeightWater, properties.VolumicWeightWater.GetAccuracy());
- Assert.AreEqual(newFactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure.GetAccuracy());
- Assert.AreEqual(newInflowModelType, properties.InflowModelType);
- Assert.AreEqual(newLoadSchematizationType, properties.LoadSchematizationType);
- Assert.AreEqual(expectedFailureProbabilityRepairClosure, properties.FailureProbabilityRepairClosure);
- Assert.AreEqual(newLevellingCount, properties.LevellingCount);
- Assert.AreEqual(expectedProbabilityCollisionSecondaryStructure, properties.ProbabilityCollisionSecondaryStructure);
- Assert.AreEqual(newEvaluationLevel, properties.EvaluationLevel, properties.EvaluationLevel.GetAccuracy());
- Assert.AreEqual(newVerticalDistance, properties.VerticalDistance, properties.VerticalDistance.GetAccuracy());
-
- mockRepository.VerifyAll();
- }
-
- [Test]
- [TestCase(double.MinValue)]
- [TestCase(double.MaxValue)]
- public void SetFailureProbabilityRepairClosure_InvalidValues_ThrowsArgumentException(double newValue)
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- const int overflow = 1;
- string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
-
- // Call
- TestDelegate call = () => properties.FailureProbabilityRepairClosure = newProbabilityString;
-
- // Assert
- var expectedMessage = "De waarde voor de faalkans is te groot of te klein.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
- [TestCase("no double value")]
- [TestCase("")]
- public void SetFailureProbabilityRepairClosure_ValuesUnableToParse_ThrowsArgumentException(string newValue)
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Call
- TestDelegate call = () => properties.FailureProbabilityRepairClosure = newValue;
-
- // Assert
- var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
- public void SetFailureProbabilityRepairClosure_NullValue_ThrowsArgumentNullException()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Call
- TestDelegate call = () => properties.FailureProbabilityRepairClosure = null;
-
- // Assert
- var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
- [TestCase(double.MinValue)]
- [TestCase(double.MaxValue)]
- public void SetProbabilityCollisionSecondaryStructure_InvalidValues_ThrowsArgumentException(double newValue)
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- const int overflow = 1;
- string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
-
- // Call
- TestDelegate call = () => properties.ProbabilityCollisionSecondaryStructure = newProbabilityString;
-
- // Assert
- var expectedMessage = "De waarde voor de faalkans is te groot of te klein.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
- [TestCase("no double value")]
- [TestCase("")]
- public void SetProbabilityCollisionSecondaryStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue)
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Call
- TestDelegate call = () => properties.ProbabilityCollisionSecondaryStructure = newValue;
-
- // Assert
- var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
- public void SetProbabilityCollisionSecondaryStructure_NullValue_ThrowsArgumentNullException()
- {
- // Setup
- var assessmentSectionStub = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var calculation = new StructuresCalculation();
- StabilityPointStructuresInput input = calculation.InputParameters;
- var inputContext = new StabilityPointStructuresInputContext(input,
- calculation,
- failureMechanism,
- assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
- // Call
- TestDelegate call = () => properties.ProbabilityCollisionSecondaryStructure = null;
-
- // Assert
- var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
public void Constructor_LinearLowSillStructure_PropertiesHaveExpectedAttributesValues()
{
// Setup
@@ -458,10 +145,7 @@
assessmentSectionStub);
// Call
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -471,9 +155,9 @@
var dynamicPropertyBag = new DynamicPropertyBag(properties);
PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
- {
- new BrowsableAttribute(true)
- });
+ {
+ new BrowsableAttribute(true)
+ });
Assert.AreEqual(35, dynamicProperties.Count);
PropertyDescriptor volumicWeightWaterProperty = dynamicProperties[linearLowSillVolumicWeightWaterPropertyIndex];
@@ -638,10 +322,7 @@
assessmentSectionStub);
// Call
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -651,9 +332,9 @@
var dynamicPropertyBag = new DynamicPropertyBag(properties);
PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
- {
- new BrowsableAttribute(true)
- });
+ {
+ new BrowsableAttribute(true)
+ });
Assert.AreEqual(35, dynamicProperties.Count);
PropertyDescriptor volumicWeightWaterProperty = dynamicProperties[quadraticLowSillVolumicWeightWaterPropertyIndex];
@@ -818,10 +499,7 @@
assessmentSectionStub);
// Call
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -831,9 +509,9 @@
var dynamicPropertyBag = new DynamicPropertyBag(properties);
PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
- {
- new BrowsableAttribute(true)
- });
+ {
+ new BrowsableAttribute(true)
+ });
Assert.AreEqual(35, dynamicProperties.Count);
PropertyDescriptor volumicWeightWaterProperty = dynamicProperties[linearFloodedCulvertVolumicWeightWaterPropertyIndex];
@@ -1008,10 +686,7 @@
assessmentSectionStub);
// Call
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
// Assert
const string schematizationCategory = "Schematisatie";
@@ -1021,9 +696,9 @@
var dynamicPropertyBag = new DynamicPropertyBag(properties);
PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
- {
- new BrowsableAttribute(true)
- });
+ {
+ new BrowsableAttribute(true)
+ });
Assert.AreEqual(35, dynamicProperties.Count);
PropertyDescriptor volumicWeightWaterProperty = dynamicProperties[quadraticFloodedCulvertVolumicWeightWaterPropertyIndex];
@@ -1177,23 +852,308 @@
}
[Test]
- public void SetStructure_StructureInSection_UpdateSectionResults()
+ public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles()
{
// Setup
var assessmentSectionStub = mockRepository.Stub();
mockRepository.ReplayAll();
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var failureMechanism = new StabilityPointStructuresFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ new TestForeshoreProfile()
+ }
+ };
var calculation = new StructuresCalculation();
var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters,
calculation,
failureMechanism,
assessmentSectionStub);
- var properties = new StabilityPointStructuresInputContextProperties
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ // Call
+ var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles();
+
+ // Assert
+ Assert.AreSame(failureMechanism.ForeshoreProfiles, availableForeshoreProfiles);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void GetAvailableStructures_SetInputContextInstanceWithStructures_ReturnStructures()
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism
{
- Data = inputContext
+ StabilityPointStructures =
+ {
+ new TestStabilityPointStructure()
+ }
};
+ var calculation = new StructuresCalculation();
+ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+ // Call
+ var availableStructures = properties.GetAvailableStructures();
+
+ // Assert
+ Assert.AreSame(failureMechanism.StabilityPointStructures, availableStructures);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
+ {
+ // Setup
+ const int numberOfChangedProperties = 9;
+ var observerMock = mockRepository.StrictMock();
+ var assessmentSectionStub = mockRepository.Stub();
+
+ observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
+
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ input.Attach(observerMock);
+
+ var random = new Random(100);
+ double newVolumicWeightWater = random.NextDouble();
+ double newFactorStormDurationOpenStructure = random.NextDouble();
+ var newInflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert;
+ var newLoadSchematizationType = LoadSchematizationType.Quadratic;
+ var newLevellingCount = 2;
+ double newEvaluationLevel = random.NextDouble();
+ double newVerticalDistance = random.NextDouble();
+
+ // Call
+ properties.VolumicWeightWater = (RoundedDouble) newVolumicWeightWater;
+ properties.FactorStormDurationOpenStructure = (RoundedDouble) newFactorStormDurationOpenStructure;
+ properties.InflowModelType = newInflowModelType;
+ properties.LoadSchematizationType = newLoadSchematizationType;
+ properties.FailureProbabilityRepairClosure = "1e-2";
+ properties.LevellingCount = newLevellingCount;
+ properties.ProbabilityCollisionSecondaryStructure = "1e-3";
+ properties.EvaluationLevel = (RoundedDouble) newEvaluationLevel;
+ properties.VerticalDistance = (RoundedDouble) newVerticalDistance;
+
+ // Assert
+ var expectedFailureProbabilityRepairClosure = ProbabilityFormattingHelper.Format(0.01);
+ var expectedProbabilityCollisionSecondaryStructure = ProbabilityFormattingHelper.Format(0.001);
+
+ Assert.AreEqual(newVolumicWeightWater, properties.VolumicWeightWater, properties.VolumicWeightWater.GetAccuracy());
+ Assert.AreEqual(newFactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure.GetAccuracy());
+ Assert.AreEqual(newInflowModelType, properties.InflowModelType);
+ Assert.AreEqual(newLoadSchematizationType, properties.LoadSchematizationType);
+ Assert.AreEqual(expectedFailureProbabilityRepairClosure, properties.FailureProbabilityRepairClosure);
+ Assert.AreEqual(newLevellingCount, properties.LevellingCount);
+ Assert.AreEqual(expectedProbabilityCollisionSecondaryStructure, properties.ProbabilityCollisionSecondaryStructure);
+ Assert.AreEqual(newEvaluationLevel, properties.EvaluationLevel, properties.EvaluationLevel.GetAccuracy());
+ Assert.AreEqual(newVerticalDistance, properties.VerticalDistance, properties.VerticalDistance.GetAccuracy());
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(double.MinValue)]
+ [TestCase(double.MaxValue)]
+ public void SetFailureProbabilityRepairClosure_InvalidValues_ThrowsArgumentException(double newValue)
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ const int overflow = 1;
+ string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
+
+ // Call
+ TestDelegate call = () => properties.FailureProbabilityRepairClosure = newProbabilityString;
+
+ // Assert
+ var expectedMessage = "De waarde voor de faalkans is te groot of te klein.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("no double value")]
+ [TestCase("")]
+ public void SetFailureProbabilityRepairClosure_ValuesUnableToParse_ThrowsArgumentException(string newValue)
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ // Call
+ TestDelegate call = () => properties.FailureProbabilityRepairClosure = newValue;
+
+ // Assert
+ var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void SetFailureProbabilityRepairClosure_NullValue_ThrowsArgumentNullException()
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ // Call
+ TestDelegate call = () => properties.FailureProbabilityRepairClosure = null;
+
+ // Assert
+ var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(double.MinValue)]
+ [TestCase(double.MaxValue)]
+ public void SetProbabilityCollisionSecondaryStructure_InvalidValues_ThrowsArgumentException(double newValue)
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ const int overflow = 1;
+ string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow);
+
+ // Call
+ TestDelegate call = () => properties.ProbabilityCollisionSecondaryStructure = newProbabilityString;
+
+ // Assert
+ var expectedMessage = "De waarde voor de faalkans is te groot of te klein.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("no double value")]
+ [TestCase("")]
+ public void SetProbabilityCollisionSecondaryStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue)
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ // Call
+ TestDelegate call = () => properties.ProbabilityCollisionSecondaryStructure = newValue;
+
+ // Assert
+ var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void SetProbabilityCollisionSecondaryStructure_NullValue_ThrowsArgumentNullException()
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ StabilityPointStructuresInput input = calculation.InputParameters;
+ var inputContext = new StabilityPointStructuresInputContext(input,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
+ // Call
+ TestDelegate call = () => properties.ProbabilityCollisionSecondaryStructure = null;
+
+ // Assert
+ var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void SetStructure_StructureInSection_UpdateSectionResults()
+ {
+ // Setup
+ var assessmentSectionStub = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var calculation = new StructuresCalculation();
+ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters,
+ calculation,
+ failureMechanism,
+ assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
+
failureMechanism.AddSection(new FailureMechanismSection("Section", new List
{
new Point2D(-10.0, -10.0),
@@ -1221,12 +1181,8 @@
calculation,
failureMechanism,
assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
// Call & Assert
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ModelFactorSuperCriticalFlow)));
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.DrainCoefficient)));
@@ -1258,12 +1214,8 @@
calculation,
failureMechanism,
assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
// Call & Assert
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ModelFactorSuperCriticalFlow)));
Assert.IsFalse(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.DrainCoefficient)));
@@ -1295,12 +1247,8 @@
calculation,
failureMechanism,
assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
// Call & Assert
Assert.IsFalse(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ModelFactorSuperCriticalFlow)));
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.DrainCoefficient)));
@@ -1332,12 +1280,8 @@
calculation,
failureMechanism,
assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
// Call & Assert
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ConstructiveStrengthLinearLoadModel)));
Assert.IsFalse(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ConstructiveStrengthQuadraticLoadModel)));
@@ -1369,12 +1313,8 @@
calculation,
failureMechanism,
assessmentSectionStub);
+ var properties = new StabilityPointStructuresInputContextProperties(inputContext);
- var properties = new StabilityPointStructuresInputContextProperties
- {
- Data = inputContext
- };
-
// Call & Assert
Assert.IsFalse(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ConstructiveStrengthLinearLoadModel)));
Assert.IsTrue(properties.DynamicVisibleValidationMethod(TypeUtils.GetMemberName(p => p.ConstructiveStrengthQuadraticLoadModel)));
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/PropertyInfos/StabilityPointStructuresInputContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/PropertyInfos/StabilityPointStructuresInputContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/PropertyInfos/StabilityPointStructuresInputContextPropertyInfoTest.cs (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -0,0 +1,61 @@
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.StabilityPointStructures.Data;
+using Ringtoets.StabilityPointStructures.Data.TestUtil;
+using Ringtoets.StabilityPointStructures.Forms.PresentationObjects;
+using Ringtoets.StabilityPointStructures.Forms.PropertyClasses;
+using Ringtoets.Common.Data.AssessmentSection;
+
+namespace Ringtoets.StabilityPointStructures.Plugin.Test.PropertyInfos
+{
+ public class StabilityPointStructuresInputContextPropertyInfoTest
+ {
+ private StabilityPointStructuresPlugin plugin;
+ private PropertyInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new StabilityPointStructuresPlugin();
+ info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(StabilityPointStructuresInputContextProperties));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(StabilityPointStructuresInputContext), info.DataType);
+ Assert.AreEqual(typeof(StabilityPointStructuresInputContextProperties), info.PropertyObjectType);
+ }
+
+ [Test]
+ public void CreateInstance_Always_NewPropertiesWithFailureMechanismContextAsData()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var calculation = new TestStabilityPointStructuresCalculation();
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var context = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection);
+
+ // Call
+ var objectProperties = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(objectProperties);
+ Assert.AreSame(context, objectProperties.Data);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj
===================================================================
diff -u -r586d097de0087256cb5cf3dda3a3c612721fee9c -r0f678f97e76d90e4a7e7f0611ff22ab196b46381
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision 586d097de0087256cb5cf3dda3a3c612721fee9c)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision 0f678f97e76d90e4a7e7f0611ff22ab196b46381)
@@ -65,6 +65,7 @@
+