Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r8c0ec57a86cd0d73759f178bee1ed647f62692dc -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -90,7 +90,7 @@ - + UserControl @@ -127,18 +127,15 @@ UserControl - + UserControl UserControl - + UserControl - - UserControl - UserControl Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/WaveImpactAsphaltCoverSectionResultRow.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/WaveImpactAsphaltCoverSectionResultRow.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/WaveImpactAsphaltCoverSectionResultRow.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,9 @@ +using Ringtoets.Integration.Data.StandAlone.SectionResult; + +namespace Ringtoets.Integration.Forms.Views.SectionResultRow +{ + public class WaveImpactAsphaltCoverSectionResultRow : NumericFailureMechanismSectionResultRow + { + public WaveImpactAsphaltCoverSectionResultRow(NumericFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + } +} \ No newline at end of file Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRow/WaveImpactAsphaltSectionResultRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/NumericFailureMechanismResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/StrengthStabilityLengthwiseConstructionResultView.cs =================================================================== diff -u -rce8424c77c708edc0bb2150a9a6a0e75dad629fa -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/StrengthStabilityLengthwiseConstructionResultView.cs (.../StrengthStabilityLengthwiseConstructionResultView.cs) (revision ce8424c77c708edc0bb2150a9a6a0e75dad629fa) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/StrengthStabilityLengthwiseConstructionResultView.cs (.../StrengthStabilityLengthwiseConstructionResultView.cs) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -1,13 +1,67 @@ -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 StrengthStabilityLengthwiseConstructionResultView : NumericFailureMechanismResultView + public class StrengthStabilityLengthwiseConstructionResultView : FailureMechanismResultView { - protected override object CreateFailureMechanismSectionResultRow(NumericFailureMechanismSectionResult sectionResult) + public StrengthStabilityLengthwiseConstructionResultView() { - return new NumericFailureMechanismSectionResultRow(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(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult sectionResult) + { + return new StrengthStabilityLengthwiseConstructionSectionResultRow(sectionResult); + } + + protected override void Dispose(bool disposing) + { + DataGridViewControl.RemoveCellFormattingHandler(OnCellFormatting); + + base.Dispose(disposing); + } + + 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/WaterPressureAsphaltCoverResultView.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaterPressureAsphaltCoverResultView.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaterPressureAsphaltCoverResultView.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,67 @@ +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 WaterPressureAsphaltCoverResultView : FailureMechanismResultView + { + public WaterPressureAsphaltCoverResultView() + { + 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(WaterPressureAsphaltCoverFailureMechanismSectionResult sectionResult) + { + return new WaterPressureAsphaltCoverSectionResultRow(sectionResult); + } + + protected override void Dispose(bool disposing) + { + DataGridViewControl.RemoveCellFormattingHandler(OnCellFormatting); + + base.Dispose(disposing); + } + + 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 Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaterPressureAsphaltResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaveImpactAsphaltCoverResultView.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaveImpactAsphaltCoverResultView.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaveImpactAsphaltCoverResultView.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,67 @@ +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 WaveImpactAsphaltCoverResultView : FailureMechanismResultView + { + public WaveImpactAsphaltCoverResultView() + { + 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(WaveImpactAsphaltCoverFailureMechanismSectionResult sectionResult) + { + return new WaveImpactAsphaltCoverSectionResultRow(sectionResult); + } + + protected override void Dispose(bool disposing) + { + DataGridViewControl.RemoveCellFormattingHandler(OnCellFormatting); + + base.Dispose(disposing); + } + + 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 Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultView/WaveImpactAsphaltResultView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r8c0ec57a86cd0d73759f178bee1ed647f62692dc -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -153,19 +153,16 @@ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism }; - yield return new ViewInfo< - FailureMechanismSectionResultContext, - IEnumerable, - NumericFailureMechanismResultView> - { - 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< + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult, + StrengthStabilityLengthwiseConstructionResultView>(); + yield return CreateFailureMechanismResultViewInfo< + WaterPressureAsphaltCoverFailureMechanismSectionResult, + WaterPressureAsphaltCoverResultView>(); + yield return CreateFailureMechanismResultViewInfo< + WaveImpactAsphaltCoverFailureMechanismSectionResult, + WaveImpactAsphaltCoverResultView>(); + yield return CreateFailureMechanismResultViewInfo< MacrostabilityInwardsFailureMechanismSectionResult, MacrostabilityInwardsResultView>(); yield return CreateFailureMechanismResultViewInfo< @@ -303,15 +300,9 @@ .Build() }; - yield return new TreeNodeInfo> - { - Text = context => RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName, - Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, - ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) - .AddOpenItem() - .Build() - }; - + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); + yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); yield return CreateFailureMechanismSectionResultTreeNodeInfo(); @@ -507,10 +498,17 @@ var grassCoverErosionInwards = failureMechanism as GrassCoverErosionInwardsFailureMechanism; var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism; - var numericFailureMechanism = failureMechanism as IHasSectionResults; - var probabilityFailureMechanism = failureMechanism as IHasSectionResults; var simpleFailureMechanism = failureMechanism as IHasSectionResults; + var strengthStabilityLengthwiseConstruction = failureMechanism as IHasSectionResults; + var waterPressureAsphaltCover = failureMechanism as IHasSectionResults; + var waveImpactAsphaltCover = failureMechanism as IHasSectionResults; + + var closingStructure = failureMechanism as IHasSectionResults; + var macrostabilityInwards = failureMechanism as IHasSectionResults; + var macrostabilityOutwards = failureMechanism as IHasSectionResults; + var strengthStabilityPointConstruction = failureMechanism as IHasSectionResults; + if (piping != null) { yield return new PipingFailureMechanismContext(piping, nodeData); @@ -523,18 +521,38 @@ { yield return new HeightStructuresFailureMechanismContext(heightStructuresFailureMechanism, nodeData); } - else if (numericFailureMechanism != null) + else if (simpleFailureMechanism != null) { + yield return new SimpleFailureMechanismContext(failureMechanism, nodeData); + } + else if (strengthStabilityLengthwiseConstruction != null) + { yield return new NumericFailureMechanismContext(failureMechanism, nodeData); } - else if (probabilityFailureMechanism != null) + else if (waterPressureAsphaltCover != null) { + yield return new NumericFailureMechanismContext(failureMechanism, nodeData); + } + else if (waveImpactAsphaltCover != null) + { + yield return new NumericFailureMechanismContext(failureMechanism, nodeData); + } + else if (closingStructure != null) + { yield return new ArbitraryProbabilityFailureMechanismContext(failureMechanism, nodeData); } - else if (simpleFailureMechanism != null) + else if (macrostabilityInwards != null) { - yield return new SimpleFailureMechanismContext(failureMechanism, nodeData); + yield return new ArbitraryProbabilityFailureMechanismContext(failureMechanism, nodeData); } + else if (macrostabilityOutwards != null) + { + yield return new ArbitraryProbabilityFailureMechanismContext(failureMechanism, nodeData); + } + else if (strengthStabilityPointConstruction != null) + { + yield return new ArbitraryProbabilityFailureMechanismContext(failureMechanism, nodeData); + } else { throw new NotImplementedException(); @@ -611,7 +629,9 @@ private IList GetOutputs(IFailureMechanism nodeData) { var simple = nodeData as IHasSectionResults; - var custom = nodeData as IHasSectionResults; + var strengthStabilityLengthwiseConstruction = nodeData as IHasSectionResults; + var waterPressureAsphaltCover = nodeData as IHasSectionResults; + var waveImpactAsphaltCover = nodeData as IHasSectionResults; var closingStructure = nodeData as IHasSectionResults; var macrostabilityInwards = nodeData as IHasSectionResults; var macrostabilityOutwards = nodeData as IHasSectionResults; @@ -623,11 +643,21 @@ failureMechanismSectionResultContexts[0] = new FailureMechanismSectionResultContext(simple.SectionResults, nodeData); } - if (custom != null) + if (strengthStabilityLengthwiseConstruction != null) { failureMechanismSectionResultContexts[0] = - new FailureMechanismSectionResultContext(custom.SectionResults, nodeData); + new FailureMechanismSectionResultContext(strengthStabilityLengthwiseConstruction.SectionResults, nodeData); } + if (waterPressureAsphaltCover != null) + { + failureMechanismSectionResultContexts[0] = + new FailureMechanismSectionResultContext(waterPressureAsphaltCover.SectionResults, nodeData); + } + if (waveImpactAsphaltCover != null) + { + failureMechanismSectionResultContexts[0] = + new FailureMechanismSectionResultContext(waveImpactAsphaltCover.SectionResults, nodeData); + } if (closingStructure != null) { failureMechanismSectionResultContexts[0] = Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r8c0ec57a86cd0d73759f178bee1ed647f62692dc -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -72,6 +72,8 @@ + + @@ -80,17 +82,21 @@ - + + + + + - - + + @@ -149,6 +155,22 @@ {4843D6E5-066F-4795-94F5-1D53932DD03C} Ringtoets.Common.Data.TestUtil + + {90DE728E-48EF-4665-AB38-3D88E41D9F4D} + Ringtoets.GrassCoverErosionInwards.Data + + + {C540E627-B95B-4CC0-A1B6-A0BDF74936C7} + Ringtoets.GrassCoverErosionInwards.Forms + + + {1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99} + Ringtoets.HeightStructures.Data + + + {F0BCF06A-3D01-4D65-A249-E2A14AEC6EFD} + Ringtoets.HeightStructures.Forms + {888d4097-8bc2-4703-9fb1-8744c94d525e} Ringtoets.HydraRing.Calculation Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -rb9d20365707e77623054f96f0c8b544e86658e67 -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision b9d20365707e77623054f96f0c8b544e86658e67) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -33,6 +33,10 @@ using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; @@ -142,9 +146,14 @@ var failureMechanisms = new IFailureMechanism[] { new PipingFailureMechanism(), - new MacrostabilityInwardsFailureMechanism(), + new GrassCoverErosionInwardsFailureMechanism(), + new HeightStructuresFailureMechanism(), new GrassCoverErosionOutwardsFailureMechanism(), - new WaterPressureAsphaltCoverFailureMechanism() + new WaterPressureAsphaltCoverFailureMechanism(), + new ClosingStructureFailureMechanism(), + new MacrostabilityInwardsFailureMechanism(), + new MacrostabilityOutwardsFailureMechanism(), + new StrengthStabilityPointConstructionFailureMechanism() }; var contribution = new FailureMechanismContribution(failureMechanisms, 10.0, 2); @@ -160,7 +169,7 @@ var objects = info.ChildNodeObjects(assessmentSection).ToArray(); // Assert - Assert.AreEqual(8, objects.Length); + Assert.AreEqual(13, objects.Length); var referenceLineContext = (ReferenceLineContext) objects[0]; Assert.AreSame(assessmentSection.ReferenceLine, referenceLineContext.WrappedData); Assert.AreSame(assessmentSection, referenceLineContext.Parent); @@ -180,17 +189,37 @@ Assert.AreSame(failureMechanisms[0], pipingFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent); - var macroStabilityFailureMechanismContext = (ArbitraryProbabilityFailureMechanismContext)objects[5]; - Assert.AreSame(failureMechanisms[1], macroStabilityFailureMechanismContext.WrappedData); - Assert.AreSame(assessmentSection, macroStabilityFailureMechanismContext.Parent); + var grassCoverErosionInwardsFailureMechanismContext = (GrassCoverErosionInwardsFailureMechanismContext) objects[5]; + Assert.AreSame(failureMechanisms[1], grassCoverErosionInwardsFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, grassCoverErosionInwardsFailureMechanismContext.Parent); - var grassCoverErosionOutwardsFailureMechanismContext = (SimpleFailureMechanismContext)objects[6]; - Assert.AreSame(failureMechanisms[2], grassCoverErosionOutwardsFailureMechanismContext.WrappedData); - Assert.AreSame(assessmentSection, grassCoverErosionOutwardsFailureMechanismContext.Parent); + var heightStructuresFailureMechanismContext = (HeightStructuresFailureMechanismContext) objects[6]; + Assert.AreSame(failureMechanisms[2], heightStructuresFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, heightStructuresFailureMechanismContext.Parent); - var waterPressureAsphaltCoverFailureMechanismContext = (NumericFailureMechanismContext)objects[7]; - Assert.AreSame(failureMechanisms[3], waterPressureAsphaltCoverFailureMechanismContext.WrappedData); - Assert.AreSame(assessmentSection, waterPressureAsphaltCoverFailureMechanismContext.Parent); + var simpleFailureMechanismContext = (SimpleFailureMechanismContext)objects[7]; + Assert.AreSame(failureMechanisms[3], simpleFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, simpleFailureMechanismContext.Parent); + + var numericFailureMechanismContext = (NumericFailureMechanismContext)objects[8]; + Assert.AreSame(failureMechanisms[4], numericFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, numericFailureMechanismContext.Parent); + + var closingStructureFailureMechnaismContext = (ArbitraryProbabilityFailureMechanismContext)objects[9]; + Assert.AreSame(failureMechanisms[5], closingStructureFailureMechnaismContext.WrappedData); + Assert.AreSame(assessmentSection, closingStructureFailureMechnaismContext.Parent); + + var macrostabilityInwardsFailureMechanismContext = (ArbitraryProbabilityFailureMechanismContext)objects[10]; + Assert.AreSame(failureMechanisms[6], macrostabilityInwardsFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, macrostabilityInwardsFailureMechanismContext.Parent); + + var macrostabilityOutwardsFailureMechanismContext = (ArbitraryProbabilityFailureMechanismContext)objects[11]; + Assert.AreSame(failureMechanisms[7], macrostabilityOutwardsFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, macrostabilityOutwardsFailureMechanismContext.Parent); + + var strengthStabilityPointConstructionFailureMechanismContext = (ArbitraryProbabilityFailureMechanismContext)objects[12]; + Assert.AreSame(failureMechanisms[8], strengthStabilityPointConstructionFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, strengthStabilityPointConstructionFailureMechanismContext.Parent); } mocks.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision be3779b7be55ce7821035393e89cdde997b15883) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -19,9 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; +using System.Reflection; using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Common.Controls.TreeView; @@ -184,35 +186,51 @@ } [Test] - public void ChildNodeObjects_FailureMechanismIsRelevantWithCustomSectinoResults_OutputNodeAdded() + [TestCase(typeof(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult))] + [TestCase(typeof(WaterPressureAsphaltCoverFailureMechanismSectionResult))] + [TestCase(typeof(WaveImpactAsphaltCoverFailureMechanismSectionResult))] + [TestCase(typeof(ClosingStructureFailureMechanismSectionResult))] + [TestCase(typeof(MacrostabilityInwardsFailureMechanismSectionResult))] + [TestCase(typeof(MacrostabilityOutwardsFailureMechanismSectionResult))] + [TestCase(typeof(StrengthStabilityPointConstructionFailureMechanismSectionResult))] + public void ChildNodeObjects_FailureMechanismIsRelevantWithDifferentFailureMechanismSectionResults_OutputNodeAdded(Type t) { + // Delegate actual test + MethodInfo method = GetType().GetMethod("ChildNodeObjects_FailureMechanismIsRelevantWithSectionResults_OutputNodeAdded"); + MethodInfo genericMethod = method.MakeGenericMethod(t); + genericMethod.Invoke(this, null); + } + public void ChildNodeObjects_FailureMechanismIsRelevantWithSectionResults_OutputNodeAdded() where T : FailureMechanismSectionResult + { // Setup var assessmentSection = mocks.Stub(); using (var plugin = new RingtoetsGuiPlugin()) { var info = GetInfo(plugin); - var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism)); + var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism)); failureMechanism.Expect(fm => ((IFailureMechanism) fm).IsRelevant).Return(true); - failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any(); + failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any(); var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection); mocks.ReplayAll(); // Call object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); + + // Assert var outputFolder = (CategoryTreeFolder)children[1]; - var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0]; + var failureMechanismResultsContext = (FailureMechanismSectionResultContext)outputFolder.Contents[0]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.SectionResults); } } [Test] - public void ChildNodeObjects_FailureMechanismIsRelevantWithSimpleSectinoResults_OutputNodeAdded() + public void ChildNodeObjects_FailureMechanismIsRelevantWithSimpleSectionResults_OutputNodeAdded() { // Setup @@ -231,6 +249,8 @@ // Call object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray(); + + // Assert var outputFolder = (CategoryTreeFolder)children[1]; var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0]; Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/NumericFailureMechanismSectionResultContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,126 @@ +// 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.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.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 StrengthStabilityLengthwiseConstructionFailureMechanism(); + var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Oordeel", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var gui = mocks.StrictMultiMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); + + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,126 @@ +// 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.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.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 WaterPressureAsphaltCoverFailureMechanism(); + var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Oordeel", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var gui = mocks.StrictMultiMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); + + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,126 @@ +// 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.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.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest + { + 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 WaveImpactAsphaltCoverFailureMechanism(); + var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism); + + // Call + var text = info.Text(context); + + // Assert + Assert.AreEqual("Oordeel", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var gui = mocks.StrictMultiMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); + + gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + gui.Expect(g => g.ProjectOpened += null).IgnoreArguments(); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ClosingStructureResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ClosingStructureResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/ClosingStructureResultViewTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,258 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.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 ClosingStructureResultViewTest + { + [Test] + public void GivenFormWithClosingStructureFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new ClosingStructureResultView()) + { + 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 GivenFormWithClosingStructureFailureMechanismResultView_WhenDataSourceWithClosingStructureFailureMechanismSectionResultAssigned_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 ClosingStructureFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new ClosingStructureFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new ClosingStructureResultView()) + { + 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 GivenFormWithClosingStructureFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + { + // Given + var section = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); + var result = new ClosingStructureFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new ClosingStructureResultView()) + { + 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 GivenFormWithClosingStructureFailureMechanismResultView_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 ClosingStructureResultView()) + { + 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.Forms.Test/Views/MacrostabilityInwardsResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacrostabilityInwardsResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacrostabilityInwardsResultViewTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,258 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.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 MacrostabilityInwardsResultViewTest + { + [Test] + public void GivenFormWithMacrostabilityInwardsFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new MacrostabilityInwardsResultView()) + { + 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 GivenFormWithMacrostabilityInwardsFailureMechanismResultView_WhenDataSourceWithMacrostabilityInwardsFailureMechanismSectionResultAssigned_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 MacrostabilityInwardsFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new MacrostabilityInwardsFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new MacrostabilityInwardsResultView()) + { + 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 GivenFormWithMacrostabilityInwardsFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + { + // Given + var section = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); + var result = new MacrostabilityInwardsFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new MacrostabilityInwardsResultView()) + { + 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 GivenFormWithMacrostabilityInwardsFailureMechanismResultView_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 MacrostabilityInwardsResultView()) + { + 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.Forms.Test/Views/MacrostabilityOutwardsResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacrostabilityOutwardsResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacrostabilityOutwardsResultViewTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,258 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.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 MacrostabilityOutwardsResultViewTest + { + [Test] + public void GivenFormWithMacrostabilityOutwardsFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new MacrostabilityOutwardsResultView()) + { + 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 GivenFormWithMacrostabilityOutwardsFailureMechanismResultView_WhenDataSourceWithMacrostabilityOutwardsFailureMechanismSectionResultAssigned_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 MacrostabilityOutwardsFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new MacrostabilityOutwardsFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new MacrostabilityOutwardsResultView()) + { + 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 GivenFormWithMacrostabilityOutwardsFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + { + // Given + var section = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); + var result = new MacrostabilityOutwardsFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new MacrostabilityOutwardsResultView()) + { + 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 GivenFormWithMacrostabilityOutwardsFailureMechanismResultView_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 MacrostabilityOutwardsResultView()) + { + 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 Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/NumericFailureMechanismResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityLengthwiseConstructionResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityLengthwiseConstructionResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityLengthwiseConstructionResultViewTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,239 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; + +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionResultViewTest + { + [Test] + public void GivenFormWithStrengthStabilityLengthwiseConstructionResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new StrengthStabilityLengthwiseConstructionResultView()) + { + 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 GivenFormWithStrengthStabilityLengthwiseConstructionResultView_WhenDataSourceWithStrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssigned_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 StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new StrengthStabilityLengthwiseConstructionResultView()) + { + 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); + Assert.AreEqual(string.Format("{0}", result1.AssessmentLayerTwoA), 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); + Assert.AreEqual(string.Format("{0}", result2.AssessmentLayerTwoA), cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual(string.Format("{0}", result2.AssessmentLayerThree), cells[assessmentLayerThreeIndex].FormattedValue); + + AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + } + } + } + + [Test] + public void GivenFormWithStrengthStabilityLengthwiseConstructionFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + { + // Given + var section = new FailureMechanismSection("Section 1", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); + var result = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new StrengthStabilityLengthwiseConstructionResultView()) + { + 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 GivenFormWithStrengthStabilityLengthwiseConstructionResultView_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 StrengthStabilityLengthwiseConstructionResultView()) + { + 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 Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/StrengthStabilityPointConstructionResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaterPressureAsphaltCoverResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaterPressureAsphaltCoverResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaterPressureAsphaltCoverResultViewTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,239 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; + +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class WaterPressureAsphaltCoverResultViewTest + { + [Test] + public void GivenFormWithWaterPressureAsphaltCoverFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new WaterPressureAsphaltCoverResultView()) + { + 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 GivenFormWithWaterPressureAsphaltCoverFailureMechanismResultView_WhenDataSourceWithWaterPressureAsphaltCoverFailureMechanismSectionResultAssigned_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 WaterPressureAsphaltCoverFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new WaterPressureAsphaltCoverFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new WaterPressureAsphaltCoverResultView()) + { + 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); + Assert.AreEqual(string.Format("{0}", result1.AssessmentLayerTwoA), 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); + Assert.AreEqual(string.Format("{0}", result2.AssessmentLayerTwoA), 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 WaterPressureAsphaltCoverFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new WaterPressureAsphaltCoverResultView()) + { + 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 GivenFormWithWaterPressureAsphaltCoverFailureMechanismResultView_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 WaterPressureAsphaltCoverResultView()) + { + 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.Forms.Test/Views/WaveImpactAsphaltCoverResultViewTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveImpactAsphaltCoverResultViewTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveImpactAsphaltCoverResultViewTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,239 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResult; +using Ringtoets.Integration.Forms.Views.SectionResultView; + +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class WaveImpactAsphaltCoverResultViewTest + { + [Test] + public void GivenFormWithWaveImpactAsphaltCoverFailureMechanismResultView_ThenExpectedColumnsAreVisible() + { + // Given + using (var form = new Form()) + { + using (var view = new WaveImpactAsphaltCoverResultView()) + { + 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 GivenFormWithWaveImpactAsphaltCoverFailureMechanismResultView_WhenDataSourceWithWaveImpactAsphaltCoverFailureMechanismSectionResultAssigned_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 WaveImpactAsphaltCoverFailureMechanismSectionResult(section1) + { + AssessmentLayerOne = true, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + var result2 = new WaveImpactAsphaltCoverFailureMechanismSectionResult(section2) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; + + using (var form = new Form()) + { + using (var view = new WaveImpactAsphaltCoverResultView()) + { + 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); + Assert.AreEqual(string.Format("{0}", result1.AssessmentLayerTwoA), 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); + Assert.AreEqual(string.Format("{0}", result2.AssessmentLayerTwoA), 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 WaveImpactAsphaltCoverFailureMechanismSectionResult(section) + { + AssessmentLayerOne = false, + AssessmentLayerTwoA = (RoundedDouble)random.NextDouble(), + AssessmentLayerThree = (RoundedDouble)random.NextDouble() + }; + using (var form = new Form()) + { + using (var view = new WaveImpactAsphaltCoverResultView()) + { + 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 GivenFormWithWaveImpactAsphaltCoverFailureMechanismResultView_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 WaveImpactAsphaltCoverResultView()) + { + 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 -r8c0ec57a86cd0d73759f178bee1ed647f62692dc -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -71,10 +71,12 @@ + + - + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs =================================================================== diff -u -r8c0ec57a86cd0d73759f178bee1ed647f62692dc -r76c2371398aaacdc8ee6b0c8debd722a747519db --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 8c0ec57a86cd0d73759f178bee1ed647f62692dc) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -235,7 +235,7 @@ ViewInfo[] viewInfos = guiPlugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(9, viewInfos.Length); + Assert.AreEqual(11, viewInfos.Length); var contributionViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismContributionContext)); Assert.AreEqual(typeof(FailureMechanismContributionView), contributionViewInfo.ViewType); @@ -245,11 +245,21 @@ Assert.AreEqual(typeof(AssessmentSectionView), mapViewInfo.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.Map, mapViewInfo.Image); - var numericResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); - Assert.AreEqual(typeof(IEnumerable), numericResultViewInfo.ViewDataType); - Assert.AreEqual(typeof(NumericFailureMechanismResultView), numericResultViewInfo.ViewType); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, numericResultViewInfo.Image); + var strengthStabilityLengthwiseConstructionResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), strengthStabilityLengthwiseConstructionResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(StrengthStabilityLengthwiseConstructionResultView), strengthStabilityLengthwiseConstructionResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, strengthStabilityLengthwiseConstructionResultViewInfo.Image); + var waterPressureAsphaltCoverResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), waterPressureAsphaltCoverResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(WaterPressureAsphaltCoverResultView), waterPressureAsphaltCoverResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, waterPressureAsphaltCoverResultViewInfo.Image); + + var waveImpactAsphaltCoverResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); + Assert.AreEqual(typeof(IEnumerable), waveImpactAsphaltCoverResultViewInfo.ViewDataType); + Assert.AreEqual(typeof(WaveImpactAsphaltCoverResultView), waveImpactAsphaltCoverResultViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, waveImpactAsphaltCoverResultViewInfo.Image); + var closingStructureResultViewInfo = viewInfos.Single(vi => vi.DataType == typeof(FailureMechanismSectionResultContext)); Assert.AreEqual(typeof(IEnumerable), closingStructureResultViewInfo.ViewDataType); Assert.AreEqual(typeof(ClosingStructureResultView), closingStructureResultViewInfo.ViewType); @@ -303,7 +313,7 @@ TreeNodeInfo[] treeNodeInfos = guiPlugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(14, treeNodeInfos.Length); + Assert.AreEqual(16, 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))); @@ -312,7 +322,9 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContributionContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Fisheye: Tag 76c2371398aaacdc8ee6b0c8debd722a747519db refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/NumericFailureMechanismResultViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/StrengthStabilityLengthwiseConstructionResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/StrengthStabilityLengthwiseConstructionResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/StrengthStabilityLengthwiseConstructionResultViewInfoTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,333 @@ +// 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.Common.Forms.Views; +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 StrengthStabilityLengthwiseConstructionResultViewInfoTest + { + 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(StrengthStabilityLengthwiseConstructionResultView)); + } + + [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(); + using(var view = new StrengthStabilityLengthwiseConstructionResultView()) + { + // Call + var viewName = info.GetViewName(view, failureMechanism.SectionResults); + + // Assert + Assert.AreEqual("Oordeel", viewName); + } + } + + [Test] + public void ViewType_Always_ReturnsViewType() + { + // Call + var viewType = info.ViewType; + + // Assert + Assert.AreEqual(typeof(StrengthStabilityLengthwiseConstructionResultView), 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 StrengthStabilityLengthwiseConstructionResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new StrengthStabilityLengthwiseConstructionResultView()) + { + var failureMechanism = new Simple(); + 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 StrengthStabilityLengthwiseConstructionResultView()) + { + 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 StrengthStabilityLengthwiseConstructionResultView()) + { + 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 StrengthStabilityLengthwiseConstructionResultView()) + { + 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 StrengthStabilityLengthwiseConstructionResultView()) + { + 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 StrengthStabilityLengthwiseConstructionResultView()) + { + 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 viewMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + viewMock.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(viewMock, context); + + // Assert + mocks.VerifyAll(); + } + + private class Simple : FailureMechanismBase, IHasSectionResults + { + public Simple() : base("simple failure mechanism", "simple code") + { + SectionResults = new List(); + } + + public IEnumerable SectionResults { get; private set; } + + public override IEnumerable Calculations + { + get + { + throw new NotImplementedException(); + } + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaterPressureAsphaltCoverResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaterPressureAsphaltCoverResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaterPressureAsphaltCoverResultViewInfoTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,333 @@ +// 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.Common.Forms.Views; +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 WaterPressureAsphaltCoverResultViewInfoTest + { + 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(WaterPressureAsphaltCoverResultView)); + } + + [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(); + using(var view = new WaterPressureAsphaltCoverResultView()) + { + // Call + var viewName = info.GetViewName(view, failureMechanism.SectionResults); + + // Assert + Assert.AreEqual("Oordeel", viewName); + } + } + + [Test] + public void ViewType_Always_ReturnsViewType() + { + // Call + var viewType = info.ViewType; + + // Assert + Assert.AreEqual(typeof(WaterPressureAsphaltCoverResultView), 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 WaterPressureAsphaltCoverResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new WaterPressureAsphaltCoverResultView()) + { + var failureMechanism = new Simple(); + 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 WaterPressureAsphaltCoverResultView()) + { + 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 WaterPressureAsphaltCoverResultView()) + { + 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 WaterPressureAsphaltCoverResultView()) + { + 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 WaterPressureAsphaltCoverResultView()) + { + 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 WaterPressureAsphaltCoverResultView()) + { + 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 viewMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + viewMock.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(viewMock, context); + + // Assert + mocks.VerifyAll(); + } + + private class Simple : FailureMechanismBase, IHasSectionResults + { + public Simple() : base("simple failure mechanism", "simple code") + { + SectionResults = new List(); + } + + public IEnumerable SectionResults { get; private set; } + + public override IEnumerable Calculations + { + get + { + throw new NotImplementedException(); + } + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverResultViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverResultViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverResultViewInfoTest.cs (revision 76c2371398aaacdc8ee6b0c8debd722a747519db) @@ -0,0 +1,332 @@ +// 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 WaveImpactAsphaltCoverResultViewInfoTest + { + 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(WaveImpactAsphaltCoverResultView)); + } + + [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(); + using(var view = new WaveImpactAsphaltCoverResultView()) + { + // Call + var viewName = info.GetViewName(view, failureMechanism.SectionResults); + + // Assert + Assert.AreEqual("Oordeel", viewName); + } + } + + [Test] + public void ViewType_Always_ReturnsViewType() + { + // Call + var viewType = info.ViewType; + + // Assert + Assert.AreEqual(typeof(WaveImpactAsphaltCoverResultView), 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 WaveImpactAsphaltCoverResultView()) + { + var failureMechanism = new Simple(); + view.Data = failureMechanism.SectionResults; + + // Call + var closeForData = info.CloseForData(view, assessmentSectionMock); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + var failureMechanismMock = mocks.Stub("N", "C"); + assessmentSectionMock.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + failureMechanismMock + }); + + mocks.ReplayAll(); + + using (var view = new WaveImpactAsphaltCoverResultView()) + { + var failureMechanism = new Simple(); + 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 WaveImpactAsphaltCoverResultView()) + { + 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 WaveImpactAsphaltCoverResultView()) + { + 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 WaveImpactAsphaltCoverResultView()) + { + 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 WaveImpactAsphaltCoverResultView()) + { + 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 WaveImpactAsphaltCoverResultView()) + { + 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 viewMock = mocks.StrictMock(); + var failureMechanism = new Simple(); + var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism); + + viewMock.Expect(v => v.FailureMechanism = failureMechanism); + + mocks.ReplayAll(); + + // Call + info.AfterCreate(viewMock, context); + + // Assert + mocks.VerifyAll(); + } + + private class Simple : FailureMechanismBase, IHasSectionResults + { + public Simple() : base("simple failure mechanism", "simple code") + { + SectionResults = new List(); + } + + public IEnumerable SectionResults { get; private set; } + + public override IEnumerable Calculations + { + get + { + throw new NotImplementedException(); + } + } + } + } +} \ No newline at end of file