Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/CustomProbabilityFailureMechanismSectionResult.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/CustomProbabilityFailureMechanismSectionResult.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/CustomProbabilityFailureMechanismSectionResult.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,71 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Core.Common.Base.Data;
+using Ringtoets.Common.Data.Properties;
+
+namespace Ringtoets.Common.Data.FailureMechanism
+{
+ ///
+ /// Class which represents a result for a failure mechanism section with a custom probability
+ /// outcome of a layer 2a assessment.
+ ///
+ public class CustomProbabilityFailureMechanismSectionResult : FailureMechanismSectionResult
+ {
+ private RoundedDouble assessmentLayerTwoA;
+
+ ///
+ /// Creates a new instance of
+ ///
+ /// The section for which to add the result.
+ public CustomProbabilityFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {}
+
+ ///
+ /// Gets the value of assessment layer two a.
+ ///
+ public RoundedDouble AssessmentLayerTwoA
+ {
+ get
+ {
+ return assessmentLayerTwoA;
+ }
+ set
+ {
+ if (value < 0 || value > 1)
+ {
+ throw new ArgumentException(Resources.CustomProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1);
+ }
+ assessmentLayerTwoA = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the value of assessment layer two b.
+ ///
+ public RoundedDouble AssessmentLayerTwoB { get; set; }
+
+ ///
+ /// Gets or sets the value of assessment layer three.
+ ///
+ public RoundedDouble AssessmentLayerThree { get; set; }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -133,6 +133,16 @@
}
///
+ /// Looks up a localized string similar to De waarde voor de faalkans moet in het bereik [0,1] liggen..
+ ///
+ public static string CustomProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1 {
+ get {
+ return ResourceManager.GetString("CustomProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to" +
+ "_be_between_0_and_1", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Een kansverdeling moet opgegeven zijn om op basis van die data een rekenwaarde te bepalen..
///
public static string DesignVariable_GetDesignValue_Distribution_must_be_set {
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -210,4 +210,7 @@
Voldoende
+
+ De waarde voor de faalkans moet in het bereik [0,1] liggen.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -r4aa6d896646fee50b7bc6fadd9c2251b4fdd4f2e -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 4aa6d896646fee50b7bc6fadd9c2251b4fdd4f2e)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -53,6 +53,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -rea99af5c043eadf5c2ba83b82a847ae009181191 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision ea99af5c043eadf5c2ba83b82a847ae009181191)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -71,6 +71,7 @@
CommentView.cs
+ UserControl
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomProbabilityFailureMechanismSectionResultRow.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomProbabilityFailureMechanismSectionResultRow.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomProbabilityFailureMechanismSectionResultRow.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Core.Common.Base.Data;
+using Ringtoets.Common.Data.FailureMechanism;
+
+namespace Ringtoets.Common.Forms.Views
+{
+ public class CustomProbabilityFailureMechanismSectionResultRow
+ {
+ public CustomProbabilityFailureMechanismSectionResultRow(CustomProbabilityFailureMechanismSectionResult sectionResult)
+ {
+ if (sectionResult == null)
+ {
+ throw new ArgumentNullException("sectionResult");
+ }
+ SectionResult = sectionResult;
+ }
+
+ private CustomProbabilityFailureMechanismSectionResult SectionResult { get; set; }
+
+ public string Name
+ {
+ get
+ {
+ return SectionResult.Section.Name;
+ }
+ }
+
+ public bool AssessmentLayerOne
+ {
+ get
+ {
+ return SectionResult.AssessmentLayerOne;
+ }
+ set
+ {
+ SectionResult.AssessmentLayerOne = value;
+ SectionResult.NotifyObservers();
+ }
+ }
+
+ public string AssessmentLayerTwoA
+ {
+ get
+ {
+ var d = (RoundedDouble) (1 / SectionResult.AssessmentLayerTwoA);
+ return string.Format(Core.Common.Base.Properties.Resources.ProbabilityPerYearFormat, d);
+ }
+ set
+ {
+ SectionResult.AssessmentLayerTwoA = (RoundedDouble) double.Parse(value);
+ }
+ }
+
+ public RoundedDouble AssessmentLayerTwoB
+ {
+ get
+ {
+ return SectionResult.AssessmentLayerTwoB;
+ }
+ set
+ {
+ SectionResult.AssessmentLayerTwoB = value;
+ }
+ }
+
+ public RoundedDouble AssessmentLayerThree
+ {
+ get
+ {
+ return SectionResult.AssessmentLayerThree;
+ }
+ set
+ {
+ SectionResult.AssessmentLayerThree = value;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomPropertyFailureMechanismSectionResultTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomPropertyFailureMechanismSectionResultTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomPropertyFailureMechanismSectionResultTest.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,105 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+
+namespace Ringtoets.Common.Data.Test.FailureMechanism
+{
+ [TestFixture]
+ public class CustomPropertyFailureMechanismSectionResultTest
+ {
+ [Test]
+ public void Constructor_WithoutSection_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new CustomProbabilityFailureMechanismSectionResult(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("section", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithSection_ResultCreatedForSection()
+ {
+ // Setup
+ var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) });
+
+ // Call
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreSame(section, result.Section);
+ Assert.IsFalse(result.AssessmentLayerOne);
+ Assert.AreEqual(0, result.AssessmentLayerTwoA.Value);
+ Assert.AreEqual(0, result.AssessmentLayerTwoB.Value);
+ Assert.AreEqual(0, result.AssessmentLayerThree.Value);
+ }
+
+ [Test]
+ [TestCase(-20)]
+ [TestCase(-1e-6)]
+ [TestCase(1+1e-6)]
+ [TestCase(12)]
+ public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double a)
+ {
+ // Setup
+ var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) });
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+
+ // Call
+ TestDelegate test = () => result.AssessmentLayerTwoA = (RoundedDouble)a;
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(
+ Properties.Resources.CustomProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1,
+ message
+ );
+ }
+
+ [Test]
+ [TestCase(0)]
+ [TestCase(1e-6)]
+ [TestCase(0.5)]
+ [TestCase(1-1e-6)]
+ [TestCase(1)]
+ public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double a)
+ {
+ // Setup
+ var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) });
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+
+ var assessmentLayerTwoAValue = (RoundedDouble)a;
+
+ // Call
+ result.AssessmentLayerTwoA = assessmentLayerTwoAValue;
+
+ // Assert
+ Assert.AreEqual(assessmentLayerTwoAValue, result.AssessmentLayerTwoA);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj
===================================================================
diff -u -r8047e7fd59525ed424105aaefc4ee88b9ae8def6 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 8047e7fd59525ed424105aaefc4ee88b9ae8def6)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -63,6 +63,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -rea99af5c043eadf5c2ba83b82a847ae009181191 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision ea99af5c043eadf5c2ba83b82a847ae009181191)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -71,6 +71,7 @@
+ UserControl
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomProbabilityFailureMechanismSectionResultRowTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomProbabilityFailureMechanismSectionResultRowTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomProbabilityFailureMechanismSectionResultRowTest.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,178 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.Views;
+
+namespace Ringtoets.Common.Forms.Test.Views
+{
+ [TestFixture]
+ public class CustomProbabilityFailureMechanismSectionResultRowTest
+ {
+ [Test]
+ public void Constructor_WithoutSectionResult_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new CustomProbabilityFailureMechanismSectionResultRow(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("sectionResult", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithSectionResult_PropertiesFromSectionAndResult()
+ {
+ // Setup
+ var section = CreateSection();
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+
+ // Call
+ var row = new CustomProbabilityFailureMechanismSectionResultRow(result);
+
+ // Assert
+ Assert.AreEqual(section.Name, row.Name);
+ Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne);
+ Assert.AreEqual(string.Format(Core.Common.Base.Properties.Resources.ProbabilityPerYearFormat, (RoundedDouble) (1 / result.AssessmentLayerTwoA)), row.AssessmentLayerTwoA);
+ Assert.AreEqual(result.AssessmentLayerTwoB, row.AssessmentLayerTwoB);
+ Assert.AreEqual(result.AssessmentLayerThree, row.AssessmentLayerThree);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue)
+ {
+ // Setup
+ var section = CreateSection();
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+ var row = new CustomProbabilityFailureMechanismSectionResultRow(result);
+
+ int counter = 0;
+ using (new Observer(() => counter++)
+ {
+ Observable = result
+ })
+ {
+ // Call
+ row.AssessmentLayerOne = newValue;
+
+ // Assert
+ Assert.AreEqual(1, counter);
+ Assert.AreEqual(newValue, result.AssessmentLayerOne);
+ }
+ }
+
+ [Test]
+ [TestCase(0)]
+ [TestCase(1)]
+ [TestCase(0.5)]
+ [TestCase(1e-6)]
+ public void AssessmentLayerTwoA_ForValidValues_ResultPropertyChanged(double value)
+ {
+ // Setup
+ var newValue = (RoundedDouble) value;
+ var section = CreateSection();
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+ var row = new CustomProbabilityFailureMechanismSectionResultRow(result);
+
+ // Call
+ row.AssessmentLayerTwoA = newValue.ToString();
+
+ // Assert
+ var expected = string.Format(Core.Common.Base.Properties.Resources.ProbabilityPerYearFormat, newValue);
+ var actual = string.Format(Core.Common.Base.Properties.Resources.ProbabilityPerYearFormat, result.AssessmentLayerTwoA);
+ Assert.AreEqual(expected, actual);
+ }
+
+ [Test]
+ [TestCase(-20)]
+ [TestCase(-1e-6)]
+ [TestCase(1 + 1e-6)]
+ [TestCase(12)]
+ public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double value)
+ {
+ // Setup
+ var newValue = (RoundedDouble)value;
+ var section = CreateSection();
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+ var row = new CustomProbabilityFailureMechanismSectionResultRow(result);
+
+ // Call
+ TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString();
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(
+ Data.Properties.Resources.CustomProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1,
+ message
+ );
+ }
+
+ [Test]
+ public void AssessmentLayerTwoB_AlwaysOnChange_ResultPropertyChanged()
+ {
+ // Setup
+ var random = new Random(21);
+ var newValue = random.NextDouble();
+ var section = CreateSection();
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+ var row = new CustomProbabilityFailureMechanismSectionResultRow(result);
+
+ // Call
+ row.AssessmentLayerTwoB = (RoundedDouble)newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, result.AssessmentLayerTwoB, row.AssessmentLayerTwoB.GetAccuracy());
+ }
+
+ [Test]
+ public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged()
+ {
+ // Setup
+ var random = new Random(21);
+ var newValue = random.NextDouble();
+ var section = CreateSection();
+ var result = new CustomProbabilityFailureMechanismSectionResult(section);
+ var row = new CustomProbabilityFailureMechanismSectionResultRow(result);
+
+ // Call
+ row.AssessmentLayerThree = (RoundedDouble)newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy());
+ }
+
+ private static FailureMechanismSection CreateSection()
+ {
+ return new FailureMechanismSection("name", new[]
+ {
+ new Point2D(0, 0)
+ });
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs
===================================================================
diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs (.../ClosingStructureFailureMechanism.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs (.../ClosingStructureFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -30,17 +30,17 @@
///
/// Defines a stand alone failure mechanisms objects
///
- public class ClosingStructureFailureMechanism : FailureMechanismBase, IHasSectionResults
+ public class ClosingStructureFailureMechanism : FailureMechanismBase, IHasSectionResults
{
- private readonly List sectionResults;
+ private readonly List sectionResults;
///
/// Initializes a new instance of the class.
///
public ClosingStructureFailureMechanism()
: base(Resources.ClosingStructureFailureMechanism_DisplayName, Resources.ClosingStructureFailureMechanism_Code)
{
- sectionResults = new List();
+ sectionResults = new List();
}
public override IEnumerable Calculations
@@ -55,7 +55,7 @@
{
base.AddSection(section);
- sectionResults.Add(new CustomFailureMechanismSectionResult(section));
+ sectionResults.Add(new CustomProbabilityFailureMechanismSectionResult(section));
}
public override void ClearAllSections()
@@ -64,7 +64,7 @@
sectionResults.Clear();
}
- public IEnumerable SectionResults
+ public IEnumerable SectionResults
{
get
{
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacroStabilityInwardsFailureMechanism.cs
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacroStabilityInwardsFailureMechanism.cs (.../MacroStabilityInwardsFailureMechanism.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacroStabilityInwardsFailureMechanism.cs (.../MacroStabilityInwardsFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -30,17 +30,17 @@
///
/// Defines a stand alone failure mechanisms objects
///
- public class MacrostabilityInwardsFailureMechanism : FailureMechanismBase, IHasSectionResults
+ public class MacrostabilityInwardsFailureMechanism : FailureMechanismBase, IHasSectionResults
{
- private readonly IList sectionResults;
+ private readonly IList sectionResults;
///
/// Initializes a new instance of the class.
///
public MacrostabilityInwardsFailureMechanism()
: base(Resources.MacrostabilityInwardFailureMechanism_DisplayName, Resources.MacrostabilityInwardFailureMechanism_Code)
{
- sectionResults = new List();
+ sectionResults = new List();
}
public override IEnumerable Calculations
@@ -55,7 +55,7 @@
{
base.AddSection(section);
- sectionResults.Add(new CustomFailureMechanismSectionResult(section));
+ sectionResults.Add(new CustomProbabilityFailureMechanismSectionResult(section));
}
public override void ClearAllSections()
@@ -64,7 +64,7 @@
sectionResults.Clear();
}
- public IEnumerable SectionResults
+ public IEnumerable SectionResults
{
get
{
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacrostabilityOutwardsFailureMechanism.cs
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacrostabilityOutwardsFailureMechanism.cs (.../MacrostabilityOutwardsFailureMechanism.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacrostabilityOutwardsFailureMechanism.cs (.../MacrostabilityOutwardsFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -30,17 +30,17 @@
///
/// Defines a stand alone failure mechanisms objects
///
- public class MacrostabilityOutwardsFailureMechanism : FailureMechanismBase, IHasSectionResults
+ public class MacrostabilityOutwardsFailureMechanism : FailureMechanismBase, IHasSectionResults
{
- private readonly IList sectionResults;
+ private readonly IList sectionResults;
///
/// Initializes a new instance of the class.
///
public MacrostabilityOutwardsFailureMechanism()
: base(Resources.MacrostabilityOutwardFailureMechanism_DisplayName, Resources.MacrostabilityOutwardFailureMechanism_Code)
{
- sectionResults = new List();
+ sectionResults = new List();
}
public override IEnumerable Calculations
@@ -55,7 +55,7 @@
{
base.AddSection(section);
- sectionResults.Add(new CustomFailureMechanismSectionResult(section));
+ sectionResults.Add(new CustomProbabilityFailureMechanismSectionResult(section));
}
public override void ClearAllSections()
@@ -64,7 +64,7 @@
sectionResults.Clear();
}
- public IEnumerable SectionResults
+ public IEnumerable SectionResults
{
get
{
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityPointConstructionFailureMechanism.cs
===================================================================
diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityPointConstructionFailureMechanism.cs (.../StrengthStabilityPointConstructionFailureMechanism.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityPointConstructionFailureMechanism.cs (.../StrengthStabilityPointConstructionFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -30,17 +30,17 @@
///
/// Defines a stand alone failure mechanisms objects
///
- public class StrengthStabilityPointConstructionFailureMechanism : FailureMechanismBase, IHasSectionResults
+ public class StrengthStabilityPointConstructionFailureMechanism : FailureMechanismBase, IHasSectionResults
{
- private readonly IList sectionResults;
+ private readonly IList sectionResults;
///
/// Initializes a new instance of the class.
///
public StrengthStabilityPointConstructionFailureMechanism()
: base(Resources.StrengthStabilityPointConstructionFailureMechanism_DisplayName, Resources.StrengthStabilityPointConstructionFailureMechanism_Code)
{
- sectionResults = new List();
+ sectionResults = new List();
}
public override IEnumerable Calculations
@@ -55,7 +55,7 @@
{
base.AddSection(section);
- sectionResults.Add(new CustomFailureMechanismSectionResult(section));
+ sectionResults.Add(new CustomProbabilityFailureMechanismSectionResult(section));
}
public override void ClearAllSections()
@@ -64,7 +64,7 @@
sectionResults.Clear();
}
- public IEnumerable SectionResults
+ public IEnumerable SectionResults
{
get
{
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/CustomProbabilityFailureMechanismContext.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/CustomProbabilityFailureMechanismContext.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/CustomProbabilityFailureMechanismContext.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,47 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+
+namespace Ringtoets.Integration.Forms.PresentationObjects
+{
+ ///
+ /// This class is a presentation object for an instance of ,
+ /// which has .
+ ///
+ public class CustomProbabilityFailureMechanismContext : FailureMechanismContext
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The failure mechanism.
+ /// The parent of .
+ /// Thrown when or are null.
+ public CustomProbabilityFailureMechanismContext(IFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) :
+ base(wrappedFailureMechanism, parent)
+ {
+
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r8ed27cd893d87ef66f1bc4f6936407dcff4a284c -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 8ed27cd893d87ef66f1bc4f6936407dcff4a284c)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -45,6 +45,7 @@
Properties\GlobalAssembly.cs
+
@@ -66,6 +67,9 @@
AssessmentSectionView.cs
+
+ UserControl
+ UserControl
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/CustomProbabilityFailureMechanismResultView.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/CustomProbabilityFailureMechanismResultView.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/CustomProbabilityFailureMechanismResultView.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,72 @@
+using System.Collections.Generic;
+using System.Windows.Forms;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.Properties;
+using Ringtoets.Common.Forms.Views;
+
+namespace Ringtoets.Integration.Forms.Views
+{
+ ///
+ /// This class defines a view where are displayed in a grid
+ /// and can be modified.
+ ///
+ public class CustomProbabilityFailureMechanismResultView : FailureMechanismResultView
+ {
+ ///
+ /// Creates a new instance of
+ ///
+ public CustomProbabilityFailureMechanismResultView()
+ {
+ AddCellFormattingHandler(OnCellFormatting);
+ }
+
+ private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs)
+ {
+ if (eventArgs.ColumnIndex > 1)
+ {
+ if (HasPassedLevelZero(eventArgs.RowIndex))
+ {
+ DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex);
+ }
+ else
+ {
+ RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex);
+ }
+ }
+ }
+
+ protected override IEnumerable GetDataGridColumns()
+ {
+ foreach (var baseColumn in base.GetDataGridColumns())
+ {
+ yield return baseColumn;
+ }
+
+ yield return new DataGridViewTextBoxColumn
+ {
+ DataPropertyName = "AssessmentLayerTwoA",
+ HeaderText = Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a,
+ Name = "column_AssessmentLayerTwoA"
+ };
+
+ yield return new DataGridViewTextBoxColumn
+ {
+ DataPropertyName = "AssessmentLayerTwoB",
+ HeaderText = Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b,
+ Name = "column_AssessmentLayerTwoB"
+ };
+
+ yield return new DataGridViewTextBoxColumn
+ {
+ DataPropertyName = "AssessmentLayerThree",
+ HeaderText = Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three,
+ Name = "column_AssessmentLayerThree"
+ };
+ }
+
+ protected override object CreateFailureMechanismSectionResultRow(CustomProbabilityFailureMechanismSectionResult sectionResult)
+ {
+ return new CustomProbabilityFailureMechanismSectionResultRow(sectionResult);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -r8ed27cd893d87ef66f1bc4f6936407dcff4a284c -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 8ed27cd893d87ef66f1bc4f6936407dcff4a284c)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -152,6 +152,15 @@
AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism
};
+ yield return new ViewInfo, IEnumerable, CustomProbabilityFailureMechanismResultView>
+ {
+ GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName,
+ Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon,
+ CloseForData = CloseCustomFailureMechanismResultViewForData,
+ GetViewData = context => context.SectionResults,
+ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism
+ };
+
yield return new ViewInfo, ICommentable, CommentView>
{
GetViewName = (v, o) => Resources.Comment_DisplayName,
@@ -268,6 +277,15 @@
.Build()
};
+ yield return new TreeNodeInfo>
+ {
+ Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName,
+ Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon,
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddOpenItem()
+ .Build()
+ };
+
yield return new TreeNodeInfo>
{
Text = comment => Resources.Comment_DisplayName,
@@ -324,30 +342,27 @@
private static bool CloseSimpleFailureMechanismResultViewForData(SimpleFailureMechanismResultView view, object o)
{
- var assessmentSection = o as IAssessmentSection;
- var failureMechanism = o as IFailureMechanism;
- var failureMechanismContext = o as IFailureMechanismContext;
var data = view.Data;
- if (assessmentSection != null)
- {
- return assessmentSection
- .GetFailureMechanisms()
- .OfType>()
- .Any(fm => ReferenceEquals(data, fm.SectionResults));
- }
- if (failureMechanismContext != null)
- {
- failureMechanism = failureMechanismContext.WrappedData;
- }
- return failureMechanism != null && ReferenceEquals(data, ((IHasSectionResults)failureMechanism).SectionResults);
+ return CloseFailureMechanismResultViewForData(o, data);
}
private static bool CloseCustomFailureMechanismResultViewForData(CustomFailureMechanismResultView view, object o)
{
+ var data = view.Data;
+ return CloseFailureMechanismResultViewForData(o, data);
+ }
+
+ private static bool CloseCustomFailureMechanismResultViewForData(CustomProbabilityFailureMechanismResultView view, object o)
+ {
+ var data = view.Data;
+ return CloseFailureMechanismResultViewForData(o, data);
+ }
+
+ private static bool CloseFailureMechanismResultViewForData(object o, object data)
+ {
var assessmentSection = o as IAssessmentSection;
var failureMechanism = o as IFailureMechanism;
var failureMechanismContext = o as IFailureMechanismContext;
- var data = view.Data;
if (assessmentSection != null)
{
return assessmentSection
@@ -359,7 +374,7 @@
{
failureMechanism = failureMechanismContext.WrappedData;
}
- return failureMechanism != null && ReferenceEquals(data, ((IHasSectionResults)failureMechanism).SectionResults);
+ return failureMechanism != null && ReferenceEquals(data, ((IHasSectionResults) failureMechanism).SectionResults);
}
#endregion
@@ -461,6 +476,7 @@
var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism;
var customFailureMechanism = failureMechanism as IHasSectionResults;
+ var customProbabilityFailureMechanism = failureMechanism as IHasSectionResults;
var simpleFailureMechanism = failureMechanism as IHasSectionResults;
if (piping != null)
@@ -479,6 +495,10 @@
{
yield return new CustomFailureMechanismContext(customFailureMechanism as IFailureMechanism, nodeData);
}
+ else if (customProbabilityFailureMechanism != null)
+ {
+ yield return new CustomProbabilityFailureMechanismContext(customProbabilityFailureMechanism as IFailureMechanism, nodeData);
+ }
else if (simpleFailureMechanism != null)
{
yield return new SimpleFailureMechanismContext(simpleFailureMechanism as IFailureMechanism, nodeData);
@@ -560,6 +580,7 @@
{
var simple = nodeData as IHasSectionResults;
var custom = nodeData as IHasSectionResults;
+ var customProbability = nodeData as IHasSectionResults;
var failureMechanismSectionResultContexts = new object[1];
if (simple != null)
{
@@ -571,6 +592,11 @@
failureMechanismSectionResultContexts[0] =
new FailureMechanismSectionResultContext(custom.SectionResults, nodeData);
}
+ if (customProbability != null)
+ {
+ failureMechanismSectionResultContexts[0] =
+ new FailureMechanismSectionResultContext(customProbability.SectionResults, nodeData);
+ }
return failureMechanismSectionResultContexts;
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs
===================================================================
diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs (.../ClosingStructureFailureMechanismTest.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs (.../ClosingStructureFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -57,7 +57,7 @@
// Assert
Assert.AreEqual(1, failureMechanism.SectionResults.Count());
- Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
+ Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs (.../MacrostabilityInwardsFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs (.../MacrostabilityInwardsFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -57,7 +57,7 @@
// Assert
Assert.AreEqual(1, failureMechanism.SectionResults.Count());
- Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
+ Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs (.../MacrostabilityOutwardsFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs (.../MacrostabilityOutwardsFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -57,7 +57,7 @@
// Assert
Assert.AreEqual(1, failureMechanism.SectionResults.Count());
- Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
+ Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs
===================================================================
diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs (.../StrengthStabilityPointConstructionFailureMechanismTest.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs (.../StrengthStabilityPointConstructionFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -57,7 +57,7 @@
// Assert
Assert.AreEqual(1, failureMechanism.SectionResults.Count());
- Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
+ Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0));
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/CustomProbabilityFailureMechanismContextTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/CustomProbabilityFailureMechanismContextTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/CustomProbabilityFailureMechanismContextTest.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,55 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.PresentationObjects;
+
+namespace Ringtoets.Integration.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class CustomProbabilityFailureMechanismContextTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new TestFailureMechanism();
+
+ // Call
+ var context = new CustomProbabilityFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf>(context);
+ Assert.AreSame(failureMechanism, context.WrappedData);
+ Assert.AreSame(assessmentSection, context.Parent);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r8ed27cd893d87ef66f1bc4f6936407dcff4a284c -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 8ed27cd893d87ef66f1bc4f6936407dcff4a284c)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -59,6 +59,7 @@
+
@@ -80,6 +81,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs
===================================================================
diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -142,7 +142,9 @@
var failureMechanisms = new IFailureMechanism[]
{
new PipingFailureMechanism(),
- new MacrostabilityInwardsFailureMechanism()
+ new MacrostabilityInwardsFailureMechanism(),
+ new GrassCoverErosionOutwardsFailureMechanism(),
+ new WaterPressureAsphaltCoverFailureMechanism()
};
var contribution = new FailureMechanismContribution(failureMechanisms, 10.0, 2);
@@ -158,7 +160,7 @@
var objects = info.ChildNodeObjects(assessmentSection).ToArray();
// Assert
- Assert.AreEqual(6, objects.Length);
+ Assert.AreEqual(8, objects.Length);
var referenceLineContext = (ReferenceLineContext) objects[0];
Assert.AreSame(assessmentSection.ReferenceLine, referenceLineContext.WrappedData);
Assert.AreSame(assessmentSection, referenceLineContext.Parent);
@@ -178,9 +180,17 @@
Assert.AreSame(failureMechanisms[0], pipingFailureMechanismContext.WrappedData);
Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent);
- var macroStabilityFailureMechanismContext = (CustomFailureMechanismContext)objects[5];
+ var macroStabilityFailureMechanismContext = (CustomProbabilityFailureMechanismContext)objects[5];
Assert.AreSame(failureMechanisms[1], macroStabilityFailureMechanismContext.WrappedData);
Assert.AreSame(assessmentSection, macroStabilityFailureMechanismContext.Parent);
+
+ var grassCoverErosionOutwardsFailureMechanismContext = (SimpleFailureMechanismContext)objects[6];
+ Assert.AreSame(failureMechanisms[2], grassCoverErosionOutwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, grassCoverErosionOutwardsFailureMechanismContext.Parent);
+
+ var waterPressureAsphaltCoverFailureMechanismContext = (CustomFailureMechanismContext)objects[7];
+ Assert.AreSame(failureMechanisms[3], waterPressureAsphaltCoverFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, waterPressureAsphaltCoverFailureMechanismContext.Parent);
}
mocks.VerifyAll();
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/CustomProbabilityFailureMechanismResultViewTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/CustomProbabilityFailureMechanismResultViewTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/CustomProbabilityFailureMechanismResultViewTest.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,249 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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.Drawing;
+using System.Windows.Forms;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.Properties;
+using Ringtoets.Integration.Forms.Views;
+
+namespace Ringtoets.Integration.Forms.Test.Views
+{
+ [TestFixture]
+ public class CustomProbabilityFailureMechanismResultViewTest
+ {
+ [Test]
+ public void GivenFormWithCustomProbabilityFailureMechanismResultView_ThenExpectedColumnsAreVisible()
+ {
+ // Given
+ using (var form = new Form())
+ {
+ using (var view = new CustomProbabilityFailureMechanismResultView())
+ {
+ form.Controls.Add(view);
+ form.Show();
+
+ // Then
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+
+ Assert.AreEqual(5, dataGridView.ColumnCount);
+
+ Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]);
+ Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]);
+ Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoBIndex]);
+ Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]);
+
+ Assert.AreEqual(Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, dataGridView.Columns[assessmentLayerOneIndex].HeaderText);
+ Assert.AreEqual(Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText);
+ Assert.AreEqual(Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b, dataGridView.Columns[assessmentLayerTwoBIndex].HeaderText);
+ Assert.AreEqual(Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three, dataGridView.Columns[assessmentLayerThreeIndex].HeaderText);
+
+ Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode);
+ Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenFormWithCustomProbabilityFailureMechanismResultView_WhenDataSourceWithCustomProbabilityFailureMechanismSectionResultAssigned_ThenSectionsAddedAsRows()
+ {
+ // Given
+ var section1 = new FailureMechanismSection("Section 1", new[]
+ {
+ new Point2D(0, 0)
+ });
+ var section2 = new FailureMechanismSection("Section 2", new[]
+ {
+ new Point2D(0, 0)
+ });
+ Random random = new Random(21);
+ var result1 = new CustomProbabilityFailureMechanismSectionResult(section1)
+ {
+ AssessmentLayerOne = true,
+ AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(),
+ AssessmentLayerTwoB = (RoundedDouble) random.NextDouble(),
+ AssessmentLayerThree = (RoundedDouble) random.NextDouble()
+ };
+ var result2 = new CustomProbabilityFailureMechanismSectionResult(section2)
+ {
+ AssessmentLayerOne = false,
+ AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(),
+ AssessmentLayerTwoB = (RoundedDouble) random.NextDouble(),
+ AssessmentLayerThree = (RoundedDouble) random.NextDouble()
+ };
+
+ using (var form = new Form())
+ {
+ using (var view = new CustomProbabilityFailureMechanismResultView())
+ {
+ form.Controls.Add(view);
+ form.Show();
+
+ // When
+ view.Data = new[]
+ {
+ result1,
+ result2
+ };
+
+ // Then
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(2, rows.Count);
+
+ var cells = rows[0].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue);
+ Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value);
+ Assert.AreEqual(string.Format(Core.Common.Base.Properties.Resources.ProbabilityPerYearFormat, (RoundedDouble)(1/result1.AssessmentLayerTwoA)), cells[assessmentLayerTwoAIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", result1.AssessmentLayerTwoB), cells[assessmentLayerTwoBIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", result1.AssessmentLayerThree), cells[assessmentLayerThreeIndex].FormattedValue);
+
+ AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]);
+ AssertCellIsDisabled(cells[assessmentLayerTwoBIndex]);
+ AssertCellIsDisabled(cells[assessmentLayerThreeIndex]);
+
+ cells = rows[1].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue);
+ Assert.AreEqual(result2.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value);
+ Assert.AreEqual(string.Format(Core.Common.Base.Properties.Resources.ProbabilityPerYearFormat, (RoundedDouble)(1 / result2.AssessmentLayerTwoA)), cells[assessmentLayerTwoAIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", result2.AssessmentLayerTwoB), cells[assessmentLayerTwoBIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", result2.AssessmentLayerThree), cells[assessmentLayerThreeIndex].FormattedValue);
+
+ AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]);
+ AssertCellIsEnabled(cells[assessmentLayerTwoBIndex]);
+ AssertCellIsEnabled(cells[assessmentLayerThreeIndex]);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenFormWithSimpleFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled()
+ {
+ // Given
+ var section = new FailureMechanismSection("Section 1", new[]
+ {
+ new Point2D(0, 0)
+ });
+ Random random = new Random(21);
+ var result = new CustomProbabilityFailureMechanismSectionResult(section)
+ {
+ AssessmentLayerOne = false,
+ AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(),
+ AssessmentLayerTwoB = (RoundedDouble)random.NextDouble(),
+ AssessmentLayerThree = (RoundedDouble)random.NextDouble()
+ };
+ using (var form = new Form())
+ {
+ using (var view = new CustomProbabilityFailureMechanismResultView())
+ {
+ form.Controls.Add(view);
+ form.Show();
+
+ view.Data = new[]
+ {
+ result
+ };
+
+ // When
+ result.AssessmentLayerOne = true;
+ result.NotifyObservers();
+
+ // Then
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(1, rows.Count);
+
+ var cells = rows[0].Cells;
+ Assert.AreEqual(5, cells.Count);
+
+ AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]);
+ AssertCellIsDisabled(cells[assessmentLayerTwoBIndex]);
+ AssertCellIsDisabled(cells[assessmentLayerThreeIndex]);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenFormWithCustomProbabilityFailureMechanismResultView_WhenDataSourceWithOtherFailureMechanismSectionResultAssigned_ThenSectionsNotAdded()
+ {
+ // Given
+ var section1 = new FailureMechanismSection("Section 1", new[]
+ {
+ new Point2D(0, 0)
+ });
+ var section2 = new FailureMechanismSection("Section 2", new[]
+ {
+ new Point2D(0, 0)
+ });
+ var result1 = new TestFailureMechanismSectionResult(section1);
+ var result2 = new TestFailureMechanismSectionResult(section2);
+
+ using (var form = new Form())
+ {
+ using (var view = new CustomProbabilityFailureMechanismResultView())
+ {
+ form.Controls.Add(view);
+ form.Show();
+
+ // When
+ view.Data = new[]
+ {
+ result1,
+ result2
+ };
+
+ // Then
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(0, rows.Count);
+ }
+ }
+ }
+
+ private const int nameColumnIndex = 0;
+ private const int assessmentLayerOneIndex = 1;
+ private const int assessmentLayerTwoAIndex = 2;
+ private const int assessmentLayerTwoBIndex = 3;
+ private const int assessmentLayerThreeIndex = 4;
+
+ private void AssertCellIsDisabled(DataGridViewCell dataGridViewCell)
+ {
+ Assert.AreEqual(true, dataGridViewCell.ReadOnly);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor);
+ }
+
+ private void AssertCellIsEnabled(DataGridViewCell dataGridViewCell)
+ {
+ Assert.AreEqual(false, dataGridViewCell.ReadOnly);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -r209bfd7b71ef53a57e1a52337f1333d38122282f -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 209bfd7b71ef53a57e1a52337f1333d38122282f)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -70,6 +70,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs
===================================================================
diff -u -r8ed27cd893d87ef66f1bc4f6936407dcff4a284c -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 8ed27cd893d87ef66f1bc4f6936407dcff4a284c)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -225,7 +225,7 @@
ViewInfo[] viewInfos = guiPlugin.GetViewInfos().ToArray();
// Assert
- Assert.AreEqual(5, viewInfos.Length);
+ Assert.AreEqual(6, viewInfos.Length);
var contributionViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismContributionContext));
Assert.AreEqual(typeof(FailureMechanismContributionView), contributionViewInfo.ViewType);
@@ -240,6 +240,11 @@
Assert.AreEqual(typeof(CustomFailureMechanismResultView), resultViewInfo.ViewType);
TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, resultViewInfo.Image);
+ var customProbabilityresultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext));
+ Assert.AreEqual(typeof(IEnumerable), customProbabilityresultViewInfo.ViewDataType);
+ Assert.AreEqual(typeof(CustomProbabilityFailureMechanismResultView), customProbabilityresultViewInfo.ViewType);
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, customProbabilityresultViewInfo.Image);
+
var simpleResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext));
Assert.AreEqual(typeof(IEnumerable), simpleResultViewInfo.ViewDataType);
Assert.AreEqual(typeof(SimpleFailureMechanismResultView), simpleResultViewInfo.ViewType);
@@ -273,7 +278,7 @@
TreeNodeInfo[] treeNodeInfos = guiPlugin.GetTreeNodeInfos().ToArray();
// Assert
- Assert.AreEqual(10, treeNodeInfos.Length);
+ Assert.AreEqual(11, treeNodeInfos.Length);
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(IAssessmentSection)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ReferenceLineContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContext)));
@@ -283,6 +288,7 @@
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CommentContext)));
}
mocks.VerifyAll();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CustomProbabilityFailureMechanismResultViewInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CustomProbabilityFailureMechanismResultViewInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CustomProbabilityFailureMechanismResultViewInfoTest.cs (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -0,0 +1,316 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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.Collections.Generic;
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Views;
+using Ringtoets.Piping.Data;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class CustomProbabilityFailureMechanismResultViewInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsGuiPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsGuiPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(CustomProbabilityFailureMechanismResultView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.DataType);
+ Assert.AreEqual(typeof(IEnumerable), info.ViewDataType);
+ }
+
+ [Test]
+ public void GetViewData_Always_ReturnsWrappedFailureMechanismResult()
+ {
+ // Setup
+ var failureMechanism = new Simple();
+ var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism);
+ mocks.ReplayAll();
+
+ // Call
+ var viewData = info.GetViewData(context);
+
+ // Assert
+ Assert.AreSame(failureMechanism.SectionResults, viewData);
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsViewName()
+ {
+ // Setup
+ var failureMechanism = new Simple();
+ var viewMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ // Call
+ var viewName = info.GetViewName(viewMock, failureMechanism.SectionResults);
+
+ // Assert
+ Assert.AreEqual("Oordeel", viewName);
+ }
+
+ [Test]
+ public void ViewType_Always_ReturnsViewType()
+ {
+ // Call
+ var viewType = info.ViewType;
+
+ // Assert
+ Assert.AreEqual(typeof(CustomProbabilityFailureMechanismResultView), viewType);
+ }
+
+ [Test]
+ public void DataType_Always_ReturnsDataType()
+ {
+ // Call
+ var dataType = info.DataType;
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), dataType);
+ }
+
+ [Test]
+ public void ViewDataType_Always_ReturnsViewDataType()
+ {
+ // Call
+ var viewDataType = info.ViewDataType;
+
+ // Assert
+ Assert.AreEqual(typeof(IEnumerable), viewDataType);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Call
+ var image = info.Image;
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image);
+ }
+
+ [Test]
+ public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var failureMechanism = new Simple();
+
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+ assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]);
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, assessmentSectionMock);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var failureMechanismMock = mocks.Stub("N", "C");
+ var failureMechanism = new Simple();
+
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+ assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[]
+ {
+ failureMechanismMock
+ });
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, assessmentSectionMock);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var failureMechanism = new Simple();
+
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+ assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[]
+ {
+ new PipingFailureMechanism(),
+ failureMechanism
+ });
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, assessmentSectionMock);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var failureMechanism = new Simple();
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, failureMechanism);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var failureMechanism = new Simple();
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, new Simple());
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var failureMechanismContext = mocks.StrictMock>();
+ var failureMechanism = new Simple();
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+ failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism);
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, failureMechanismContext);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var failureMechanismContext = mocks.StrictMock>();
+ var failureMechanism = new Simple();
+ viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults);
+ failureMechanismContext.Expect(fm => fm.WrappedData).Return(new Simple());
+
+ mocks.ReplayAll();
+
+ // Call
+ var closeForData = info.CloseForData(viewMock, failureMechanismContext);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ [Test]
+ public void AfterCreate_Always_SetsSpecificPropertiesToView()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var failureMechanism = new Simple();
+ var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism);
+
+ viewMock.Expect(v => v.FailureMechanism = failureMechanism);
+
+ mocks.ReplayAll();
+
+ // Call
+ info.AfterCreate(viewMock, context);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ private class Simple : FailureMechanismBase, IHasSectionResults
+ {
+ public Simple() : base("simple failure mechanism", "simple code")
+ {
+ SectionResults = new List();
+ }
+
+ public IEnumerable SectionResults { get; private set; }
+
+ public override IEnumerable Calculations
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs
===================================================================
diff -u -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f -ra883652e0cf7e59e4d086472939379ad9be36472
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472)
@@ -30,6 +30,8 @@
using Ringtoets.Common.Forms.Views;
using Ringtoets.Piping.Data;
+using CoreCommonResources = Core.Common.Base.Properties.Resources;
+
namespace Ringtoets.Piping.Forms.Views
{
///