Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/ArbitraryProbabilityFailureMechanismSectionResult.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/ArbitraryProbabilityFailureMechanismSectionResult.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/ArbitraryProbabilityFailureMechanismSectionResult.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,73 @@ +// 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 results of different layers (1, 2a, 2b, 3) of results of the + /// . The result for a layer 2a assessment is an arbitrary + /// probability. + /// + public class ArbitraryProbabilityFailureMechanismSectionResult : FailureMechanismSectionResult + { + private RoundedDouble assessmentLayerTwoA; + + /// + /// Creates a new instance of + /// + /// The section for which to add the result. + public ArbitraryProbabilityFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + + /// + /// Gets the value of assessment layer two a. + /// + /// Thrown when is not in range [0,1]. + public RoundedDouble AssessmentLayerTwoA + { + get + { + return assessmentLayerTwoA; + } + set + { + if (value < 0 || value > 1) + { + throw new ArgumentException(Resources.ArbitraryProbabilityFailureMechanismSectionResult_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 Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/CustomFailureMechanismSectionResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/CustomProbabilityFailureMechanismSectionResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/NumericFailureMechanismSectionResult.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/NumericFailureMechanismSectionResult.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/NumericFailureMechanismSectionResult.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,54 @@ +// 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 Core.Common.Base.Data; + +namespace Ringtoets.Common.Data.FailureMechanism +{ + /// + /// Class which represents results of different layers (1, 2a, 2b, 3) of results of the + /// . The result for a layer 2a assessment is an arbitrary + /// numeric value. + /// + public class NumericFailureMechanismSectionResult: FailureMechanismSectionResult + { + /// + /// Creates a new instance of + /// + /// The section for which to add the result. + public NumericFailureMechanismSectionResult(FailureMechanismSection section) : base(section) { } + + /// + /// Gets the value of assessment layer two a. + /// + public RoundedDouble AssessmentLayerTwoA { get; set; } + + /// + /// 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/FailureMechanism/SimpleFailureMechanismSectionResult.cs =================================================================== diff -u -r8abb584035c1788f6e1d92985da399a9921e3a09 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/SimpleFailureMechanismSectionResult.cs (.../SimpleFailureMechanismSectionResult.cs) (revision 8abb584035c1788f6e1d92985da399a9921e3a09) +++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/SimpleFailureMechanismSectionResult.cs (.../SimpleFailureMechanismSectionResult.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -24,8 +24,9 @@ namespace Ringtoets.Common.Data.FailureMechanism { /// - /// Class which represents a result for a failure mechanism section with three possible outcomes - /// for a layer 2a assessment. + /// Class which represents results of different layers (1, 2a, 2b, 3) of results of the + /// . The result for a layer 2a assessment is any of + /// three possible outcomes: 'successful', 'failed' or 'not calculated'. /// public class SimpleFailureMechanismSectionResult : FailureMechanismSectionResult { Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -61,6 +61,16 @@ } /// + /// Looks up a localized string similar to De waarde voor de faalkans moet in het bereik [0,1] liggen.. + /// + public static string ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1 { + get { + return ResourceManager.GetString("ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs" + + "_to_be_between_0_and_1", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Onvoldoende. /// public static string AssessmentLayerTwoAResult_Failed { @@ -133,16 +143,6 @@ } /// - /// 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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -210,7 +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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -52,8 +52,8 @@ - - + + Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r0d1a1a5d6962e334a56ec7fd0c83488c6f377ca3 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0d1a1a5d6962e334a56ec7fd0c83488c6f377ca3) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -71,6 +71,36 @@ } /// + /// Looks up a localized string similar to De waarde voor toetslaag 2a kon niet geïnterpreteerd worden als een getal.. + /// + public static string ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_value { + get { + return ResourceManager.GetString("ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_no" + + "t_parse_string_to_double_value", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De waarde voor toetslaag 2a moet ingevuld zijn.. + /// + public static string ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null { + get { + return ResourceManager.GetString("ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_ca" + + "nnot_be_null", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De waarde voor toetslaag 2a is te groot of te klein.. + /// + public static string ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large { + get { + return ResourceManager.GetString("ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_to" + + "o_large", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Be&rekenen. /// public static string Calculate { @@ -321,6 +351,15 @@ } /// + /// Looks up a localized string similar to De tekst mag niet leeg zijn.. + /// + public static string DataGridViewCellValidating_Text_may_not_be_empty { + get { + return ResourceManager.GetString("DataGridViewCellValidating_Text_may_not_be_empty", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap EditDocumentIcon { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -rf5ac9de8b45cef4515fa7a051c5af54446f96712 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision f5ac9de8b45cef4515fa7a051c5af54446f96712) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -328,6 +328,15 @@ ..\Resources\table.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + De waarde voor toetslaag 2a kon niet geïnterpreteerd worden als een getal. + + + De waarde voor toetslaag 2a is te groot of te klein. + + + De waarde voor toetslaag 2a moet ingevuld zijn. + De gemiddelde waarde van de lognormale verdeling. Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -rf5ac9de8b45cef4515fa7a051c5af54446f96712 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision f5ac9de8b45cef4515fa7a051c5af54446f96712) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -75,8 +75,8 @@ CommentView.cs - - + + UserControl Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/ArbitraryProbabilityFailureMechanismSectionResultRow.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/ArbitraryProbabilityFailureMechanismSectionResultRow.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/ArbitraryProbabilityFailureMechanismSectionResultRow.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,148 @@ +// 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.Properties; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.Common.Forms.Views +{ + /// + /// Container of a , which takes care of the + /// representation of properties in a grid. + /// + public class ArbitraryProbabilityFailureMechanismSectionResultRow + { + /// + /// Creates a new instance of . + /// + /// The that is + /// the source of this row. + /// Throw when is + /// null. + public ArbitraryProbabilityFailureMechanismSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) + { + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + SectionResult = sectionResult; + } + + /// + /// Gets the name of the failure mechanism section. + /// + public string Name + { + get + { + return SectionResult.Section.Name; + } + } + + /// + /// Gets or sets the value representing whether the section passed the layer 0 assessment. + /// + public bool AssessmentLayerOne + { + get + { + return SectionResult.AssessmentLayerOne; + } + set + { + SectionResult.AssessmentLayerOne = value; + SectionResult.NotifyObservers(); + } + } + + /// + /// Gets or sets the value representing the result of the layer 2a assessment. + /// + /// Thrown when is null. + /// Thrown when either: + /// + /// is not in the range [0,1] + /// doesn't represent a value which can be parsed to a double value + /// + /// + public string AssessmentLayerTwoA + { + get + { + var d = (RoundedDouble) (1/SectionResult.AssessmentLayerTwoA); + return string.Format(Resources.ProbabilityPerYearFormat, d); + } + set + { + if (value == null) + { + throw new ArgumentNullException("value",Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null); + } + try + { + SectionResult.AssessmentLayerTwoA = (RoundedDouble) double.Parse(value); + } + catch (OverflowException) + { + throw new ArgumentException(Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large); + } + catch (FormatException) + { + throw new ArgumentException(Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_value); + } + } + } + + /// + /// Gets or sets the value representing the result of the layer 2b assessment. + /// + public RoundedDouble AssessmentLayerTwoB + { + get + { + return SectionResult.AssessmentLayerTwoB; + } + set + { + SectionResult.AssessmentLayerTwoB = value; + } + } + + /// + /// Gets or sets the value representing the result of the layer 3 assessment. + /// + public RoundedDouble AssessmentLayerThree + { + get + { + return SectionResult.AssessmentLayerThree; + } + set + { + SectionResult.AssessmentLayerThree = value; + } + } + + private ArbitraryProbabilityFailureMechanismSectionResult SectionResult { get; set; } + } +} \ No newline at end of file Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomFailureMechanismSectionResultRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomProbabilityFailureMechanismSectionResultRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/NumericFailureMechanismSectionResultRow.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/NumericFailureMechanismSectionResultRow.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/NumericFailureMechanismSectionResultRow.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,124 @@ +// 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 +{ + /// + /// Container of a , which takes care of the + /// representation of properties in a grid. + /// + public class NumericFailureMechanismSectionResultRow + { + /// + /// Creates a new instance of . + /// + /// The that is + /// the source of this row. + /// Throw when is + /// null. + public NumericFailureMechanismSectionResultRow(NumericFailureMechanismSectionResult sectionResult) + { + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + SectionResult = sectionResult; + } + + /// + /// Gets the name of the failure mechanism section. + /// + public string Name + { + get + { + return SectionResult.Section.Name; + } + } + + /// + /// Gets or sets the value representing whether the section passed the layer 0 assessment. + /// + public bool AssessmentLayerOne + { + get + { + return SectionResult.AssessmentLayerOne; + } + set + { + SectionResult.AssessmentLayerOne = value; + SectionResult.NotifyObservers(); + } + } + + /// + /// Gets or sets the value representing the result of the layer 2a assessment. + /// + public RoundedDouble AssessmentLayerTwoA + { + get + { + return SectionResult.AssessmentLayerTwoA; + } + set + { + SectionResult.AssessmentLayerTwoA = value; + } + } + + /// + /// Gets or sets the value representing the result of the layer 2b assessment. + /// + public RoundedDouble AssessmentLayerTwoB + { + get + { + return SectionResult.AssessmentLayerTwoB; + } + set + { + SectionResult.AssessmentLayerTwoB = value; + } + } + + /// + /// Gets or sets the value representing the result of the layer 3 assessment. + /// + public RoundedDouble AssessmentLayerThree + { + get + { + return SectionResult.AssessmentLayerThree; + } + set + { + SectionResult.AssessmentLayerThree = value; + } + } + + private NumericFailureMechanismSectionResult SectionResult { get; set; } + } +} \ No newline at end of file Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomFailureMechanismSectionResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomPropertyFailureMechanismSectionResultTest.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomPropertyFailureMechanismSectionResultTest.cs (.../CustomPropertyFailureMechanismSectionResultTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomPropertyFailureMechanismSectionResultTest.cs (.../CustomPropertyFailureMechanismSectionResultTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -34,7 +34,7 @@ public void Constructor_WithoutSection_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new CustomProbabilityFailureMechanismSectionResult(null); + TestDelegate test = () => new ArbitraryProbabilityFailureMechanismSectionResult(null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -48,7 +48,7 @@ var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); // Call - var result = new CustomProbabilityFailureMechanismSectionResult(section); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); // Assert Assert.IsInstanceOf(result); @@ -68,15 +68,15 @@ { // Setup var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); - var result = new CustomProbabilityFailureMechanismSectionResult(section); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(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, + Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, message ); } @@ -91,7 +91,7 @@ { // Setup var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); - var result = new CustomProbabilityFailureMechanismSectionResult(section); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); var assessmentLayerTwoAValue = (RoundedDouble)a; Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/NumericFailureMechanismSectionResultTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/NumericFailureMechanismSectionResultTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/NumericFailureMechanismSectionResultTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,61 @@ +// 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.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.Common.Data.Test.FailureMechanism +{ + [TestFixture] + public class NumericFailureMechanismSectionResultTest + { + [Test] + public void Constructor_WithoutSection_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new NumericFailureMechanismSectionResult(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 NumericFailureMechanismSectionResult(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); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -64,7 +64,7 @@ - + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -rf5ac9de8b45cef4515fa7a051c5af54446f96712 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision f5ac9de8b45cef4515fa7a051c5af54446f96712) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -75,8 +75,8 @@ - - + + UserControl Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/ArbitraryProbabilityFailureMechanismSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/ArbitraryProbabilityFailureMechanismSectionResultRowTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/ArbitraryProbabilityFailureMechanismSectionResultRowTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,250 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Views; + +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Ringtoets.Common.Forms.Test.Views +{ + [TestFixture] + public class ArbitraryProbabilityFailureMechanismSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ArbitraryProbabilityFailureMechanismSectionResultRow(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 ArbitraryProbabilityFailureMechanismSectionResult(section); + + // Call + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(result); + + // Assert + Assert.AreEqual(section.Name, row.Name); + Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne); + + var expected2AValue = (RoundedDouble) (1 / result.AssessmentLayerTwoA); + var expected2AValueString = string.Format( + CoreCommonBaseResources.ProbabilityPerYearFormat, + expected2AValue + ); + Assert.AreEqual( + expected2AValueString, + 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 ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(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 ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(result); + + // Call + row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var expected = string.Format(CoreCommonBaseResources.ProbabilityPerYearFormat, newValue); + var actual = string.Format(CoreCommonBaseResources.ProbabilityPerYearFormat, result.AssessmentLayerTwoA); + Assert.AreEqual(expected, actual); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsArgumentException(double value) + { + // Setup + var newValue = (RoundedDouble)value; + var section = CreateSection(); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Data.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message + ); + } + + [Test] + [TestCase(double.MaxValue + 1)] + [TestCase(double.MinValue - 1)] + public void AssessmentLayerTwoA_ForTooLargeValues_ThrowsArgumentException(double value) + { + // Setup + var newValue = (RoundedDouble)value; + var section = CreateSection(); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large, + message + ); + } + + [Test] + [TestCase("many")] + [TestCase("")] + public void AssessmentLayerTwoA_ForNonNumericValues_ThrowsArgumentException(string value) + { + // Setup + var section = CreateSection(); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = value; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_value, + message + ); + } + + [Test] + public void AssessmentLayerTwoA_ForNullValue_ThrowsArgumentException() + { + // Setup + var section = CreateSection(); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = (string) null; + + // Assert + var expectedMessage = Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void AssessmentLayerTwoB_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(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 ArbitraryProbabilityFailureMechanismSectionResult(section); + var row = new ArbitraryProbabilityFailureMechanismSectionResultRow(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 Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomFailureMechanismSectionResultRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomProbabilityFailureMechanismSectionResultRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/NumericFailureMechanismSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/NumericFailureMechanismSectionResultRowTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/NumericFailureMechanismSectionResultRowTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,149 @@ +// 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 NumericFailureMechanismSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new NumericFailureMechanismSectionResultRow(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 NumericFailureMechanismSectionResult(section); + + // Call + var row = new NumericFailureMechanismSectionResultRow(result); + + // Assert + Assert.AreEqual(section.Name, row.Name); + Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne); + Assert.AreEqual(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 NumericFailureMechanismSectionResult(section); + var row = new NumericFailureMechanismSectionResultRow(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] + public void AssessmentLayerTwoA_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new NumericFailureMechanismSectionResult(section); + var row = new NumericFailureMechanismSectionResultRow(result); + + // Call + row.AssessmentLayerTwoA = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerTwoA, row.AssessmentLayerTwoA.GetAccuracy()); + } + + [Test] + public void AssessmentLayerTwoB_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new NumericFailureMechanismSectionResult(section); + var row = new NumericFailureMechanismSectionResultRow(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 NumericFailureMechanismSectionResult(section); + var row = new NumericFailureMechanismSectionResultRow(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/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs =================================================================== diff -u -r4d2271ee60b40225ccfeb4a8eadc40c7e0fae357 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 4d2271ee60b40225ccfeb4a8eadc40c7e0fae357) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -22,6 +22,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.Views; @@ -82,10 +83,20 @@ protected override void AddDataGridColumns() { base.AddDataGridColumns(); - - DataGridViewControl.AddTextBoxColumn("AssessmentLayerTwoA", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, true); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerTwoB", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerThree", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); + + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, + true + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoB), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); } protected override object CreateFailureMechanismSectionResultRow(GrassCoverErosionInwardsFailureMechanismSectionResult sectionResult) Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs =================================================================== diff -u -r89e5c41b732ccf30350026e8d35a01d9a180fdfc -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs (.../HeightStructuresFailureMechanismTest.cs) (revision 89e5c41b732ccf30350026e8d35a01d9a180fdfc) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs (.../HeightStructuresFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -52,7 +52,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedHeightStructuresFailureMechanismResult() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs (.../ClosingStructureFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/ClosingStructureFailureMechanism.cs (.../ClosingStructureFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 CustomProbabilityFailureMechanismSectionResult(section)); + sectionResults.Add(new ArbitraryProbabilityFailureMechanismSectionResult(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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacroStabilityInwardsFailureMechanism.cs (.../MacroStabilityInwardsFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacroStabilityInwardsFailureMechanism.cs (.../MacroStabilityInwardsFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 CustomProbabilityFailureMechanismSectionResult(section)); + sectionResults.Add(new ArbitraryProbabilityFailureMechanismSectionResult(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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacrostabilityOutwardsFailureMechanism.cs (.../MacrostabilityOutwardsFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/MacrostabilityOutwardsFailureMechanism.cs (.../MacrostabilityOutwardsFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 CustomProbabilityFailureMechanismSectionResult(section)); + sectionResults.Add(new ArbitraryProbabilityFailureMechanismSectionResult(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/StabilityStoneCoverFailureMechanism.cs =================================================================== diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StabilityStoneCoverFailureMechanism.cs (.../StabilityStoneCoverFailureMechanism.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StabilityStoneCoverFailureMechanism.cs (.../StabilityStoneCoverFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -30,17 +30,17 @@ /// /// Defines a stand alone failure mechanisms objects /// - public class StabilityStoneCoverFailureMechanism : FailureMechanismBase, IHasSectionResults + public class StabilityStoneCoverFailureMechanism : FailureMechanismBase, IHasSectionResults { - private readonly IList sectionResults; + private readonly IList sectionResults; /// /// Initializes a new instance of the class. /// public StabilityStoneCoverFailureMechanism() : base(Resources.StabilityStoneCoverFailureMechanism_DisplayName, Resources.StabilityStoneCoverFailureMechanism_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 NumericFailureMechanismSectionResult(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/StrengthStabilityLengthwiseConstructionFailureMechanism.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityLengthwiseConstructionFailureMechanism.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanism.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityLengthwiseConstructionFailureMechanism.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -30,17 +30,17 @@ /// /// Defines a stand alone failure mechanisms objects /// - public class StrengthStabilityLengthwiseConstructionFailureMechanism : FailureMechanismBase, IHasSectionResults + public class StrengthStabilityLengthwiseConstructionFailureMechanism : FailureMechanismBase, IHasSectionResults { - private readonly IList sectionResults; + private readonly IList sectionResults; /// /// Initializes a new instance of the class. /// public StrengthStabilityLengthwiseConstructionFailureMechanism() : base(Resources.StrengthStabilityLengthwiseConstructionFailureMechanism_DisplayName, Resources.StrengthStabilityLengthwiseConstructionFailureMechanism_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 NumericFailureMechanismSectionResult(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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityPointConstructionFailureMechanism.cs (.../StrengthStabilityPointConstructionFailureMechanism.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/StrengthStabilityPointConstructionFailureMechanism.cs (.../StrengthStabilityPointConstructionFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 CustomProbabilityFailureMechanismSectionResult(section)); + sectionResults.Add(new ArbitraryProbabilityFailureMechanismSectionResult(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/WaterPressureAsphaltCoverFailureMechanism.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/WaterPressureAsphaltCoverFailureMechanism.cs (.../WaterPressureAsphaltCoverFailureMechanism.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/WaterPressureAsphaltCoverFailureMechanism.cs (.../WaterPressureAsphaltCoverFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -30,17 +30,17 @@ /// /// Defines a stand alone failure mechanisms objects /// - public class WaterPressureAsphaltCoverFailureMechanism : FailureMechanismBase, IHasSectionResults + public class WaterPressureAsphaltCoverFailureMechanism : FailureMechanismBase, IHasSectionResults { - private readonly IList sectionResults; + private readonly IList sectionResults; /// /// Initializes a new instance of the class. /// public WaterPressureAsphaltCoverFailureMechanism() : base(Resources.WaterPressureAsphaltCoverFailureMechanism_DisplayName, Resources.WaterPressureAsphaltCoverFailureMechanism_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 NumericFailureMechanismSectionResult(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/WaveImpactAsphaltCoverFailureMechanism.cs =================================================================== diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/WaveImpactAsphaltCoverFailureMechanism.cs (.../WaveImpactAsphaltCoverFailureMechanism.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/WaveImpactAsphaltCoverFailureMechanism.cs (.../WaveImpactAsphaltCoverFailureMechanism.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -30,17 +30,17 @@ /// /// Defines a stand alone failure mechanisms objects /// - public class WaveImpactAsphaltCoverFailureMechanism : FailureMechanismBase, IHasSectionResults + public class WaveImpactAsphaltCoverFailureMechanism : FailureMechanismBase, IHasSectionResults { - private readonly IList sectionResults; + private readonly IList sectionResults; /// /// Initializes a new instance of the class. /// public WaveImpactAsphaltCoverFailureMechanism() : base(Resources.WaveImpactAsphaltCoverFailureMechanism_DisplayName, Resources.WaveImpactAsphaltCoverFailureMechanism_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 NumericFailureMechanismSectionResult(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/ArbitraryProbabilityFailureMechanismContext.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/ArbitraryProbabilityFailureMechanismContext.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/ArbitraryProbabilityFailureMechanismContext.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 ArbitraryProbabilityFailureMechanismContext : FailureMechanismContext + { + /// + /// Initializes a new instance of the class. + /// + /// The failure mechanism. + /// The parent of . + /// Thrown when or are null. + public ArbitraryProbabilityFailureMechanismContext(IFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) : + base(wrappedFailureMechanism, parent) + { + + } + } +} \ No newline at end of file Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/CustomFailureMechanismContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/CustomProbabilityFailureMechanismContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/NumericFailureMechanismContext.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/NumericFailureMechanismContext.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/NumericFailureMechanismContext.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 NumericFailureMechanismContext : FailureMechanismContext + { + /// + /// Initializes a new instance of the class. + /// + /// The failure mechanism. + /// The parent of . + /// Thrown when or are null. + public NumericFailureMechanismContext(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 -r219f8633c1b5b24f9e9aec3e903734fa94775f0e -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 219f8633c1b5b24f9e9aec3e903734fa94775f0e) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -45,8 +45,8 @@ Properties\GlobalAssembly.cs - - + + @@ -67,10 +67,10 @@ AssessmentSectionView.cs - + UserControl - + UserControl Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/ArbitraryProbabilityFailureMechanismResultView.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/ArbitraryProbabilityFailureMechanismResultView.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/ArbitraryProbabilityFailureMechanismResultView.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,82 @@ +// 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.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Views +{ + /// + /// This class defines a view where are displayed in a grid + /// and can be modified. + /// + public class ArbitraryProbabilityFailureMechanismResultView : FailureMechanismResultView + { + /// + /// Creates a new instance of + /// + public ArbitraryProbabilityFailureMechanismResultView() + { + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + } + + private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) + { + if (eventArgs.ColumnIndex > 1) + { + if (HasPassedLevelOne(eventArgs.RowIndex)) + { + DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + else + { + DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + } + } + + protected override void AddDataGridColumns() + { + base.AddDataGridColumns(); + + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoB), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); + } + + protected override object CreateFailureMechanismSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) + { + return new ArbitraryProbabilityFailureMechanismSectionResultRow(sectionResult); + } + } +} \ No newline at end of file Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/CustomFailureMechanismResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/CustomProbabilityFailureMechanismResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/NumericFailureMechanismResultView.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/NumericFailureMechanismResultView.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/NumericFailureMechanismResultView.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,82 @@ +// 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.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Views +{ + /// + /// This class defines a view where are displayed in a grid + /// and can be modified. + /// + public class NumericFailureMechanismResultView : FailureMechanismResultView + { + /// + /// Creates a new instance of + /// + public NumericFailureMechanismResultView() + { + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + } + + private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) + { + if (eventArgs.ColumnIndex > 1) + { + if (HasPassedLevelOne(eventArgs.RowIndex)) + { + DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + else + { + DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + } + } + + protected override void AddDataGridColumns() + { + base.AddDataGridColumns(); + + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoB), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); + } + + protected override object CreateFailureMechanismSectionResultRow(NumericFailureMechanismSectionResult sectionResult) + { + return new NumericFailureMechanismSectionResultRow(sectionResult); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SimpleFailureMechanismResultView.cs =================================================================== diff -u -rac1e7b044016869e0c2b7668171c0dbfe0be1788 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SimpleFailureMechanismResultView.cs (.../SimpleFailureMechanismResultView.cs) (revision ac1e7b044016869e0c2b7668171c0dbfe0be1788) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SimpleFailureMechanismResultView.cs (.../SimpleFailureMechanismResultView.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -24,6 +24,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Utils; +using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -69,13 +70,20 @@ .ToList(); DataGridViewControl.AddComboBoxColumn( - "AssessmentLayerTwoA", - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, dataSource, - o => o.Value, - o => o.DisplayName); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerTwoB", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerThree", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); + edw => edw.Value, + edw => edw.DisplayName + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoB), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); } protected override object CreateFailureMechanismSectionResultRow(SimpleFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -134,7 +134,10 @@ Image = RingtoetsFormsResources.Map }; - yield return new ViewInfo, IEnumerable, SimpleFailureMechanismResultView> + yield return new ViewInfo< + FailureMechanismSectionResultContext, + IEnumerable, + SimpleFailureMechanismResultView> { GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, @@ -143,20 +146,26 @@ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism }; - yield return new ViewInfo, IEnumerable, CustomFailureMechanismResultView> + yield return new ViewInfo< + FailureMechanismSectionResultContext, + IEnumerable, + NumericFailureMechanismResultView> { GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, - CloseForData = CloseCustomFailureMechanismResultViewForData, + CloseForData = CloseNumericFailureMechanismResultViewForData, GetViewData = context => context.SectionResults, AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism }; - yield return new ViewInfo, IEnumerable, CustomProbabilityFailureMechanismResultView> + yield return new ViewInfo< + FailureMechanismSectionResultContext, + IEnumerable, + ArbitraryProbabilityFailureMechanismResultView> { GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, - CloseForData = CloseCustomFailureMechanismResultViewForData, + CloseForData = CloseArbitraryProbabilityFailureMechanismResultViewForData, GetViewData = context => context.SectionResults, AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism }; @@ -268,7 +277,7 @@ .Build() }; - yield return new TreeNodeInfo> + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, @@ -277,7 +286,7 @@ .Build() }; - yield return new TreeNodeInfo> + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, @@ -346,13 +355,13 @@ return CloseFailureMechanismResultViewForData(o, data); } - private static bool CloseCustomFailureMechanismResultViewForData(CustomFailureMechanismResultView view, object o) + private static bool CloseNumericFailureMechanismResultViewForData(NumericFailureMechanismResultView view, object o) { var data = view.Data; return CloseFailureMechanismResultViewForData(o, data); } - private static bool CloseCustomFailureMechanismResultViewForData(CustomProbabilityFailureMechanismResultView view, object o) + private static bool CloseArbitraryProbabilityFailureMechanismResultViewForData(ArbitraryProbabilityFailureMechanismResultView view, object o) { var data = view.Data; return CloseFailureMechanismResultViewForData(o, data); @@ -363,6 +372,7 @@ var assessmentSection = o as IAssessmentSection; var failureMechanism = o as IFailureMechanism; var failureMechanismContext = o as IFailureMechanismContext; + if (assessmentSection != null) { return assessmentSection @@ -374,7 +384,12 @@ { failureMechanism = failureMechanismContext.WrappedData; } - return failureMechanism != null && ReferenceEquals(data, ((IHasSectionResults) failureMechanism).SectionResults); + + var failureMechanismWithSectionResults = failureMechanism as IHasSectionResults; + + return failureMechanism != null + && failureMechanismWithSectionResults != null + && ReferenceEquals(data, failureMechanismWithSectionResults.SectionResults); } #endregion @@ -475,8 +490,8 @@ var grassCoverErosionInwards = failureMechanism as GrassCoverErosionInwardsFailureMechanism; var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism; - var customFailureMechanism = failureMechanism as IHasSectionResults; - var customProbabilityFailureMechanism = failureMechanism as IHasSectionResults; + var numericFailureMechanism = failureMechanism as IHasSectionResults; + var probabilityFailureMechanism = failureMechanism as IHasSectionResults; var simpleFailureMechanism = failureMechanism as IHasSectionResults; if (piping != null) @@ -491,13 +506,13 @@ { yield return new HeightStructuresFailureMechanismContext(heightStructuresFailureMechanism, nodeData); } - else if (customFailureMechanism != null) + else if (numericFailureMechanism != null) { - yield return new CustomFailureMechanismContext(customFailureMechanism as IFailureMechanism, nodeData); + yield return new NumericFailureMechanismContext(numericFailureMechanism as IFailureMechanism, nodeData); } - else if (customProbabilityFailureMechanism != null) + else if (probabilityFailureMechanism != null) { - yield return new CustomProbabilityFailureMechanismContext(customProbabilityFailureMechanism as IFailureMechanism, nodeData); + yield return new ArbitraryProbabilityFailureMechanismContext(probabilityFailureMechanism as IFailureMechanism, nodeData); } else if (simpleFailureMechanism != null) { @@ -579,8 +594,8 @@ private IList GetOutputs(IFailureMechanism nodeData) { var simple = nodeData as IHasSectionResults; - var custom = nodeData as IHasSectionResults; - var customProbability = nodeData as IHasSectionResults; + var custom = nodeData as IHasSectionResults; + var arbitraryProbability = nodeData as IHasSectionResults; var failureMechanismSectionResultContexts = new object[1]; if (simple != null) { @@ -590,12 +605,12 @@ if (custom != null) { failureMechanismSectionResultContexts[0] = - new FailureMechanismSectionResultContext(custom.SectionResults, nodeData); + new FailureMechanismSectionResultContext(custom.SectionResults, nodeData); } - if (customProbability != null) + if (arbitraryProbability != null) { failureMechanismSectionResultContexts[0] = - new FailureMechanismSectionResultContext(customProbability.SectionResults, nodeData); + new FailureMechanismSectionResultContext(arbitraryProbability.SectionResults, nodeData); } return failureMechanismSectionResultContexts; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs (.../ClosingStructureFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs (.../ClosingStructureFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedArbitraryProbabilityFailureMechanismResult() { // Setup var failureMechanism = new ClosingStructureFailureMechanism(); @@ -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/GrassCoverSlipOffInwardsFailureMechanismTest.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/GrassCoverSlipOffInwardsFailureMechanismTest.cs (.../GrassCoverSlipOffInwardsFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/GrassCoverSlipOffInwardsFailureMechanismTest.cs (.../GrassCoverSlipOffInwardsFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedSimpleFailureMechanismResult() { // Setup var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs (.../MacrostabilityInwardsFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs (.../MacrostabilityInwardsFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedArbitraryProbabilityFailureMechanismResult() { // Setup var failureMechanism = new MacrostabilityInwardsFailureMechanism(); @@ -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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs (.../MacrostabilityOutwardsFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs (.../MacrostabilityOutwardsFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedArbitraryProbabilityFailureMechanismResult() { // Setup var failureMechanism = new MacrostabilityOutwardsFailureMechanism(); @@ -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/MicrostabilityFailureMechanismTest.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MicrostabilityFailureMechanismTest.cs (.../MicrostabilityFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MicrostabilityFailureMechanismTest.cs (.../MicrostabilityFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedSimpleFailureMechanismResult() { // Setup var failureMechanism = new MicrostabilityFailureMechanism(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StabilityStoneCoverFailureMechanismTest.cs =================================================================== diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StabilityStoneCoverFailureMechanismTest.cs (.../StabilityStoneCoverFailureMechanismTest.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StabilityStoneCoverFailureMechanismTest.cs (.../StabilityStoneCoverFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedNumericFailureMechanismResult() { // Setup var failureMechanism = new StabilityStoneCoverFailureMechanism(); @@ -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/StrengthStabilityLengthwiseConstructionFailureMechanismTest.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityLengthwiseConstructionFailureMechanismTest.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityLengthwiseConstructionFailureMechanismTest.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedNumericFailureMechanismResult() { // Setup var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); @@ -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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs (.../StrengthStabilityPointConstructionFailureMechanismTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs (.../StrengthStabilityPointConstructionFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedArbitraryProbabilityFailureMechanismResult() { // Setup var failureMechanism = new StrengthStabilityPointConstructionFailureMechanism(); @@ -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/TechnicalInnovationFailureMechanismTest.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/TechnicalInnovationFailureMechanismTest.cs (.../TechnicalInnovationFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/TechnicalInnovationFailureMechanismTest.cs (.../TechnicalInnovationFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedSimpleFailureMechanismResult() { // Setup var failureMechanism = new TechnicalInnovationFailureMechanism(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/WaterPressureAsphaltCoverFailureMechanismTest.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/WaterPressureAsphaltCoverFailureMechanismTest.cs (.../WaterPressureAsphaltCoverFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/WaterPressureAsphaltCoverFailureMechanismTest.cs (.../WaterPressureAsphaltCoverFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedNumericFailureMechanismResult() { // Setup var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); @@ -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/WaveImpactAsphaltCoverFailureMechanismTest.cs =================================================================== diff -u -r20bb156dfc129b1602ddbcddc73c0806807f19ab -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/WaveImpactAsphaltCoverFailureMechanismTest.cs (.../WaveImpactAsphaltCoverFailureMechanismTest.cs) (revision 20bb156dfc129b1602ddbcddc73c0806807f19ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/WaveImpactAsphaltCoverFailureMechanismTest.cs (.../WaveImpactAsphaltCoverFailureMechanismTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -44,7 +44,7 @@ } [Test] - public void AddSection_WithSection_AddedCustomFailureMechanismResult() + public void AddSection_WithSection_AddedNumericFailureMechanismResult() { // Setup var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); @@ -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/ArbitraryProbabilityFailureMechanismContextTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/ArbitraryProbabilityFailureMechanismContextTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/ArbitraryProbabilityFailureMechanismContextTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 ArbitraryProbabilityFailureMechanismContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new TestFailureMechanism(); + + // Call + var context = new ArbitraryProbabilityFailureMechanismContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(failureMechanism, context.WrappedData); + Assert.AreSame(assessmentSection, context.Parent); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/CustomFailureMechanismContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/CustomProbabilityFailureMechanismContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/NumericFailureMechanismContextTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/NumericFailureMechanismContextTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/NumericFailureMechanismContextTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 NumericFailureMechanismContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new TestFailureMechanism(); + + // Call + var context = new NumericFailureMechanismContext(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/PropertyClasses/StandAloneFailureMechanismContextPropertiesTest.cs =================================================================== diff -u -rdaa1008263412accdb1fcad949ddf100fb2e97b7 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAloneFailureMechanismContextPropertiesTest.cs (.../StandAloneFailureMechanismContextPropertiesTest.cs) (revision daa1008263412accdb1fcad949ddf100fb2e97b7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAloneFailureMechanismContextPropertiesTest.cs (.../StandAloneFailureMechanismContextPropertiesTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -62,14 +62,14 @@ } [Test] - public void Data_SetNewCustomFailureMechanismContextInstance_ReturnCorrectPropertyValues() + public void Data_SetNewNumericFailureMechanismContextInstance_ReturnCorrectPropertyValues() { // Setup var failureMechanism = new TestFailureMechanism(); var properties = new StandAloneFailureMechanismContextProperties(); // Call - properties.Data = new CustomFailureMechanismContext(failureMechanism, new MockRepository().StrictMock()); + properties.Data = new NumericFailureMechanismContext(failureMechanism, new MockRepository().StrictMock()); // Assert Assert.AreEqual(failureMechanism.Name, properties.Name); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -59,15 +59,16 @@ - + - + + @@ -76,13 +77,13 @@ - + - - + + Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ArbitraryProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ArbitraryProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ArbitraryProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,125 @@ +using System.Collections.Generic; +using System.Linq; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class ArbitraryProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest + { + private MockRepository mocks; + private RingtoetsGuiPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new RingtoetsGuiPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType); + + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnsName() + { + // Setup + mocks.ReplayAll(); + + var mechanism = new ArbitraryProbabilityFailureMechanism(); + var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Oordeel", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.GenericInputOutputIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var gui = mocks.StrictMultiMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); + + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + + // Assert + mocks.VerifyAll(); + } + + class ArbitraryProbabilityFailureMechanism : FailureMechanismBase, IHasSectionResults + { + public ArbitraryProbabilityFailureMechanism() + : base("N", "C") + { + SectionResults = new List(); + } + + public IEnumerable SectionResults { get; private set; } + + public override IEnumerable Calculations + { + get + { + throw new System.NotImplementedException(); + } + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -180,15 +180,15 @@ Assert.AreSame(failureMechanisms[0], pipingFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent); - var macroStabilityFailureMechanismContext = (CustomProbabilityFailureMechanismContext)objects[5]; + var macroStabilityFailureMechanismContext = (ArbitraryProbabilityFailureMechanismContext)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]; + var waterPressureAsphaltCoverFailureMechanismContext = (NumericFailureMechanismContext)objects[7]; Assert.AreSame(failureMechanisms[3], waterPressureAsphaltCoverFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, waterPressureAsphaltCoverFailureMechanismContext.Parent); } Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/CustomFailureMechanismSectionResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r1c8a44983627b9d580cbbeab3c8444c5ecc41524 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 1c8a44983627b9d580cbbeab3c8444c5ecc41524) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -88,7 +88,7 @@ mocks.ReplayAll(); var failureMechanism = new TestFailureMechanism("name", "code"); - var failureMechanismContext = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var failureMechanismContext = new NumericFailureMechanismContext(failureMechanism, assessmentSection); using (var plugin = new RingtoetsGuiPlugin()) { @@ -130,7 +130,7 @@ mocks.ReplayAll(); var failureMechanism = new TestFailureMechanism("C", "C"); - var context = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var context = new NumericFailureMechanismContext(failureMechanism, assessmentSection); // Call var textColor = info.ForeColor(context); @@ -193,9 +193,9 @@ { var info = GetInfo(plugin); - var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism)); + var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism)); failureMechanism.Expect(fm => ((IFailureMechanism) fm).IsRelevant).Return(true); - failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any(); + failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any(); var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection); mocks.ReplayAll(); @@ -204,7 +204,7 @@ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); var outputFolder = (CategoryTreeFolder)children[1]; - var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0]; + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.SectionResults); } @@ -258,7 +258,7 @@ new Point2D(1, 2), new Point2D(5, 6) })); - var failureMechanismContext = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var failureMechanismContext = new NumericFailureMechanismContext(failureMechanism, assessmentSection); // Call object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); @@ -279,7 +279,7 @@ { var failureMechanism = new TestFailureMechanism("A", "C"); var assessmentSection = mocks.Stub(); - var context = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var context = new NumericFailureMechanismContext(failureMechanism, assessmentSection); var gui = mocks.StrictMock(); var menuBuilderMock = mocks.StrictMock(); @@ -326,7 +326,7 @@ IsRelevant = false }; var assessmentSection = mocks.Stub(); - var context = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var context = new NumericFailureMechanismContext(failureMechanism, assessmentSection); var gui = mocks.StrictMock(); var menuBuilderMock = mocks.StrictMock(); @@ -365,7 +365,7 @@ { var assessmentSection = mocks.Stub(); var failureMechanism = new TestFailureMechanism("A", "C"); - var context = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var context = new NumericFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -410,7 +410,7 @@ failureMechanism.Attach(failureMechanismObserver); var assessmentSection = mocks.Stub(); - var failureMechanismContext = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var failureMechanismContext = new NumericFailureMechanismContext(failureMechanism, assessmentSection); var viewCommands = mocks.StrictMock(); viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext)); @@ -457,7 +457,7 @@ failureMechanism.Attach(failureMechanismObserver); var assessmentSection = mocks.Stub(); - var failureMechanismContext = new CustomFailureMechanismContext(failureMechanism, assessmentSection); + var failureMechanismContext = new NumericFailureMechanismContext(failureMechanism, assessmentSection); var treeViewControl = mocks.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/NumericFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/NumericFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/NumericFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,146 @@ +// 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.Collections.Generic; +using System.Linq; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Integration.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class NumericFailureMechanismSectionResultContextTreeNodeInfoTest + { + private MockRepository mocks; + private RingtoetsGuiPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new RingtoetsGuiPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType); + + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnsName() + { + // Setup + mocks.ReplayAll(); + + var mechanism = new NumericFailureMechanism(); + var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Oordeel", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var gui = mocks.StrictMultiMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); + + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + + // Assert + mocks.VerifyAll(); + } + + class NumericFailureMechanism : FailureMechanismBase, IHasSectionResults + { + public NumericFailureMechanism() + : base("N", "C") + { + SectionResults = new List(); + } + + public IEnumerable SectionResults { get; private set; } + + public override IEnumerable Calculations + { + get + { + throw new System.NotImplementedException(); + } + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/SimpleFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u -r903d441abc9596fbae24ca98a7d6af633bd616f7 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/SimpleFailureMechanismSectionResultContextTreeNodeInfoTest.cs (.../SimpleFailureMechanismSectionResultContextTreeNodeInfoTest.cs) (revision 903d441abc9596fbae24ca98a7d6af633bd616f7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/SimpleFailureMechanismSectionResultContextTreeNodeInfoTest.cs (.../SimpleFailureMechanismSectionResultContextTreeNodeInfoTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -123,23 +123,23 @@ // Assert mocks.VerifyAll(); } - } - - public class SimpleFailureMechanism : FailureMechanismBase, IHasSectionResults - { - public SimpleFailureMechanism() - : base("N", "C") + + class SimpleFailureMechanism : FailureMechanismBase, IHasSectionResults { - SectionResults = new List(); - } + public SimpleFailureMechanism() + : base("N", "C") + { + SectionResults = new List(); + } - public IEnumerable SectionResults { get; private set; } + public IEnumerable SectionResults { get; private set; } - public override IEnumerable Calculations - { - get + public override IEnumerable Calculations { - throw new System.NotImplementedException(); + get + { + throw new System.NotImplementedException(); + } } } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ArbitraryProbabilityFailureMechanismResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ArbitraryProbabilityFailureMechanismResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ArbitraryProbabilityFailureMechanismResultViewTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -0,0 +1,272 @@ +// 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; + +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class ArbitraryProbabilityFailureMechanismResultViewTest + { + [Test] + public void GivenFormWithArbitraryProbabilityFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new ArbitraryProbabilityFailureMechanismResultView()) + { + 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 GivenFormWithArbitraryProbabilityFailureMechanismResultView_WhenDataSourceWithArbitraryProbabilityFailureMechanismSectionResultAssigned_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 ArbitraryProbabilityFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerTwoB = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new ArbitraryProbabilityFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerTwoB = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new ArbitraryProbabilityFailureMechanismResultView()) + { + 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); + var expectedAssessmentLayer2AValue1 = (RoundedDouble) (1/result1.AssessmentLayerTwoA); + var expectedAssessmentLayer2AString1 = string.Format( + CoreCommonBaseResources.ProbabilityPerYearFormat, + expectedAssessmentLayer2AValue1 + ); + Assert.AreEqual(expectedAssessmentLayer2AString1, 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); + var expectedAssessmentLayer2AValue2 = (RoundedDouble)(1 / result2.AssessmentLayerTwoA); + var expectedAssessmentLayer2AString2 = string.Format( + CoreCommonBaseResources.ProbabilityPerYearFormat, + expectedAssessmentLayer2AValue2 + ); + Assert.AreEqual(expectedAssessmentLayer2AString2, 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 ArbitraryProbabilityFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerTwoB = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new ArbitraryProbabilityFailureMechanismResultView()) + { + 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 GivenFormWithArbitraryProbabilityFailureMechanismResultView_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 ArbitraryProbabilityFailureMechanismResultView()) + { + 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 Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/CustomFailureMechanismResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/CustomProbabilityFailureMechanismResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/NumericFailureMechanismResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/NumericFailureMechanismResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/NumericFailureMechanismResultViewTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 NumericFailureMechanismResultViewTest + { + [Test] + public void GivenFormWithNumericFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new NumericFailureMechanismResultView()) + { + 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 GivenFormWithNumericFailureMechanismResultView_WhenDataSourceWithNumericFailureMechanismSectionResultAssigned_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 NumericFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerTwoB = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new NumericFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerTwoB = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new NumericFailureMechanismResultView()) + { + 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("{0}", 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("{0}", 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 NumericFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerTwoB = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new NumericFailureMechanismResultView()) + { + 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 GivenFormWithNumericFailureMechanismResultView_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 NumericFailureMechanismResultView()) + { + 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 -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -70,8 +70,8 @@ - - + + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs =================================================================== diff -u -ra883652e0cf7e59e4d086472939379ad9be36472 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision a883652e0cf7e59e4d086472939379ad9be36472) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -235,15 +235,15 @@ Assert.AreEqual(typeof(AssessmentSectionView), mapViewInfo.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.Map, mapViewInfo.Image); - var resultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); - Assert.AreEqual(typeof(IEnumerable), resultViewInfo.ViewDataType); - Assert.AreEqual(typeof(CustomFailureMechanismResultView), resultViewInfo.ViewType); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, resultViewInfo.Image); + var numericResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), numericResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(NumericFailureMechanismResultView), numericResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, numericResultViewInfo.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 arbitraryProbabilityResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), arbitraryProbabilityResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(ArbitraryProbabilityFailureMechanismResultView), arbitraryProbabilityResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, arbitraryProbabilityResultViewInfo.Image); var simpleResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); Assert.AreEqual(typeof(IEnumerable), simpleResultViewInfo.ViewDataType); @@ -287,8 +287,8 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContributionContext))); 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(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/ArbitraryProbabilityFailureMechanismResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ArbitraryProbabilityFailureMechanismResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ArbitraryProbabilityFailureMechanismResultViewInfoTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 ArbitraryProbabilityFailureMechanismResultViewInfoTest + { + 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(ArbitraryProbabilityFailureMechanismResultView)); + } + + [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(ArbitraryProbabilityFailureMechanismResultView), 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 Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CustomFailureMechanismResultViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b9d20365707e77623054f96f0c8b544e86658e67 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/CustomProbabilityFailureMechanismResultViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/NumericFailureMechanismResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/NumericFailureMechanismResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/NumericFailureMechanismResultViewInfoTest.cs (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -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 NumericFailureMechanismResultViewInfoTest + { + 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(NumericFailureMechanismResultView)); + } + + [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(NumericFailureMechanismResultView), 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/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/SimpleFailureMechanismResultViewInfoTest.cs =================================================================== diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/SimpleFailureMechanismResultViewInfoTest.cs (.../SimpleFailureMechanismResultViewInfoTest.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/SimpleFailureMechanismResultViewInfoTest.cs (.../SimpleFailureMechanismResultViewInfoTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -250,7 +250,7 @@ { // Setup var viewMock = mocks.StrictMock(); - var failureMechanismContext = mocks.StrictMock>(); + var failureMechanismContext = mocks.StrictMultiMock>(); var failureMechanism = new Simple(); viewMock.Expect(vm => vm.Data).Return(failureMechanism.SectionResults); failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs =================================================================== diff -u -ra048dc4662f1eb83e4e8cd127790473f01470263 -rb9d20365707e77623054f96f0c8b544e86658e67 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision a048dc4662f1eb83e4e8cd127790473f01470263) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) @@ -23,6 +23,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.Properties; @@ -88,9 +89,19 @@ { base.AddDataGridColumns(); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerTwoA", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, true); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerTwoB", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b); - DataGridViewControl.AddTextBoxColumn("AssessmentLayerThree", RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, + true + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoB), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); } protected override object CreateFailureMechanismSectionResultRow(PipingFailureMechanismSectionResult sectionResult)