Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj =================================================================== diff -u -r94b85dc077cddf7535b328b8b3a96a494afac0f6 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 94b85dc077cddf7535b328b8b3a96a494afac0f6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -43,7 +43,6 @@ - Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/ArbitraryProbabilityFailureMechanismSectionResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/ClosingStructureFailureMechanismSectionResult.cs =================================================================== diff -u -r94b85dc077cddf7535b328b8b3a96a494afac0f6 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/ClosingStructureFailureMechanismSectionResult.cs (.../ClosingStructureFailureMechanismSectionResult.cs) (revision 94b85dc077cddf7535b328b8b3a96a494afac0f6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/ClosingStructureFailureMechanismSectionResult.cs (.../ClosingStructureFailureMechanismSectionResult.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -19,12 +19,50 @@ // 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; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Integration.Data.StandAlone.SectionResult { - public class ClosingStructureFailureMechanismSectionResult : ArbitraryProbabilityFailureMechanismSectionResult + public class ClosingStructureFailureMechanismSectionResult : FailureMechanismSectionResult { - public ClosingStructureFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + private RoundedDouble assessmentLayerTwoA; + public ClosingStructureFailureMechanismSectionResult(FailureMechanismSection section) + : base(section) + { + AssessmentLayerTwoA = (RoundedDouble)1.0; + } + + /// + /// Gets the probability 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 three. + /// + public RoundedDouble AssessmentLayerThree { get; set; } + + /// + /// Gets or sets the state of the assessment layer one. + /// + public bool AssessmentLayerOne { get; set; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/MacrostabilityInwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r94b85dc077cddf7535b328b8b3a96a494afac0f6 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/MacrostabilityInwardsFailureMechanismSectionResult.cs (.../MacrostabilityInwardsFailureMechanismSectionResult.cs) (revision 94b85dc077cddf7535b328b8b3a96a494afac0f6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/MacrostabilityInwardsFailureMechanismSectionResult.cs (.../MacrostabilityInwardsFailureMechanismSectionResult.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -19,12 +19,50 @@ // 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; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Integration.Data.StandAlone.SectionResult { - public class MacrostabilityInwardsFailureMechanismSectionResult : ArbitraryProbabilityFailureMechanismSectionResult + public class MacrostabilityInwardsFailureMechanismSectionResult : FailureMechanismSectionResult { - public MacrostabilityInwardsFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + private RoundedDouble assessmentLayerTwoA; + public MacrostabilityInwardsFailureMechanismSectionResult(FailureMechanismSection section) + : base(section) + { + AssessmentLayerTwoA = (RoundedDouble)1.0; + } + + /// + /// Gets the probability 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 three. + /// + public RoundedDouble AssessmentLayerThree { get; set; } + + /// + /// Gets or sets the state of the assessment layer one. + /// + public bool AssessmentLayerOne { get; set; } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/MacrostabilityOutwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r94b85dc077cddf7535b328b8b3a96a494afac0f6 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/MacrostabilityOutwardsFailureMechanismSectionResult.cs (.../MacrostabilityOutwardsFailureMechanismSectionResult.cs) (revision 94b85dc077cddf7535b328b8b3a96a494afac0f6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/MacrostabilityOutwardsFailureMechanismSectionResult.cs (.../MacrostabilityOutwardsFailureMechanismSectionResult.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -19,12 +19,51 @@ // 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; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Integration.Data.StandAlone.SectionResult { - public class MacrostabilityOutwardsFailureMechanismSectionResult : ArbitraryProbabilityFailureMechanismSectionResult + public class MacrostabilityOutwardsFailureMechanismSectionResult : FailureMechanismSectionResult { - public MacrostabilityOutwardsFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + private RoundedDouble assessmentLayerTwoA; + + public MacrostabilityOutwardsFailureMechanismSectionResult(FailureMechanismSection section) + : base(section) + { + AssessmentLayerTwoA = (RoundedDouble)1.0; + } + + /// + /// Gets the probability 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 three. + /// + public RoundedDouble AssessmentLayerThree { get; set; } + + /// + /// Gets or sets the state of the assessment layer one. + /// + public bool AssessmentLayerOne { get; set; } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/StrengthStabilityPointConstructionFailureMechanismSectionResult.cs =================================================================== diff -u -r94b85dc077cddf7535b328b8b3a96a494afac0f6 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/StrengthStabilityPointConstructionFailureMechanismSectionResult.cs (.../StrengthStabilityPointConstructionFailureMechanismSectionResult.cs) (revision 94b85dc077cddf7535b328b8b3a96a494afac0f6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResult/StrengthStabilityPointConstructionFailureMechanismSectionResult.cs (.../StrengthStabilityPointConstructionFailureMechanismSectionResult.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -19,12 +19,50 @@ // 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; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Integration.Data.StandAlone.SectionResult { - public class StrengthStabilityPointConstructionFailureMechanismSectionResult : ArbitraryProbabilityFailureMechanismSectionResult + public class StrengthStabilityPointConstructionFailureMechanismSectionResult : FailureMechanismSectionResult { - public StrengthStabilityPointConstructionFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + private RoundedDouble assessmentLayerTwoA; + public StrengthStabilityPointConstructionFailureMechanismSectionResult(FailureMechanismSection section) + : base(section) + { + AssessmentLayerTwoA = (RoundedDouble)1.0; + } + + /// + /// Gets the probability 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 three. + /// + public RoundedDouble AssessmentLayerThree { get; set; } + + /// + /// Gets or sets the state of the assessment layer one. + /// + public bool AssessmentLayerOne { get; set; } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/ArbitraryProbabilityFailureMechanismContext.cs =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/ArbitraryProbabilityFailureMechanismContext.cs (.../ArbitraryProbabilityFailureMechanismContext.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/ArbitraryProbabilityFailureMechanismContext.cs (.../ArbitraryProbabilityFailureMechanismContext.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -23,13 +23,12 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; -using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Forms.PresentationObjects { /// /// This class is a presentation object for an instance of , - /// which has . + /// which has . /// public class ArbitraryProbabilityFailureMechanismContext : FailureMechanismContext { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -73,7 +73,7 @@ FailureMechanismContributionView.cs - + @@ -91,9 +91,6 @@ - - UserControl - UserControl Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/ArbitraryProbabilityFailureMechanismSectionResultRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/ClosingStructureSectionResultRow.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/ClosingStructureSectionResultRow.cs (.../ClosingStructureSectionResultRow.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/ClosingStructureSectionResultRow.cs (.../ClosingStructureSectionResultRow.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,9 +1,92 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Forms.Views.SectionResultRow { - public class ClosingStructureSectionResultRow : ArbitraryProbabilityFailureMechanismSectionResultRow + public class ClosingStructureSectionResultRow : FailureMechanismSectionResultRow { - public ClosingStructureSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + public ClosingStructureSectionResultRow(ClosingStructureFailureMechanismSectionResult sectionResult) : base(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",Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null); + } + try + { + SectionResult.AssessmentLayerTwoA = (RoundedDouble) double.Parse(value); + } + catch (OverflowException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large); + } + catch (FormatException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_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; + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/FailureMechanismSectionResultRow.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/FailureMechanismSectionResultRow.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/FailureMechanismSectionResultRow.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,53 @@ +// 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.Integration.Forms.Views.SectionResultRow +{ + /// + /// Container of a , which takes care of the + /// representation of properties in a grid. + /// + public class FailureMechanismSectionResultRow where T : FailureMechanismSectionResult + { + /// + /// Creates a new instance of . + /// + /// The that is + /// the source of this row. + /// Throw when is + /// null. + public FailureMechanismSectionResultRow(T sectionResult) + { + if (sectionResult == null) + { + throw new ArgumentNullException("sectionResult"); + } + SectionResult = sectionResult; + } + + protected T SectionResult { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/MacrostabilityInwardsSectionResultRow.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/MacrostabilityInwardsSectionResultRow.cs (.../MacrostabilityInwardsSectionResultRow.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/MacrostabilityInwardsSectionResultRow.cs (.../MacrostabilityInwardsSectionResultRow.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,9 +1,92 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Forms.Views.SectionResultRow { - public class MacrostabilityInwardsSectionResultRow : ArbitraryProbabilityFailureMechanismSectionResultRow + public class MacrostabilityInwardsSectionResultRow : FailureMechanismSectionResultRow { - public MacrostabilityInwardsSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + public MacrostabilityInwardsSectionResultRow(MacrostabilityInwardsFailureMechanismSectionResult sectionResult) : base(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",Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null); + } + try + { + SectionResult.AssessmentLayerTwoA = (RoundedDouble) double.Parse(value); + } + catch (OverflowException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large); + } + catch (FormatException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_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; + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/MacrostabilityOutwardsSectionResultRow.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/MacrostabilityOutwardsSectionResultRow.cs (.../MacrostabilityOutwardsSectionResultRow.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/MacrostabilityOutwardsSectionResultRow.cs (.../MacrostabilityOutwardsSectionResultRow.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,9 +1,92 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Forms.Views.SectionResultRow { - public class MacrostabilityOutwardsSectionResultRow : ArbitraryProbabilityFailureMechanismSectionResultRow + public class MacrostabilityOutwardsSectionResultRow : FailureMechanismSectionResultRow { - public MacrostabilityOutwardsSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + public MacrostabilityOutwardsSectionResultRow(MacrostabilityOutwardsFailureMechanismSectionResult sectionResult) : base(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",Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null); + } + try + { + SectionResult.AssessmentLayerTwoA = (RoundedDouble) double.Parse(value); + } + catch (OverflowException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large); + } + catch (FormatException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_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; + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/StrengthStabilityPointConstructionSectionResultRow.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/StrengthStabilityPointConstructionSectionResultRow.cs (.../StrengthStabilityPointConstructionSectionResultRow.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/StrengthStabilityPointConstructionSectionResultRow.cs (.../StrengthStabilityPointConstructionSectionResultRow.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,9 +1,92 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Forms.Views.SectionResultRow { - public class StrengthStabilityPointConstructionSectionResultRow : ArbitraryProbabilityFailureMechanismSectionResultRow + public class StrengthStabilityPointConstructionSectionResultRow : FailureMechanismSectionResultRow { - public StrengthStabilityPointConstructionSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + public StrengthStabilityPointConstructionSectionResultRow(StrengthStabilityPointConstructionFailureMechanismSectionResult sectionResult) : base(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",Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null); + } + try + { + SectionResult.AssessmentLayerTwoA = (RoundedDouble) double.Parse(value); + } + catch (OverflowException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_too_large); + } + catch (FormatException) + { + throw new ArgumentException(Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Could_not_parse_string_to_double_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; + } + } } } \ No newline at end of file Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/ArbitraryProbabilityFailureMechanismResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/ClosingStructureResultView.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/ClosingStructureResultView.cs (.../ClosingStructureResultView.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/ClosingStructureResultView.cs (.../ClosingStructureResultView.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,13 +1,60 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Integration.Data.StandAlone.SectionResult; using Ringtoets.Integration.Forms.Views.SectionResultRow; namespace Ringtoets.Integration.Forms.Views.SectionResultView { - public class ClosingStructureResultView : ArbitraryProbabilityFailureMechanismResultView + public class ClosingStructureResultView : FailureMechanismResultView { - protected override object CreateFailureMechanismSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) + public ClosingStructureResultView() { - return new ArbitraryProbabilityFailureMechanismSectionResultRow(sectionResult); + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + + AddDataGridColumns(); } + + private void AddDataGridColumns() + { + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.Name), + Resources.FailureMechanismResultView_InitializeDataGridView_Section_name, + true + ); + DataGridViewControl.AddCheckBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); + } + + protected override object CreateFailureMechanismSectionResultRow(ClosingStructureFailureMechanismSectionResult sectionResult) + { + return new ClosingStructureSectionResultRow(sectionResult); + } + + 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); + } + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/MacrostabilityInwardsResultView.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/MacrostabilityInwardsResultView.cs (.../MacrostabilityInwardsResultView.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/MacrostabilityInwardsResultView.cs (.../MacrostabilityInwardsResultView.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,13 +1,60 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Integration.Data.StandAlone.SectionResult; using Ringtoets.Integration.Forms.Views.SectionResultRow; namespace Ringtoets.Integration.Forms.Views.SectionResultView { - public class MacrostabilityInwardsResultView : ArbitraryProbabilityFailureMechanismResultView + public class MacrostabilityInwardsResultView : FailureMechanismResultView { - protected override object CreateFailureMechanismSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) + public MacrostabilityInwardsResultView() { - return new ArbitraryProbabilityFailureMechanismSectionResultRow(sectionResult); + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + + AddDataGridColumns(); } + + private void AddDataGridColumns() + { + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.Name), + Resources.FailureMechanismResultView_InitializeDataGridView_Section_name, + true + ); + DataGridViewControl.AddCheckBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); + } + + protected override object CreateFailureMechanismSectionResultRow(MacrostabilityInwardsFailureMechanismSectionResult sectionResult) + { + return new MacrostabilityInwardsSectionResultRow(sectionResult); + } + + 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); + } + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/MacrostabilityOutwardsResultView.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/MacrostabilityOutwardsResultView.cs (.../MacrostabilityOutwardsResultView.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/MacrostabilityOutwardsResultView.cs (.../MacrostabilityOutwardsResultView.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,13 +1,60 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Integration.Data.StandAlone.SectionResult; using Ringtoets.Integration.Forms.Views.SectionResultRow; namespace Ringtoets.Integration.Forms.Views.SectionResultView { - public class MacrostabilityOutwardsResultView : ArbitraryProbabilityFailureMechanismResultView + public class MacrostabilityOutwardsResultView : FailureMechanismResultView { - protected override object CreateFailureMechanismSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) + public MacrostabilityOutwardsResultView() { - return new ArbitraryProbabilityFailureMechanismSectionResultRow(sectionResult); + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + + AddDataGridColumns(); } + + private void AddDataGridColumns() + { + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.Name), + Resources.FailureMechanismResultView_InitializeDataGridView_Section_name, + true + ); + DataGridViewControl.AddCheckBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); + } + + protected override object CreateFailureMechanismSectionResultRow(MacrostabilityOutwardsFailureMechanismSectionResult sectionResult) + { + return new MacrostabilityOutwardsSectionResultRow(sectionResult); + } + + 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); + } + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/StrengthStabilityPointConstructionResultView.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/StrengthStabilityPointConstructionResultView.cs (.../StrengthStabilityPointConstructionResultView.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/StrengthStabilityPointConstructionResultView.cs (.../StrengthStabilityPointConstructionResultView.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -1,13 +1,60 @@ -using Ringtoets.Integration.Data.StandAlone.SectionResult; +using System.Windows.Forms; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Integration.Data.StandAlone.SectionResult; using Ringtoets.Integration.Forms.Views.SectionResultRow; namespace Ringtoets.Integration.Forms.Views.SectionResultView { - public class StrengthStabilityPointConstructionResultView : ArbitraryProbabilityFailureMechanismResultView + public class StrengthStabilityPointConstructionResultView : FailureMechanismResultView { - protected override object CreateFailureMechanismSectionResultRow(ArbitraryProbabilityFailureMechanismSectionResult sectionResult) + public StrengthStabilityPointConstructionResultView() { - return new ArbitraryProbabilityFailureMechanismSectionResultRow(sectionResult); + DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); + + AddDataGridColumns(); } + + private void AddDataGridColumns() + { + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.Name), + Resources.FailureMechanismResultView_InitializeDataGridView_Section_name, + true + ); + DataGridViewControl.AddCheckBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a + ); + DataGridViewControl.AddTextBoxColumn( + TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), + Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three + ); + } + + protected override object CreateFailureMechanismSectionResultRow(StrengthStabilityPointConstructionFailureMechanismSectionResult sectionResult) + { + return new StrengthStabilityPointConstructionSectionResultRow(sectionResult); + } + + 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); + } + } + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -56,6 +56,7 @@ using Ringtoets.HydraRing.Calculation.Data.Output; using Ringtoets.HydraRing.Data; using Ringtoets.HydraRing.IO; +using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.SectionResult; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.PropertyClasses; @@ -164,17 +165,18 @@ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism }; - yield return new ViewInfo< - FailureMechanismSectionResultContext, - IEnumerable, - ArbitraryProbabilityFailureMechanismResultView> - { - GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, - Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, - CloseForData = CloseFailureMechanismResultViewForData, - GetViewData = context => context.SectionResults, - AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism - }; + yield return CreateFailureMechanismResultViewInfo< + MacrostabilityInwardsFailureMechanismSectionResult, + MacrostabilityInwardsResultView>(); + yield return CreateFailureMechanismResultViewInfo< + MacrostabilityOutwardsFailureMechanismSectionResult, + MacrostabilityOutwardsResultView>(); + yield return CreateFailureMechanismResultViewInfo< + StrengthStabilityPointConstructionFailureMechanismSectionResult, + StrengthStabilityPointConstructionResultView>(); + yield return CreateFailureMechanismResultViewInfo< + ClosingStructureFailureMechanismSectionResult, + ClosingStructureResultView>(); yield return new ViewInfo, ICommentable, CommentView> { @@ -185,6 +187,24 @@ }; } + private static ViewInfo, IEnumerable, TView> + CreateFailureMechanismResultViewInfo() + where TResult : FailureMechanismSectionResult + where TView : FailureMechanismResultView + { + return new ViewInfo< + FailureMechanismSectionResultContext, + IEnumerable, + TView> + { + GetViewName = (v, o) => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, + Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, + CloseForData = CloseFailureMechanismResultViewForData, + GetViewData = context => context.SectionResults, + AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism + }; + } + /// /// Gets the child data instances that have definitions of some parent data object. /// @@ -292,19 +312,27 @@ .Build() }; - yield return new TreeNodeInfo> + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + + yield return new TreeNodeInfo> { - Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, - Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, + Text = comment => Resources.Comment_DisplayName, + Image = context => RingtoetsCommonFormsResources.EditDocumentIcon, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddOpenItem() .Build() }; + } - yield return new TreeNodeInfo> + private TreeNodeInfo> CreateFailureMechanismSectionResultTreeNodeInfo() where T : FailureMechanismSectionResult + { + return new TreeNodeInfo> { - Text = comment => Resources.Comment_DisplayName, - Image = context => RingtoetsCommonFormsResources.EditDocumentIcon, + Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, + Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddOpenItem() .Build() @@ -480,7 +508,7 @@ var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism; var numericFailureMechanism = failureMechanism as IHasSectionResults; - var probabilityFailureMechanism = failureMechanism as IHasSectionResults; + var probabilityFailureMechanism = failureMechanism as IHasSectionResults; var simpleFailureMechanism = failureMechanism as IHasSectionResults; if (piping != null) @@ -584,7 +612,11 @@ { var simple = nodeData as IHasSectionResults; var custom = nodeData as IHasSectionResults; - var arbitraryProbability = nodeData as IHasSectionResults; + var closingStructure = nodeData as IHasSectionResults; + var macrostabilityInwards = nodeData as IHasSectionResults; + var macrostabilityOutwards = nodeData as IHasSectionResults; + var strengthStabilityPointConstruction = nodeData as IHasSectionResults; + var failureMechanismSectionResultContexts = new object[1]; if (simple != null) { @@ -596,11 +628,26 @@ failureMechanismSectionResultContexts[0] = new FailureMechanismSectionResultContext(custom.SectionResults, nodeData); } - if (arbitraryProbability != null) + if (closingStructure != null) { failureMechanismSectionResultContexts[0] = - new FailureMechanismSectionResultContext(arbitraryProbability.SectionResults, nodeData); + new FailureMechanismSectionResultContext(closingStructure.SectionResults, nodeData); } + if (macrostabilityInwards != null) + { + failureMechanismSectionResultContexts[0] = + new FailureMechanismSectionResultContext(macrostabilityInwards.SectionResults, nodeData); + } + if (macrostabilityOutwards != null) + { + failureMechanismSectionResultContexts[0] = + new FailureMechanismSectionResultContext(macrostabilityOutwards.SectionResults, nodeData); + } + if (strengthStabilityPointConstruction != null) + { + failureMechanismSectionResultContexts[0] = + new FailureMechanismSectionResultContext(strengthStabilityPointConstruction.SectionResults, nodeData); + } return failureMechanismSectionResultContexts; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -56,7 +56,10 @@ - + + + + Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs (.../ClosingStructureFailureMechanismTest.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/ClosingStructureFailureMechanismTest.cs (.../ClosingStructureFailureMechanismTest.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -24,7 +24,6 @@ using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Integration.Data.StandAlone; -using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Data.Test.StandAlone { @@ -58,7 +57,7 @@ // Assert Assert.AreEqual(1, failureMechanism.SectionResults.Count()); - Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0)); + Assert.IsInstanceOf(failureMechanism.SectionResults.ElementAt(0)); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs (.../MacrostabilityInwardsFailureMechanismTest.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityInwardsFailureMechanismTest.cs (.../MacrostabilityInwardsFailureMechanismTest.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -24,7 +24,6 @@ using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Integration.Data.StandAlone; -using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Data.Test.StandAlone { @@ -58,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 -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs (.../MacrostabilityOutwardsFailureMechanismTest.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/MacrostabilityOutwardsFailureMechanismTest.cs (.../MacrostabilityOutwardsFailureMechanismTest.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -24,7 +24,6 @@ using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Integration.Data.StandAlone; -using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Data.Test.StandAlone { @@ -58,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 Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/ArbitraryProbabilityFailureMechanismSectionResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/ClosingStructureFailureMechanismSectionResultTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/ClosingStructureFailureMechanismSectionResultTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/ClosingStructureFailureMechanismSectionResultTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,105 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResult; + +namespace Ringtoets.Integration.Data.Test.StandAlone.SectionResult +{ + [TestFixture] + public class ClosingStructureFailureMechanismSectionResultTest + { + [Test] + public void Constructor_WithoutSection_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ClosingStructureFailureMechanismSectionResult(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 ClosingStructureFailureMechanismSectionResult(section); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreSame(section, result.Section); + Assert.IsFalse(result.AssessmentLayerOne); + Assert.AreEqual(1, result.AssessmentLayerTwoA.Value); + Assert.AreEqual(0, result.AssessmentLayerThree.Value); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1+1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new ClosingStructureFailureMechanismSectionResult(section); + + // Call + TestDelegate test = () => result.AssessmentLayerTwoA = (RoundedDouble)a; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Data.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message + ); + } + + [Test] + [TestCase(0)] + [TestCase(1e-6)] + [TestCase(0.5)] + [TestCase(1-1e-6)] + [TestCase(1)] + public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new ClosingStructureFailureMechanismSectionResult(section); + + var assessmentLayerTwoAValue = (RoundedDouble)a; + + // Call + result.AssessmentLayerTwoA = assessmentLayerTwoAValue; + + // Assert + Assert.AreEqual(assessmentLayerTwoAValue, result.AssessmentLayerTwoA); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/MacrostabilityInwardsFailureMechanismSectionResultTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/MacrostabilityInwardsFailureMechanismSectionResultTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/MacrostabilityInwardsFailureMechanismSectionResultTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,105 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResult; + +namespace Ringtoets.Integration.Data.Test.StandAlone.SectionResult +{ + [TestFixture] + public class MacrostabilityInwardsFailureMechanismSectionResultTest + { + [Test] + public void Constructor_WithoutSection_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacrostabilityInwardsFailureMechanismSectionResult(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 MacrostabilityInwardsFailureMechanismSectionResult(section); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreSame(section, result.Section); + Assert.IsFalse(result.AssessmentLayerOne); + Assert.AreEqual(1, result.AssessmentLayerTwoA.Value); + Assert.AreEqual(0, result.AssessmentLayerThree.Value); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1+1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new MacrostabilityInwardsFailureMechanismSectionResult(section); + + // Call + TestDelegate test = () => result.AssessmentLayerTwoA = (RoundedDouble)a; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Data.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message + ); + } + + [Test] + [TestCase(0)] + [TestCase(1e-6)] + [TestCase(0.5)] + [TestCase(1-1e-6)] + [TestCase(1)] + public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new MacrostabilityInwardsFailureMechanismSectionResult(section); + + var assessmentLayerTwoAValue = (RoundedDouble)a; + + // Call + result.AssessmentLayerTwoA = assessmentLayerTwoAValue; + + // Assert + Assert.AreEqual(assessmentLayerTwoAValue, result.AssessmentLayerTwoA); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/MacrostabilityOutwardsFailureMechanismSectionResultTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/MacrostabilityOutwardsFailureMechanismSectionResultTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/MacrostabilityOutwardsFailureMechanismSectionResultTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,105 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResult; + +namespace Ringtoets.Integration.Data.Test.StandAlone.SectionResult +{ + [TestFixture] + public class MacrostabilityOutwardsFailureMechanismSectionResultTest + { + [Test] + public void Constructor_WithoutSection_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacrostabilityOutwardsFailureMechanismSectionResult(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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreSame(section, result.Section); + Assert.IsFalse(result.AssessmentLayerOne); + Assert.AreEqual(1, result.AssessmentLayerTwoA.Value); + Assert.AreEqual(0, result.AssessmentLayerThree.Value); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1+1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new MacrostabilityOutwardsFailureMechanismSectionResult(section); + + // Call + TestDelegate test = () => result.AssessmentLayerTwoA = (RoundedDouble)a; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Data.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message + ); + } + + [Test] + [TestCase(0)] + [TestCase(1e-6)] + [TestCase(0.5)] + [TestCase(1-1e-6)] + [TestCase(1)] + public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new MacrostabilityOutwardsFailureMechanismSectionResult(section); + + var assessmentLayerTwoAValue = (RoundedDouble)a; + + // Call + result.AssessmentLayerTwoA = assessmentLayerTwoAValue; + + // Assert + Assert.AreEqual(assessmentLayerTwoAValue, result.AssessmentLayerTwoA); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/StrengthStabilityPointConstructionFailureMechanismSectionResultTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/StrengthStabilityPointConstructionFailureMechanismSectionResultTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/SectionResult/StrengthStabilityPointConstructionFailureMechanismSectionResultTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,105 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResult; + +namespace Ringtoets.Integration.Data.Test.StandAlone.SectionResult +{ + [TestFixture] + public class StrengthStabilityPointConstructionFailureMechanismSectionResultTest + { + [Test] + public void Constructor_WithoutSection_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new StrengthStabilityPointConstructionFailureMechanismSectionResult(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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreSame(section, result.Section); + Assert.IsFalse(result.AssessmentLayerOne); + Assert.AreEqual(1, result.AssessmentLayerTwoA.Value); + Assert.AreEqual(0, result.AssessmentLayerThree.Value); + } + + [Test] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1+1e-6)] + [TestCase(12)] + public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + + // Call + TestDelegate test = () => result.AssessmentLayerTwoA = (RoundedDouble)a; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Data.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, + message + ); + } + + [Test] + [TestCase(0)] + [TestCase(1e-6)] + [TestCase(0.5)] + [TestCase(1-1e-6)] + [TestCase(1)] + public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double a) + { + // Setup + var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) }); + var result = new StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + + var assessmentLayerTwoAValue = (RoundedDouble)a; + + // Call + result.AssessmentLayerTwoA = assessmentLayerTwoAValue; + + // Assert + Assert.AreEqual(assessmentLayerTwoAValue, result.AssessmentLayerTwoA); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs (.../StrengthStabilityPointConstructionFailureMechanismTest.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/StrengthStabilityPointConstructionFailureMechanismTest.cs (.../StrengthStabilityPointConstructionFailureMechanismTest.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -24,7 +24,6 @@ using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Integration.Data.StandAlone; -using Ringtoets.Integration.Data.StandAlone.SectionResult; namespace Ringtoets.Integration.Data.Test.StandAlone { @@ -58,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/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -68,10 +68,13 @@ - + + + + @@ -81,14 +84,17 @@ - + - + + + + - + - + Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ArbitraryProbabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,108 @@ +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.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class ClosingStructureFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 ClosingStructureFailureMechanism(); + 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(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,108 @@ +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.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 MacrostabilityInwardsFailureMechanism(); + 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(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,108 @@ +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.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 MacrostabilityOutwardsFailureMechanism(); + 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(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StrengthStabilityPointwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StrengthStabilityPointwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StrengthStabilityPointwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,106 @@ +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.Forms.PresentationObjects; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class StrengthStabilityPointConstructionFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 StrengthStabilityPointConstructionFailureMechanism(); + 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(); + } + } +} \ No newline at end of file Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ArbitraryProbabilityFailureMechanismResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ArbitraryProbabilityFailureMechanismSectionResultRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/NumericFailureMechanismSectionResultRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/ClosingStructureSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/ClosingStructureSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/ClosingStructureSectionResultRowTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,232 @@ +// 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.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultRow; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.Views.SectionResultRow +{ + [TestFixture] + public class ClosingStructureSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ClosingStructureSectionResultRow(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 ClosingStructureFailureMechanismSectionResult(section); + + // Call + var row = new ClosingStructureSectionResultRow(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.AssessmentLayerThree, row.AssessmentLayerThree); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue) + { + // Setup + var section = CreateSection(); + var result = new ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(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 ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(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 ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.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 ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = value; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = (string) null; + + // Assert + var expectedMessage = Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new ClosingStructureFailureMechanismSectionResult(section); + var row = new ClosingStructureSectionResultRow(result); + + // Call + row.AssessmentLayerThree = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("name", new[] + { + new Point2D(0, 0) + }); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/MacrostabilityInwardsSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/MacrostabilityInwardsSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/MacrostabilityInwardsSectionResultRowTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,232 @@ +// 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.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultRow; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.Views.SectionResultRow +{ + [TestFixture] + public class MacrostabilityInwardsSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacrostabilityInwardsSectionResultRow(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 MacrostabilityInwardsFailureMechanismSectionResult(section); + + // Call + var row = new MacrostabilityInwardsSectionResultRow(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.AssessmentLayerThree, row.AssessmentLayerThree); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue) + { + // Setup + var section = CreateSection(); + var result = new MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(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 MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(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 MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.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 MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = value; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = (string) null; + + // Assert + var expectedMessage = Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new MacrostabilityInwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityInwardsSectionResultRow(result); + + // Call + row.AssessmentLayerThree = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("name", new[] + { + new Point2D(0, 0) + }); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/MacrostabilityOutwardsSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/MacrostabilityOutwardsSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/MacrostabilityOutwardsSectionResultRowTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,232 @@ +// 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.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultRow; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.Views.SectionResultRow +{ + [TestFixture] + public class MacrostabilityOutwardsSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacrostabilityOutwardsSectionResultRow(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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + + // Call + var row = new MacrostabilityOutwardsSectionResultRow(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.AssessmentLayerThree, row.AssessmentLayerThree); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue) + { + // Setup + var section = CreateSection(); + var result = new MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = value; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = (string) null; + + // Assert + var expectedMessage = Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new MacrostabilityOutwardsFailureMechanismSectionResult(section); + var row = new MacrostabilityOutwardsSectionResultRow(result); + + // Call + row.AssessmentLayerThree = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("name", new[] + { + new Point2D(0, 0) + }); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/NumericFailureMechanismSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/NumericFailureMechanismSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/NumericFailureMechanismSectionResultRowTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,132 @@ +// 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.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultRow; + +namespace Ringtoets.Integration.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.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 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/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/SimpleFailureMechanismSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/SimpleFailureMechanismSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/SimpleFailureMechanismSectionResultRowTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,131 @@ +// 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.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultRow; + +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class SimpleFailureMechanismSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new SimpleFailureMechanismSectionResultRow(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 SimpleFailureMechanismSectionResult(section); + + // Call + var row = new SimpleFailureMechanismSectionResultRow(result); + + // Assert + Assert.AreEqual(section.Name, row.Name); + Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne); + Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); + 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 SimpleFailureMechanismSectionResult(section); + var row = new SimpleFailureMechanismSectionResultRow(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 newValue = AssessmentLayerTwoAResult.Successful; + var section = CreateSection(); + var result = new SimpleFailureMechanismSectionResult(section); + var row = new SimpleFailureMechanismSectionResultRow(result); + + // Call + row.AssessmentLayerTwoA = newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerTwoA); + } + + [Test] + public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new SimpleFailureMechanismSectionResult(section); + var row = new SimpleFailureMechanismSectionResultRow(result); + + // Call + row.AssessmentLayerThree = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("name", new[] + { + new Point2D(0, 0) + }); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/StrengthStabilityPointConstructionSectionResultRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/StrengthStabilityPointConstructionSectionResultRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRow/StrengthStabilityPointConstructionSectionResultRowTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,232 @@ +// 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.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultRow; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.Views.SectionResultRow +{ + [TestFixture] + public class StrengthStabilityPointConstructionSectionResultRowTest + { + [Test] + public void Constructor_WithoutSectionResult_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new StrengthStabilityPointConstructionSectionResultRow(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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + + // Call + var row = new StrengthStabilityPointConstructionSectionResultRow(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.AssessmentLayerThree, row.AssessmentLayerThree); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue) + { + // Setup + var section = CreateSection(); + var result = new StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = newValue.ToString(); + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = value; + + // Assert + var message = Assert.Throws(test).Message; + Assert.AreEqual( + Common.Forms.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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(result); + + // Call + TestDelegate test = () => row.AssessmentLayerTwoA = (string) null; + + // Assert + var expectedMessage = Common.Forms.Properties.Resources.ArbitraryProbabilityFailureMechanismSectionResultRow_AssessmentLayerTwoA_Value_cannot_be_null; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() + { + // Setup + var random = new Random(21); + var newValue = random.NextDouble(); + var section = CreateSection(); + var result = new StrengthStabilityPointConstructionFailureMechanismSectionResult(section); + var row = new StrengthStabilityPointConstructionSectionResultRow(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 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SimpleFailureMechanismSectionResultRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityPointConstructionResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityPointConstructionResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityPointConstructionResultViewTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,259 @@ +// 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.Common.Forms.Views; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class StrengthStabilityPointConstructionResultViewTest + { + [Test] + public void GivenFormWithArbitraryProbabilityFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new StrengthStabilityPointConstructionResultView()) + { + form.Controls.Add(view); + form.Show(); + + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(4, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); + 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_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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new StrengthStabilityPointConstructionFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new StrengthStabilityPointConstructionResultView()) + { + 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(4, 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.AssessmentLayerThree), cells[assessmentLayerThreeIndex].FormattedValue); + + AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + + cells = rows[1].Cells; + Assert.AreEqual(4, 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.AssessmentLayerThree), cells[assessmentLayerThreeIndex].FormattedValue); + + AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + 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 StrengthStabilityPointConstructionFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new StrengthStabilityPointConstructionResultView()) + { + 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(4, cells.Count); + + AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + 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 StrengthStabilityPointConstructionResultView()) + { + 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 assessmentLayerThreeIndex = 3; + + 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 -rb9d20365707e77623054f96f0c8b544e86658e67 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision b9d20365707e77623054f96f0c8b544e86658e67) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -70,7 +70,10 @@ - + + + + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r8c0ec57a86cd0d73759f178bee1ed647f62692dc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -235,7 +235,7 @@ ViewInfo[] viewInfos = guiPlugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(6, viewInfos.Length); + Assert.AreEqual(9, viewInfos.Length); var contributionViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismContributionContext)); Assert.AreEqual(typeof(FailureMechanismContributionView), contributionViewInfo.ViewType); @@ -250,11 +250,26 @@ Assert.AreEqual(typeof(NumericFailureMechanismResultView), numericResultViewInfo.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, numericResultViewInfo.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 closingStructureResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), closingStructureResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(ClosingStructureResultView), closingStructureResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, closingStructureResultViewInfo.Image); + var macrostabilityOutwardsResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), macrostabilityOutwardsResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(MacrostabilityOutwardsResultView), macrostabilityOutwardsResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, macrostabilityOutwardsResultViewInfo.Image); + + var macrostabilityInwardsResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), macrostabilityInwardsResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(MacrostabilityInwardsResultView), macrostabilityInwardsResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, macrostabilityInwardsResultViewInfo.Image); + + var strengthStabilityPointConstructionResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), strengthStabilityPointConstructionResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(StrengthStabilityPointConstructionResultView), strengthStabilityPointConstructionResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, strengthStabilityPointConstructionResultViewInfo.Image); + var simpleResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); Assert.AreEqual(typeof(IEnumerable), simpleResultViewInfo.ViewDataType); Assert.AreEqual(typeof(SimpleFailureMechanismResultView), simpleResultViewInfo.ViewType); @@ -288,7 +303,7 @@ TreeNodeInfo[] treeNodeInfos = guiPlugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(11, treeNodeInfos.Length); + Assert.AreEqual(14, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(IAssessmentSection))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ReferenceLineContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContext))); @@ -298,7 +313,10 @@ 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(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CommentContext))); } mocks.VerifyAll(); Fisheye: Tag 8c0ec57a86cd0d73759f178bee1ed647f62692dc refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ArbitraryProbabilityFailureMechanismResultViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructureResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructureResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/ClosingStructureResultViewInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,334 @@ +// 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.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; +using Ringtoets.Piping.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class ClosingStructureResultViewInfoTest + { + 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(ClosingStructureResultView)); + } + + [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(ClosingStructureResultView), 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 assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); + mocks.ReplayAll(); + + using (var view = new ClosingStructureResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new ClosingStructureResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[] + { + new PipingFailureMechanism(), + failureMechanism + }); + + mocks.ReplayAll(); + + using (var view = new ClosingStructureResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + using (var view = new ClosingStructureResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() + { + // Setup + using (var view = new ClosingStructureResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, new Simple()); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + var failureMechanism = new Simple(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism); + + mocks.ReplayAll(); + + using (var view = new ClosingStructureResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(new Simple()); + + mocks.ReplayAll(); + + using (var view = new ClosingStructureResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + var failureMechanism = new Simple(); + var view = mocks.StrictMock(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + view.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(view, 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/MacrostabilityInwardsResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/MacrostabilityInwardsResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/MacrostabilityInwardsResultViewInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,334 @@ +// 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.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; +using Ringtoets.Piping.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class MacrostabilityInwardsResultViewInfoTest + { + 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(MacrostabilityInwardsResultView)); + } + + [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(MacrostabilityInwardsResultView), 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 assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); + mocks.ReplayAll(); + + using (var view = new MacrostabilityInwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityInwardsResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[] + { + new PipingFailureMechanism(), + failureMechanism + }); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityInwardsResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + using (var view = new MacrostabilityInwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() + { + // Setup + using (var view = new MacrostabilityInwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, new Simple()); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + var failureMechanism = new Simple(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityInwardsResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(new Simple()); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityInwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + var failureMechanism = new Simple(); + var view = mocks.StrictMock(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + view.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(view, 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/MacrostabilityOutwardsResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/MacrostabilityOutwardsResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/MacrostabilityOutwardsResultViewInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,334 @@ +// 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.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; +using Ringtoets.Piping.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class MacrostabilityOutwardsResultViewInfoTest + { + 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(MacrostabilityOutwardsResultView)); + } + + [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(MacrostabilityOutwardsResultView), 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 assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); + mocks.ReplayAll(); + + using (var view = new MacrostabilityOutwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityOutwardsResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[] + { + new PipingFailureMechanism(), + failureMechanism + }); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityOutwardsResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + using (var view = new MacrostabilityOutwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() + { + // Setup + using (var view = new MacrostabilityOutwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, new Simple()); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + var failureMechanism = new Simple(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityOutwardsResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(new Simple()); + + mocks.ReplayAll(); + + using (var view = new MacrostabilityOutwardsResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + var failureMechanism = new Simple(); + var view = mocks.StrictMock(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + view.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(view, 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/StrengthStabilityPointConstructionResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/StrengthStabilityPointConstructionResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/StrengthStabilityPointConstructionResultViewInfoTest.cs (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) @@ -0,0 +1,334 @@ +// 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.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; +using Ringtoets.Piping.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class StrengthStabilityPointConstructionResultViewInfoTest + { + 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(StrengthStabilityPointConstructionResultView)); + } + + [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(StrengthStabilityPointConstructionResultView), 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 assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); + mocks.ReplayAll(); + + using (var view = new StrengthStabilityPointConstructionResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new StrengthStabilityPointConstructionResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[] + { + new PipingFailureMechanism(), + failureMechanism + }); + + mocks.ReplayAll(); + + using (var view = new StrengthStabilityPointConstructionResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + using (var view = new StrengthStabilityPointConstructionResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() + { + // Setup + using (var view = new StrengthStabilityPointConstructionResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, new Simple()); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + var failureMechanism = new Simple(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(failureMechanism); + + mocks.ReplayAll(); + + using (var view = new StrengthStabilityPointConstructionResultView()) + { + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var failureMechanismContext = mocks.StrictMock>(); + failureMechanismContext.Expect(fm => fm.WrappedData).Return(new Simple()); + + mocks.ReplayAll(); + + using (var view = new StrengthStabilityPointConstructionResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + var failureMechanism = new Simple(); + var view = mocks.StrictMock(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + view.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(view, 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