Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/DesignWaterLevelCalculationContext.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/DesignWaterLevelCalculationContext.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/DesignWaterLevelCalculationContext.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,42 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Ringtoets.Common.Data.Hydraulics; + +namespace Ringtoets.Common.Forms.PresentationObjects +{ + /// + /// Presentation object for all data required to configure an instance of + /// with a design water level calculation result. + /// + public class DesignWaterLevelCalculationContext : HydraulicBoundaryLocationCalculationContext + { + /// + /// Creates a new instance of . + /// + /// The which the + /// belongs to. + /// Thrown when is null. + public DesignWaterLevelCalculationContext(HydraulicBoundaryLocationCalculation wrappedData) + : base(wrappedData) {} + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/WaveHeightCalculationContext.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/WaveHeightCalculationContext.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/WaveHeightCalculationContext.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,42 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Ringtoets.Common.Data.Hydraulics; + +namespace Ringtoets.Common.Forms.PresentationObjects +{ + /// + /// Presentation object for all data required to configure an instance of + /// with a wave height calculation result. + /// + public class WaveHeightCalculationContext : HydraulicBoundaryLocationCalculationContext + { + /// + /// Creates a new instance of . + /// + /// The which the + /// belongs to. + /// Thrown when is null. + public WaveHeightCalculationContext(HydraulicBoundaryLocationCalculation wrappedData) + : base(wrappedData) {} + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -re9602557466ba57cb9d288377cf0a3ab0fb0426c -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision e9602557466ba57cb9d288377cf0a3ab0fb0426c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -61,6 +61,7 @@ + @@ -86,6 +87,7 @@ + @@ -172,6 +174,12 @@ + + UserControl + + + DesignWaterLevelCalculationsView.cs + @@ -263,6 +271,12 @@ UserControl + + UserControl + + + WaveHeightCalculationsView.cs + @@ -279,6 +293,9 @@ ScenarioSelectionControl.cs + + DesignWaterLevelCalculationsView.cs + FailureMechanismSectionsView.cs Designer @@ -316,6 +333,10 @@ RingtoetsMapControl.cs + + WaveHeightCalculationsView.cs + Designer + Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.Designer.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.Designer.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.Designer.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2017. 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. + +namespace Ringtoets.Common.Forms.Views +{ + partial class DesignWaterLevelCalculationsView + { + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DesignWaterLevelCalculationsView)); + this.SuspendLayout(); + // + // dataGridViewControl + // + resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); + // + // ButtonGroupBox + // + resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox"); + // + // DesignWaterLevelCalculationsView + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Name = "DesignWaterLevelCalculationsView"; + this.ResumeLayout(false); + + } + + #endregion + } +} Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,98 @@ +// Copyright (C) Stichting Deltares 2017. 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.Windows.Forms; +using Core.Common.Base; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Service.MessageProviders; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Common.Forms.Views +{ + /// + /// View for presenting and performing design water level calculations. + /// + public partial class DesignWaterLevelCalculationsView : HydraulicBoundaryCalculationsView + { + private readonly Func getNormFunc; + private readonly DesignWaterLevelCalculationMessageProvider messageProvider; + + /// + /// Creates a new instance of . + /// + /// The calculations to show in the view. + /// The assessment section which the calculations belong to. + /// for getting the norm to use during calculations. + /// The name of the category boundary. + /// Thrown when , + /// or is null. + /// Thrown when is null or empty. + public DesignWaterLevelCalculationsView(IObservableEnumerable calculations, + IAssessmentSection assessmentSection, + Func getNormFunc, + string categoryBoundaryName) + : base(calculations, assessmentSection) + { + if (getNormFunc == null) + { + throw new ArgumentNullException(nameof(getNormFunc)); + } + + InitializeComponent(); + + messageProvider = new DesignWaterLevelCalculationMessageProvider(categoryBoundaryName); + + this.getNormFunc = getNormFunc; + } + + protected override object CreateSelectedItemFromCurrentRow() + { + DataGridViewRow currentRow = dataGridViewControl.CurrentRow; + + if (currentRow != null) + { + return new DesignWaterLevelCalculationContext(((HydraulicBoundaryLocationCalculationRow) currentRow.DataBoundItem).CalculatableObject); + } + + return null; + } + + protected override void PerformSelectedCalculations(IEnumerable calculations) + { + CalculationGuiService.CalculateDesignWaterLevels(AssessmentSection.HydraulicBoundaryDatabase.FilePath, + AssessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(), + calculations, + getNormFunc(), + messageProvider); + } + + protected override void InitializeDataGridView() + { + base.InitializeDataGridView(); + dataGridViewControl.AddTextBoxColumn(nameof(HydraulicBoundaryLocationCalculationRow.Result), + RingtoetsCommonFormsResources.DesignWaterLevelCalculation_Result_DisplayName); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.resx =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.resx (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/DesignWaterLevelCalculationsView.resx (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + 523, 344 + + + dataGridViewControl + + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + 0, 344 + + + 523, 61 + + + Toetspeilen berekenen + + + ButtonGroupBox + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 6, 13 + + + 523, 405 + + + DesignWaterLevelCalculationsView + + + Ringtoets.Integration.Forms.Views.HydraulicBoundaryCalculationsView, Ringtoets.Integration.Forms, Culture=neutral, PublicKeyToken=null + + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.Designer.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.Designer.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.Designer.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2017. 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. + +namespace Ringtoets.Common.Forms.Views +{ + partial class WaveHeightCalculationsView + { + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WaveHeightCalculationsView)); + this.SuspendLayout(); + // + // dataGridViewControl + // + resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); + // + // ButtonGroupBox + // + resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox"); + // + // WaveHeightCalculationsView + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Name = "WaveHeightCalculationsView"; + this.ResumeLayout(false); + + } + + #endregion + } +} Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,98 @@ +// Copyright (C) Stichting Deltares 2017. 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.Windows.Forms; +using Core.Common.Base; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Service.MessageProviders; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Common.Forms.Views +{ + /// + /// View for presenting and performing wave height calculations. + /// + public partial class WaveHeightCalculationsView : HydraulicBoundaryCalculationsView + { + private readonly Func getNormFunc; + private readonly WaveHeightCalculationMessageProvider messageProvider; + + /// + /// Creates a new instance of . + /// + /// The calculations to show in the view. + /// The assessment section which the calculations belong to. + /// for getting the norm to use during calculations. + /// The name of the category boundary. + /// Thrown when , + /// or is null. + /// Thrown when is null or empty. + public WaveHeightCalculationsView(IObservableEnumerable calculations, + IAssessmentSection assessmentSection, + Func getNormFunc, + string categoryBoundaryName) + : base(calculations, assessmentSection) + { + if (getNormFunc == null) + { + throw new ArgumentNullException(nameof(getNormFunc)); + } + + InitializeComponent(); + + messageProvider = new WaveHeightCalculationMessageProvider(categoryBoundaryName); + + this.getNormFunc = getNormFunc; + } + + protected override object CreateSelectedItemFromCurrentRow() + { + DataGridViewRow currentRow = dataGridViewControl.CurrentRow; + + if (currentRow != null) + { + return new WaveHeightCalculationContext(((HydraulicBoundaryLocationCalculationRow) currentRow.DataBoundItem).CalculatableObject); + } + + return null; + } + + protected override void PerformSelectedCalculations(IEnumerable calculations) + { + CalculationGuiService.CalculateWaveHeights(AssessmentSection.HydraulicBoundaryDatabase.FilePath, + AssessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(), + calculations, + getNormFunc(), + messageProvider); + } + + protected override void InitializeDataGridView() + { + base.InitializeDataGridView(); + dataGridViewControl.AddTextBoxColumn(nameof(HydraulicBoundaryLocationCalculationRow.Result), + RingtoetsCommonFormsResources.WaveHeightCalculation_Result_DisplayName); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.resx =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.resx (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/WaveHeightCalculationsView.resx (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + 523, 344 + + + dataGridViewControl + + + Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + 0, 344 + + + 523, 61 + + + Golfhoogtes berekenen + + + ButtonGroupBox + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 6, 13 + + + 523, 405 + + + WaveHeightCalculationsView + + + Ringtoets.Integration.Forms.Views.HydraulicBoundaryCalculationsView, Ringtoets.Integration.Forms, Culture=neutral, PublicKeyToken=null + + \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/DesignWaterLevelCalculationContextTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/DesignWaterLevelCalculationContextTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/DesignWaterLevelCalculationContextTest.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,46 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; + +namespace Ringtoets.Common.Forms.Test.PresentationObjects +{ + [TestFixture] + public class DesignWaterLevelCalculationContextTest + { + [Test] + public void Constructor_ValidParameters_ExpectedValues() + { + // Setup + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()); + + // Call + var context = new DesignWaterLevelCalculationContext(hydraulicBoundaryLocationCalculation); + + // Assert + Assert.IsInstanceOf(context); + Assert.AreSame(hydraulicBoundaryLocationCalculation, context.WrappedData); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/WaveHeightCalculationContextTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/WaveHeightCalculationContextTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/WaveHeightCalculationContextTest.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,46 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; + +namespace Ringtoets.Common.Forms.Test.PresentationObjects +{ + [TestFixture] + public class WaveHeightCalculationContextTest + { + [Test] + public void Constructor_ValidParameters_ExpectedValues() + { + // Setup + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()); + + // Call + var context = new WaveHeightCalculationContext(hydraulicBoundaryLocationCalculation); + + // Assert + Assert.IsInstanceOf(context); + Assert.AreSame(hydraulicBoundaryLocationCalculation, context.WrappedData); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -re9602557466ba57cb9d288377cf0a3ab0fb0426c -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision e9602557466ba57cb9d288377cf0a3ab0fb0426c) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -68,6 +68,7 @@ + @@ -91,6 +92,7 @@ + @@ -154,6 +156,7 @@ + @@ -178,6 +181,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,689 @@ +// Copyright (C) Stichting Deltares 2017. 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.Globalization; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Base.Geometry; +using Core.Common.Controls.DataGrid; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Common.Service.MessageProviders; + +namespace Ringtoets.Common.Forms.Test.Views +{ + [TestFixture] + public class DesignWaterLevelCalculationsViewTest + { + private const int calculateColumnIndex = 0; + private const int includeIllustrationPointsColumnIndex = 1; + private const int locationNameColumnIndex = 2; + private const int locationIdColumnIndex = 3; + private const int locationColumnIndex = 4; + private const int designWaterLevelColumnIndex = 5; + + private Form testForm; + private MockRepository mockRepository; + + [SetUp] + public void Setup() + { + testForm = new Form(); + mockRepository = new MockRepository(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_GetNormFuncNull_ThrowsArgumentNullException() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + mockRepository.ReplayAll(); + + // Call + TestDelegate test = () => new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + null, + "A"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("getNormFunc", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + mockRepository.ReplayAll(); + + // Call + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) + { + // Assert + Assert.IsInstanceOf(view); + Assert.IsNull(view.Data); + } + } + + [Test] + public void Constructor_DataGridViewCorrectlyInitialized() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + mockRepository.ReplayAll(); + + // Call + ShowDesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + 0.01, + "A", + testForm); + + // Assert + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + Assert.AreEqual(6, calculationsDataGridView.ColumnCount); + + var calculateColumn = (DataGridViewCheckBoxColumn) calculationsDataGridView.Columns[calculateColumnIndex]; + Assert.AreEqual("Berekenen", calculateColumn.HeaderText); + + var includeIllustrationPointsColumn = (DataGridViewCheckBoxColumn) calculationsDataGridView.Columns[includeIllustrationPointsColumnIndex]; + Assert.AreEqual("Illustratiepunten inlezen", includeIllustrationPointsColumn.HeaderText); + + var locationNameColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[locationNameColumnIndex]; + Assert.AreEqual("Naam", locationNameColumn.HeaderText); + + var locationIdColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[locationIdColumnIndex]; + Assert.AreEqual("ID", locationIdColumn.HeaderText); + + var locationColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[locationColumnIndex]; + Assert.AreEqual("Coördinaten [m]", locationColumn.HeaderText); + + var designWaterLevelColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[designWaterLevelColumnIndex]; + Assert.AreEqual("Waterstand [m+NAP]", designWaterLevelColumn.HeaderText); + + var button = (Button) testForm.Controls.Find("CalculateForSelectedButton", true).First(); + Assert.IsFalse(button.Enabled); + } + + [Test] + public void Constructor_WithCalculations_DataGridViewCorrectlyInitialized() + { + // Call + ShowFullyConfiguredDesignWaterLevelCalculationsView(GetTestHydraulicBoundaryLocationCalculations(), testForm); + + // Assert + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + Assert.AreEqual(4, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(1, 1).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[designWaterLevelColumnIndex].FormattedValue); + + cells = rows[1].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(2, 2).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), cells[designWaterLevelColumnIndex].FormattedValue); + + cells = rows[2].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("3", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("3", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(3, 3).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[designWaterLevelColumnIndex].FormattedValue); + + cells = rows[3].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("4", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("4", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(4, 4).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), cells[designWaterLevelColumnIndex].FormattedValue); + } + + [Test] + public void DesignWaterLevelCalculationsView_CalculationsUpdated_DataGridViewCorrectlyUpdated() + { + // Setup + ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + ShowFullyConfiguredDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + const double designWaterLevel = 10.23; + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(10, "10", 10.0, 10.0)) + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = new TestHydraulicBoundaryLocationCalculationOutput(designWaterLevel) + }; + + // Precondition + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + Assert.AreEqual(4, rows.Count); + + hydraulicBoundaryLocationCalculations.Clear(); + hydraulicBoundaryLocationCalculations.Add(hydraulicBoundaryLocationCalculation); + + // Call + hydraulicBoundaryLocationCalculations.NotifyObservers(); + + // Assert + Assert.AreEqual(1, rows.Count); + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("10", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("10", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(10, 10).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(designWaterLevel, cells[designWaterLevelColumnIndex].Value); + } + + [Test] + public void DesignWaterLevelCalculationsView_CalculationUpdated_DataGridViewCorrectlyUpdated() + { + // Setup + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + ShowFullyConfiguredDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + // Precondition + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); + + HydraulicBoundaryLocationCalculation calculation = hydraulicBoundaryLocationCalculations.First(); + + // Call + calculation.InputParameters.ShouldIllustrationPointsBeCalculated = true; + calculation.NotifyObservers(); + + // Assert + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + } + + [Test] + public void DesignWaterLevelCalculationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated() + { + // Setup + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + ShowFullyConfiguredDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + + calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(2, 0)); + + // Precondition + CollectionAssert.IsEmpty(illustrationPointsControl.Data); + + var topLevelIllustrationPoints = new[] + { + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "Regular", + new TestSubMechanismIllustrationPoint()) + }; + var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); + var output = new TestHydraulicBoundaryLocationCalculationOutput(generalResult); + + // Call + HydraulicBoundaryLocationCalculation boundaryLocationCalculation = hydraulicBoundaryLocationCalculations.ElementAt(2); + boundaryLocationCalculation.Output = output; + boundaryLocationCalculation.NotifyObservers(); + + // Assert + IEnumerable expectedControlItems = CreateControlItems(generalResult); + CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); + } + + [Test] + public void CalculateForSelectedButton_OneSelected_CallsCalculateDesignWaterLevels() + { + // Setup + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + DesignWaterLevelCalculationsView view = ShowFullyConfiguredDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + var guiService = mockRepository.StrictMock(); + + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + guiService.Expect(ch => ch.CalculateDesignWaterLevels(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => { performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); }); + mockRepository.ReplayAll(); + + view.CalculationGuiService = guiService; + var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + buttonTester.Click(); + + // Assert + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + [Test] + public void CalculateForSelectedButton_OneSelectedButCalculationGuiServiceNotSet_DoesNotThrowException() + { + // Setup + ShowFullyConfiguredDesignWaterLevelCalculationsView(GetTestHydraulicBoundaryLocationCalculations(), testForm); + + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + TestDelegate test = () => button.Click(); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + public void CalculateForSelectedButton_HydraulicBoundaryDatabaseWithCanUsePreprocessorFalse_CalculateDesignWaterLevelsCalledAsExpected() + { + // Setup + const string databaseFilePath = "DatabaseFilePath"; + const double norm = 0.01; + const string categoryBoundaryName = "A"; + + var assessmentSection = mockRepository.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = databaseFilePath + }; + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var guiService = mockRepository.StrictMock(); + + var hydraulicBoundaryDatabaseFilePathValue = ""; + var preprocessorDirectoryValue = ""; + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + double normValue = double.NaN; + ICalculationMessageProvider messageProviderValue = null; + guiService.Expect(ch => ch.CalculateDesignWaterLevels(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => + { + hydraulicBoundaryDatabaseFilePathValue = invocation.Arguments[0].ToString(); + preprocessorDirectoryValue = invocation.Arguments[1].ToString(); + performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); + normValue = (double) invocation.Arguments[3]; + messageProviderValue = (ICalculationMessageProvider) invocation.Arguments[4]; + }); + + mockRepository.ReplayAll(); + + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + DesignWaterLevelCalculationsView view = ShowDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, + assessmentSection, + norm, + categoryBoundaryName, + testForm); + + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + DataGridViewRowCollection rows = calculationsDataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.IsInstanceOf(messageProviderValue); + Assert.AreEqual($"Waterstand berekenen voor locatie 'Location name' (Categorie {categoryBoundaryName})", + messageProviderValue.GetActivityDescription("Location name")); + Assert.AreEqual(databaseFilePath, hydraulicBoundaryDatabaseFilePathValue); + Assert.AreEqual("", preprocessorDirectoryValue); + Assert.AreEqual(norm, normValue); + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + [Test] + public void CalculateForSelectedButton_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_CalculateDesignWaterLevelsCalledAsExpected() + { + // Setup + const string databaseFilePath = "DatabaseFilePath"; + const string preprocessorDirectory = "PreprocessorDirectory"; + const double norm = 0.01; + const string categoryBoundaryName = "A"; + + var assessmentSection = mockRepository.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = databaseFilePath, + CanUsePreprocessor = true, + UsePreprocessor = true, + PreprocessorDirectory = preprocessorDirectory + }; + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var guiService = mockRepository.StrictMock(); + + var hydraulicBoundaryDatabaseFilePathValue = ""; + var preprocessorDirectoryValue = ""; + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + double normValue = double.NaN; + ICalculationMessageProvider messageProviderValue = null; + guiService.Expect(ch => ch.CalculateDesignWaterLevels(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => + { + hydraulicBoundaryDatabaseFilePathValue = invocation.Arguments[0].ToString(); + preprocessorDirectoryValue = invocation.Arguments[1].ToString(); + performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); + normValue = (double) invocation.Arguments[3]; + messageProviderValue = (ICalculationMessageProvider) invocation.Arguments[4]; + }); + + mockRepository.ReplayAll(); + + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + DesignWaterLevelCalculationsView view = ShowDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, + assessmentSection, + norm, + categoryBoundaryName, + testForm); + + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + DataGridViewRowCollection rows = calculationsDataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.IsInstanceOf(messageProviderValue); + Assert.AreEqual($"Waterstand berekenen voor locatie 'Location name' (Categorie {categoryBoundaryName})", + messageProviderValue.GetActivityDescription("Location name")); + Assert.AreEqual(databaseFilePath, hydraulicBoundaryDatabaseFilePathValue); + Assert.AreEqual(preprocessorDirectory, preprocessorDirectoryValue); + Assert.AreEqual(norm, normValue); + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + [Test] + public void CalculateForSelectedButton_HydraulicBoundaryDatabaseWithUsePreprocessorFalse_CalculateDesignWaterLevelsCalledAsExpected() + { + // Setup + const string databaseFilePath = "DatabaseFilePath"; + const double norm = 0.01; + const string categoryBoundaryName = "A"; + + var assessmentSection = mockRepository.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = databaseFilePath, + CanUsePreprocessor = true, + UsePreprocessor = false, + PreprocessorDirectory = "InvalidPreprocessorDirectory" + }; + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var guiService = mockRepository.StrictMock(); + + var hydraulicBoundaryDatabaseFilePathValue = ""; + var preprocessorDirectoryValue = ""; + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + double normValue = double.NaN; + ICalculationMessageProvider messageProviderValue = null; + guiService.Expect(ch => ch.CalculateDesignWaterLevels(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => + { + hydraulicBoundaryDatabaseFilePathValue = invocation.Arguments[0].ToString(); + preprocessorDirectoryValue = invocation.Arguments[1].ToString(); + performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); + normValue = (double) invocation.Arguments[3]; + messageProviderValue = (ICalculationMessageProvider) invocation.Arguments[4]; + }); + + mockRepository.ReplayAll(); + + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + DesignWaterLevelCalculationsView view = ShowDesignWaterLevelCalculationsView(hydraulicBoundaryLocationCalculations, + assessmentSection, + norm, + categoryBoundaryName, + testForm); + + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + DataGridViewRowCollection rows = calculationsDataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.IsInstanceOf(messageProviderValue); + Assert.AreEqual($"Waterstand berekenen voor locatie 'Location name' (Categorie {categoryBoundaryName})", + messageProviderValue.GetActivityDescription("Location name")); + Assert.AreEqual(databaseFilePath, hydraulicBoundaryDatabaseFilePathValue); + Assert.AreEqual(string.Empty, preprocessorDirectoryValue); + Assert.AreEqual(norm, normValue); + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + private DataGridView GetCalculationsDataGridView() + { + return ControlTestHelper.GetDataGridView(testForm, "DataGridView"); + } + + private DataGridViewControl GetCalculationsDataGridViewControl() + { + return ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); + } + + private IllustrationPointsControl GetIllustrationPointsControl() + { + return ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").Single(); + } + + private static IEnumerable CreateControlItems( + GeneralResult generalResult) + { + return generalResult.TopLevelIllustrationPoints + .Select(topLevelIllustrationPoint => + { + SubMechanismIllustrationPoint illustrationPoint = topLevelIllustrationPoint.SubMechanismIllustrationPoint; + return new IllustrationPointControlItem(topLevelIllustrationPoint, + topLevelIllustrationPoint.WindDirection.Name, + topLevelIllustrationPoint.ClosingSituation, + illustrationPoint.Stochasts, + illustrationPoint.Beta); + }); + } + + private static DesignWaterLevelCalculationsView ShowDesignWaterLevelCalculationsView(IObservableEnumerable calculations, + IAssessmentSection assessmentSection, + double norm, + string categoryBoundaryName, + Form form) + { + var view = new DesignWaterLevelCalculationsView(calculations, + assessmentSection, + () => norm, + categoryBoundaryName); + + form.Controls.Add(view); + form.Show(); + + return view; + } + + private static DesignWaterLevelCalculationsView ShowFullyConfiguredDesignWaterLevelCalculationsView(IObservableEnumerable calculations, + Form form) + { + var assessmentSection = new AssessmentSectionStub(); + + return ShowDesignWaterLevelCalculationsView(calculations, assessmentSection, 0.01, "A", form); + } + + private static ObservableList GetTestHydraulicBoundaryLocationCalculations() + { + var topLevelIllustrationPoints = new[] + { + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "Regular", + new TestSubMechanismIllustrationPoint()), + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "Test", + new TestSubMechanismIllustrationPoint()) + }; + + var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); + + return new ObservableList + { + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(1, "1", 1.0, 1.0)), + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(2, "2", 2.0, 2.0)) + { + Output = new TestHydraulicBoundaryLocationCalculationOutput(1.23) + }, + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(3, "3", 3.0, 3.0)) + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + } + }, + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(4, "4", 4.0, 4.0)) + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = new TestHydraulicBoundaryLocationCalculationOutput(1.01, generalResult) + } + }; + } + + [TestFixture] + private class ViewSynchronizationTest : CalculationsViewSynchronizationTester + { + private ObservableList calculations; + + protected override int OutputColumnIndex + { + get + { + return designWaterLevelColumnIndex; + } + } + + public override void Setup() + { + calculations = GetTestHydraulicBoundaryLocationCalculations(); + + base.Setup(); + } + + protected override object GetCalculationSelection(CalculationsView view, object selectedRowObject) + { + return new DesignWaterLevelCalculationContext(((HydraulicBoundaryLocationCalculationRow) selectedRowObject).CalculatableObject); + } + + protected override CalculationsView ShowFullyConfiguredCalculationsView(Form form) + { + return ShowFullyConfiguredDesignWaterLevelCalculationsView(calculations, form); + } + + protected override ObservableList GetCalculationsInView(CalculationsView view) + { + return calculations; + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/WaveHeightCalculationsViewTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/WaveHeightCalculationsViewTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/WaveHeightCalculationsViewTest.cs (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -0,0 +1,689 @@ +// Copyright (C) Stichting Deltares 2017. 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.Globalization; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Base.Geometry; +using Core.Common.Controls.DataGrid; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.Common.Forms.Views; +using Ringtoets.Common.Service.MessageProviders; + +namespace Ringtoets.Common.Forms.Test.Views +{ + [TestFixture] + public class WaveHeightCalculationsViewTest + { + private const int calculateColumnIndex = 0; + private const int includeIllustrationPointsColumnIndex = 1; + private const int locationNameColumnIndex = 2; + private const int locationIdColumnIndex = 3; + private const int locationColumnIndex = 4; + private const int waveHeightColumnIndex = 5; + + private Form testForm; + private MockRepository mockRepository; + + [SetUp] + public void Setup() + { + testForm = new Form(); + mockRepository = new MockRepository(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_GetNormFuncNull_ThrowsArgumentNullException() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + mockRepository.ReplayAll(); + + // Call + TestDelegate test = () => new WaveHeightCalculationsView(new ObservableList(), + assessmentSection, + null, + "A"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("getNormFunc", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + mockRepository.ReplayAll(); + + // Call + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) + { + // Assert + Assert.IsInstanceOf(view); + Assert.IsNull(view.Data); + } + } + + [Test] + public void Constructor_DataGridViewCorrectlyInitialized() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + mockRepository.ReplayAll(); + + // Call + ShowWaveHeightCalculationsView(new ObservableList(), + assessmentSection, + 0.01, + "A", + testForm); + + // Assert + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + Assert.AreEqual(6, calculationsDataGridView.ColumnCount); + + var calculateColumn = (DataGridViewCheckBoxColumn) calculationsDataGridView.Columns[calculateColumnIndex]; + Assert.AreEqual("Berekenen", calculateColumn.HeaderText); + + var includeIllustrationPointsColumn = (DataGridViewCheckBoxColumn) calculationsDataGridView.Columns[includeIllustrationPointsColumnIndex]; + Assert.AreEqual("Illustratiepunten inlezen", includeIllustrationPointsColumn.HeaderText); + + var locationNameColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[locationNameColumnIndex]; + Assert.AreEqual("Naam", locationNameColumn.HeaderText); + + var locationIdColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[locationIdColumnIndex]; + Assert.AreEqual("ID", locationIdColumn.HeaderText); + + var locationColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[locationColumnIndex]; + Assert.AreEqual("Coördinaten [m]", locationColumn.HeaderText); + + var waveHeightColumn = (DataGridViewTextBoxColumn) calculationsDataGridView.Columns[waveHeightColumnIndex]; + Assert.AreEqual("Golfhoogte [m]", waveHeightColumn.HeaderText); + + var button = (Button) testForm.Controls.Find("CalculateForSelectedButton", true).First(); + Assert.IsFalse(button.Enabled); + } + + [Test] + public void Constructor_WithCalculations_DataGridViewCorrectlyInitialized() + { + // Call + ShowFullyConfiguredWaveHeightCalculationsView(GetTestHydraulicBoundaryLocationCalculations(), testForm); + + // Assert + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + Assert.AreEqual(4, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(1, 1).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[waveHeightColumnIndex].FormattedValue); + + cells = rows[1].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(2, 2).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), cells[waveHeightColumnIndex].FormattedValue); + + cells = rows[2].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("3", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("3", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(3, 3).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[waveHeightColumnIndex].FormattedValue); + + cells = rows[3].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("4", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("4", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(4, 4).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), cells[waveHeightColumnIndex].FormattedValue); + } + + [Test] + public void WaveHeightCalculationsView_CalculationsUpdated_DataGridViewCorrectlyUpdated() + { + // Setup + ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + const double waveHeight = 10.23; + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(10, "10", 10.0, 10.0)) + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = new TestHydraulicBoundaryLocationCalculationOutput(waveHeight) + }; + + // Precondition + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + Assert.AreEqual(4, rows.Count); + + hydraulicBoundaryLocationCalculations.Clear(); + hydraulicBoundaryLocationCalculations.Add(hydraulicBoundaryLocationCalculation); + + // Call + hydraulicBoundaryLocationCalculations.NotifyObservers(); + + // Assert + Assert.AreEqual(1, rows.Count); + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("10", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("10", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(10, 10).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(waveHeight, cells[waveHeightColumnIndex].Value); + } + + [Test] + public void WaveHeightCalculationsView_CalculationUpdated_DataGridViewCorrectlyUpdated() + { + // Setup + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + // Precondition + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); + + HydraulicBoundaryLocationCalculation calculation = hydraulicBoundaryLocationCalculations.First(); + + // Call + calculation.InputParameters.ShouldIllustrationPointsBeCalculated = true; + calculation.NotifyObservers(); + + // Assert + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + } + + [Test] + public void WaveHeightCalculationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated() + { + // Setup + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + + calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(2, 0)); + + // Precondition + CollectionAssert.IsEmpty(illustrationPointsControl.Data); + + var topLevelIllustrationPoints = new[] + { + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "Regular", + new TestSubMechanismIllustrationPoint()) + }; + var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); + var output = new TestHydraulicBoundaryLocationCalculationOutput(generalResult); + + // Call + HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculations.ElementAt(2); + hydraulicBoundaryLocationCalculation.Output = output; + hydraulicBoundaryLocationCalculation.NotifyObservers(); + + // Assert + IEnumerable expectedControlItems = CreateControlItems(generalResult); + CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); + } + + [Test] + public void CalculateForSelectedButton_OneSelected_CallsCalculateWaveHeights() + { + // Setup + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + WaveHeightCalculationsView view = ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm); + + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + var guiService = mockRepository.StrictMock(); + + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + guiService.Expect(ch => ch.CalculateWaveHeights(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => { performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); }); + mockRepository.ReplayAll(); + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + [Test] + public void CalculateForSelectedButton_OneSelectedButCalculationGuiServiceNotSet_DoesNotThrowException() + { + // Setup + ShowFullyConfiguredWaveHeightCalculationsView(GetTestHydraulicBoundaryLocationCalculations(), testForm); + + DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); + DataGridViewRowCollection rows = calculationsDataGridViewControl.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + TestDelegate test = () => button.Click(); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + public void CalculateForSelectedButton_HydraulicBoundaryDatabaseWithCanUsePreprocessorFalse_CalculateWaveHeightsCalledAsExpected() + { + // Setup + const string databaseFilePath = "DatabaseFilePath"; + const double norm = 0.01; + const string categoryBoundaryName = "A"; + + var assessmentSection = mockRepository.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = databaseFilePath + }; + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var guiService = mockRepository.StrictMock(); + + var hydraulicBoundaryDatabaseFilePathValue = ""; + var preprocessorDirectoryValue = ""; + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + double normValue = double.NaN; + ICalculationMessageProvider messageProviderValue = null; + guiService.Expect(ch => ch.CalculateWaveHeights(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => + { + hydraulicBoundaryDatabaseFilePathValue = invocation.Arguments[0].ToString(); + preprocessorDirectoryValue = invocation.Arguments[1].ToString(); + performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); + normValue = (double) invocation.Arguments[3]; + messageProviderValue = (ICalculationMessageProvider) invocation.Arguments[4]; + }); + + mockRepository.ReplayAll(); + + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + WaveHeightCalculationsView view = ShowWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, + assessmentSection, + norm, + categoryBoundaryName, + testForm); + + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + DataGridViewRowCollection rows = calculationsDataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.IsInstanceOf(messageProviderValue); + Assert.AreEqual($"Golfhoogte berekenen voor locatie 'Location name' (Categorie {categoryBoundaryName})", + messageProviderValue.GetActivityDescription("Location name")); + Assert.AreEqual(databaseFilePath, hydraulicBoundaryDatabaseFilePathValue); + Assert.AreEqual("", preprocessorDirectoryValue); + Assert.AreEqual(norm, normValue); + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + [Test] + public void CalculateForSelectedButton_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_CalculateWaveHeightsCalledAsExpected() + { + // Setup + const string databaseFilePath = "DatabaseFilePath"; + const string preprocessorDirectory = "PreprocessorDirectory"; + const double norm = 0.01; + const string categoryBoundaryName = "A"; + + var assessmentSection = mockRepository.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = databaseFilePath, + CanUsePreprocessor = true, + UsePreprocessor = true, + PreprocessorDirectory = preprocessorDirectory + }; + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var guiService = mockRepository.StrictMock(); + + var hydraulicBoundaryDatabaseFilePathValue = ""; + var preprocessorDirectoryValue = ""; + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + double normValue = double.NaN; + ICalculationMessageProvider messageProviderValue = null; + guiService.Expect(ch => ch.CalculateWaveHeights(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => + { + hydraulicBoundaryDatabaseFilePathValue = invocation.Arguments[0].ToString(); + preprocessorDirectoryValue = invocation.Arguments[1].ToString(); + performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); + normValue = (double) invocation.Arguments[3]; + messageProviderValue = (ICalculationMessageProvider) invocation.Arguments[4]; + }); + + mockRepository.ReplayAll(); + + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + WaveHeightCalculationsView view = ShowWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, + assessmentSection, + norm, + categoryBoundaryName, + testForm); + + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + DataGridViewRowCollection rows = calculationsDataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.IsInstanceOf(messageProviderValue); + Assert.AreEqual($"Golfhoogte berekenen voor locatie 'Location name' (Categorie {categoryBoundaryName})", + messageProviderValue.GetActivityDescription("Location name")); + Assert.AreEqual(databaseFilePath, hydraulicBoundaryDatabaseFilePathValue); + Assert.AreEqual(preprocessorDirectory, preprocessorDirectoryValue); + Assert.AreEqual(norm, normValue); + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + [Test] + public void CalculateForSelectedButton_HydraulicBoundaryDatabaseWithUsePreprocessorFalse_CalculateWaveHeightsCalledAsExpected() + { + // Setup + const string databaseFilePath = "DatabaseFilePath"; + const double norm = 0.01; + const string categoryBoundaryName = "A"; + + var assessmentSection = mockRepository.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = databaseFilePath, + CanUsePreprocessor = true, + UsePreprocessor = false, + PreprocessorDirectory = "InvalidPreprocessorDirectory" + }; + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var guiService = mockRepository.StrictMock(); + + var hydraulicBoundaryDatabaseFilePathValue = ""; + var preprocessorDirectoryValue = ""; + HydraulicBoundaryLocationCalculation[] performedCalculations = null; + double normValue = double.NaN; + ICalculationMessageProvider messageProviderValue = null; + guiService.Expect(ch => ch.CalculateWaveHeights(null, null, null, int.MinValue, null)).IgnoreArguments().WhenCalled( + invocation => + { + hydraulicBoundaryDatabaseFilePathValue = invocation.Arguments[0].ToString(); + preprocessorDirectoryValue = invocation.Arguments[1].ToString(); + performedCalculations = ((IEnumerable) invocation.Arguments[2]).ToArray(); + normValue = (double) invocation.Arguments[3]; + messageProviderValue = (ICalculationMessageProvider) invocation.Arguments[4]; + }); + + mockRepository.ReplayAll(); + + IObservableEnumerable hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); + + WaveHeightCalculationsView view = ShowWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, + assessmentSection, + norm, + categoryBoundaryName, + testForm); + + DataGridView calculationsDataGridView = GetCalculationsDataGridView(); + DataGridViewRowCollection rows = calculationsDataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + view.CalculationGuiService = guiService; + var button = new ButtonTester("CalculateForSelectedButton", testForm); + + // Call + button.Click(); + + // Assert + Assert.IsInstanceOf(messageProviderValue); + Assert.AreEqual($"Golfhoogte berekenen voor locatie 'Location name' (Categorie {categoryBoundaryName})", + messageProviderValue.GetActivityDescription("Location name")); + Assert.AreEqual(databaseFilePath, hydraulicBoundaryDatabaseFilePathValue); + Assert.AreEqual(string.Empty, preprocessorDirectoryValue); + Assert.AreEqual(norm, normValue); + Assert.AreEqual(1, performedCalculations.Length); + Assert.AreSame(hydraulicBoundaryLocationCalculations.First(), performedCalculations.First()); + } + + private DataGridView GetCalculationsDataGridView() + { + return ControlTestHelper.GetDataGridView(testForm, "DataGridView"); + } + + private DataGridViewControl GetCalculationsDataGridViewControl() + { + return ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); + } + + private IllustrationPointsControl GetIllustrationPointsControl() + { + return ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").Single(); + } + + private static IEnumerable CreateControlItems( + GeneralResult generalResult) + { + return generalResult.TopLevelIllustrationPoints + .Select(topLevelIllustrationPoint => + { + SubMechanismIllustrationPoint illustrationPoint = topLevelIllustrationPoint.SubMechanismIllustrationPoint; + return new IllustrationPointControlItem(topLevelIllustrationPoint, + topLevelIllustrationPoint.WindDirection.Name, + topLevelIllustrationPoint.ClosingSituation, + illustrationPoint.Stochasts, + illustrationPoint.Beta); + }); + } + + private static WaveHeightCalculationsView ShowWaveHeightCalculationsView(IObservableEnumerable calculations, + IAssessmentSection assessmentSection, + double norm, + string categoryBoundaryName, + Form form) + { + var view = new WaveHeightCalculationsView(calculations, + assessmentSection, + () => norm, + categoryBoundaryName); + + form.Controls.Add(view); + form.Show(); + + return view; + } + + private static WaveHeightCalculationsView ShowFullyConfiguredWaveHeightCalculationsView(IObservableEnumerable calculations, + Form form) + { + var assessmentSection = new AssessmentSectionStub(); + + return ShowWaveHeightCalculationsView(calculations, assessmentSection, 0.01, "A", form); + } + + private static ObservableList GetTestHydraulicBoundaryLocationCalculations() + { + var topLevelIllustrationPoints = new[] + { + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "Regular", + new TestSubMechanismIllustrationPoint()), + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "Test", + new TestSubMechanismIllustrationPoint()) + }; + + var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); + + return new ObservableList + { + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(1, "1", 1.0, 1.0)), + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(2, "2", 2.0, 2.0)) + { + Output = new TestHydraulicBoundaryLocationCalculationOutput(1.23) + }, + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(3, "3", 3.0, 3.0)) + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + } + }, + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(4, "4", 4.0, 4.0)) + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = new TestHydraulicBoundaryLocationCalculationOutput(1.01, generalResult) + } + }; + } + + [TestFixture] + public class ViewSynchronizationTest : CalculationsViewSynchronizationTester + { + private ObservableList calculations; + + protected override int OutputColumnIndex + { + get + { + return waveHeightColumnIndex; + } + } + + public override void Setup() + { + calculations = GetTestHydraulicBoundaryLocationCalculations(); + + base.Setup(); + } + + protected override object GetCalculationSelection(CalculationsView view, object selectedRowObject) + { + return new WaveHeightCalculationContext(((HydraulicBoundaryLocationCalculationRow) selectedRowObject).CalculatableObject); + } + + protected override CalculationsView ShowFullyConfiguredCalculationsView(Form form) + { + return ShowFullyConfiguredWaveHeightCalculationsView(calculations, form); + } + + protected override ObservableList GetCalculationsInView(CalculationsView view) + { + return calculations; + } + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj =================================================================== diff -u -r1eb7e7ef92a8a08a227ce81e75a2ac95df4b3b57 -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 1eb7e7ef92a8a08a227ce81e75a2ac95df4b3b57) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -44,17 +44,11 @@ GrassCoverErosionOutwardsFailureMechanismView.cs - - UserControl - UserControl - - UserControl - Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsDesignWaterLevelCalculationsView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsWaveHeightCalculationsView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r4278b8ff350cb0c4629c8609e2b8267af9f5da5b -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 4278b8ff350cb0c4629c8609e2b8267af9f5da5b) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -45,6 +45,7 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TreeNodeInfos; +using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Plugin; using Ringtoets.Common.Service; using Ringtoets.Common.Service.MessageProviders; @@ -177,35 +178,33 @@ yield return new ViewInfo< GrassCoverErosionOutwardsDesignWaterLevelCalculationsContext, IObservableEnumerable, - GrassCoverErosionOutwardsDesignWaterLevelCalculationsView> + DesignWaterLevelCalculationsView> { GetViewName = (view, context) => $"{Resources.GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContext_DisplayName} " + $"- {RingtoetsPluginHelper.FormatCategoryBoundaryName(context.CategoryBoundaryName)}", GetViewData = context => context.WrappedData, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, - CreateInstance = context => new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(context.WrappedData, - context.FailureMechanism, - context.AssessmentSection, - context.GetNormFunc, - context.CategoryBoundaryName), + CreateInstance = context => new DesignWaterLevelCalculationsView(context.WrappedData, + context.AssessmentSection, + context.GetNormFunc, + context.CategoryBoundaryName), AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; }, CloseForData = (view, data) => CloseHydraulicBoundaryCalculationsViewForData(view.AssessmentSection, data) }; yield return new ViewInfo< GrassCoverErosionOutwardsWaveHeightCalculationsContext, IObservableEnumerable, - GrassCoverErosionOutwardsWaveHeightCalculationsView> + WaveHeightCalculationsView> { GetViewName = (view, context) => $"{Resources.GrassCoverErosionOutwardsWaveHeightCalculationsGroupContext_DisplayName} " + $"- {RingtoetsPluginHelper.FormatCategoryBoundaryName(context.CategoryBoundaryName)}", GetViewData = context => context.WrappedData, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, - CreateInstance = context => new GrassCoverErosionOutwardsWaveHeightCalculationsView(context.WrappedData, - context.FailureMechanism, - context.AssessmentSection, - context.GetNormFunc, - context.CategoryBoundaryName), + CreateInstance = context => new WaveHeightCalculationsView(context.WrappedData, + context.AssessmentSection, + context.GetNormFunc, + context.CategoryBoundaryName), AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; }, CloseForData = (view, data) => CloseHydraulicBoundaryCalculationsViewForData(view.AssessmentSection, data) }; Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj =================================================================== diff -u -rf937806272bc4ed4d04ab0de94937057649b9fe6 -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision f937806272bc4ed4d04ab0de94937057649b9fe6) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -44,11 +44,9 @@ - - Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightCalculationsViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -r0fc08c66887f3e02384f9de25436d937461cdc0c -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 0fc08c66887f3e02384f9de25436d937461cdc0c) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionOutwards.Forms.PropertyClasses; @@ -80,13 +81,13 @@ viewInfos, typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsContext), typeof(IObservableEnumerable), - typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsView)); + typeof(DesignWaterLevelCalculationsView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(GrassCoverErosionOutwardsWaveHeightCalculationsContext), typeof(IObservableEnumerable), - typeof(GrassCoverErosionOutwardsWaveHeightCalculationsView)); + typeof(WaveHeightCalculationsView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs =================================================================== diff -u -recb0e5b29e11012efd3944171530d9310e07804a -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs) (revision ecb0e5b29e11012efd3944171530d9310e07804a) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -32,9 +32,9 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; -using Ringtoets.GrassCoverErosionOutwards.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.ViewInfos @@ -52,10 +52,10 @@ ViewInfo info = GetInfo(plugin); // Assert - Assert.NotNull(info, "Expected a viewInfo definition for views with type {0}.", typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsView)); + Assert.NotNull(info, "Expected a viewInfo definition for views with type {0}.", typeof(DesignWaterLevelCalculationsView)); Assert.AreEqual(typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsContext), info.DataType); Assert.AreEqual(typeof(IObservableEnumerable), info.ViewDataType); - Assert.AreEqual(typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsView), info.ViewType); + Assert.AreEqual(typeof(DesignWaterLevelCalculationsView), info.ViewType); } } @@ -114,11 +114,10 @@ plugin.Activate(); // Call - var view = (GrassCoverErosionOutwardsDesignWaterLevelCalculationsView) info.CreateInstance(context); + var view = (DesignWaterLevelCalculationsView) info.CreateInstance(context); // Assert Assert.AreSame(assessmentSection, view.AssessmentSection); - Assert.AreSame(grassCoverErosionOutwardsFailureMechanism, view.FailureMechanism); } mockRepository.VerifyAll(); @@ -195,11 +194,10 @@ plugin.Gui = gui; plugin.Activate(); - using (var view = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(new ObservableList(), - grassCoverErosionOutwardsFailureMechanism, - assessmentSection, - () => 0.01, - "A")) + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) { // Call info.AfterCreate(view, data); @@ -228,11 +226,10 @@ assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); - using (var view = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(new ObservableList(), - failureMechanism, - assessmentSection, - () => 0.01, - "A")) + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -268,11 +265,10 @@ }); mocks.ReplayAll(); - using (var view = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(new ObservableList(), - failureMechanism, - assessmentSectionA, - () => 0.01, - "A")) + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSectionA, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -305,11 +301,10 @@ new GrassCoverErosionOutwardsFailureMechanism(), assessmentSection); - using (var view = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(new ObservableList(), - new GrassCoverErosionOutwardsFailureMechanism(), - assessmentSection, - () => 0.01, - "A")) + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -347,11 +342,10 @@ new GrassCoverErosionOutwardsFailureMechanism(), assessmentSectionB); - using (var view = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(new ObservableList(), - new GrassCoverErosionOutwardsFailureMechanism(), - assessmentSectionA, - () => 0.01, - "A")) + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSectionA, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -380,11 +374,10 @@ assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); - using (var view = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsView(new ObservableList(), - new GrassCoverErosionOutwardsFailureMechanism(), - assessmentSection, - () => 0.01, - "A")) + using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -401,7 +394,7 @@ private static ViewInfo GetInfo(PluginBase plugin) { - return plugin.GetViewInfos().FirstOrDefault(vi => vi.ViewType == typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsView)); + return plugin.GetViewInfos().FirstOrDefault(vi => vi.ViewType == typeof(DesignWaterLevelCalculationsView)); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs =================================================================== diff -u -recb0e5b29e11012efd3944171530d9310e07804a -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs) (revision ecb0e5b29e11012efd3944171530d9310e07804a) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -32,9 +32,9 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; -using Ringtoets.GrassCoverErosionOutwards.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.ViewInfos @@ -52,10 +52,10 @@ ViewInfo info = GetInfo(plugin); // Assert - Assert.NotNull(info, "Expected a viewInfo definition for views with type {0}.", typeof(GrassCoverErosionOutwardsWaveHeightCalculationsView)); + Assert.NotNull(info, "Expected a viewInfo definition for views with type {0}.", typeof(WaveHeightCalculationsView)); Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveHeightCalculationsContext), info.DataType); Assert.AreEqual(typeof(IObservableEnumerable), info.ViewDataType); - Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveHeightCalculationsView), info.ViewType); + Assert.AreEqual(typeof(WaveHeightCalculationsView), info.ViewType); } } @@ -110,11 +110,10 @@ plugin.Activate(); // Call - var view = (GrassCoverErosionOutwardsWaveHeightCalculationsView) info.CreateInstance(context); + var view = (WaveHeightCalculationsView) info.CreateInstance(context); // Assert Assert.AreSame(assessmentSection, view.AssessmentSection); - Assert.AreSame(grassCoverErosionOutwardsFailureMechanism, view.FailureMechanism); } mockRepository.VerifyAll(); @@ -184,11 +183,10 @@ plugin.Gui = gui; plugin.Activate(); - using (var view = new GrassCoverErosionOutwardsWaveHeightCalculationsView(new ObservableList(), - failureMechanism, - assessmentSection, - () => 0.01, - "A")) + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) { info.AfterCreate(view, data); @@ -216,11 +214,10 @@ assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); - using (var view = new GrassCoverErosionOutwardsWaveHeightCalculationsView(new ObservableList(), - failureMechanism, - assessmentSection, - () => 0.01, - "A")) + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -256,11 +253,10 @@ }); mocks.ReplayAll(); - using (var view = new GrassCoverErosionOutwardsWaveHeightCalculationsView(new ObservableList(), - failureMechanism, - assessmentSectionA, - () => 0.01, - "A")) + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSectionA, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -293,11 +289,10 @@ new GrassCoverErosionOutwardsFailureMechanism(), assessmentSection); - using (var view = new GrassCoverErosionOutwardsWaveHeightCalculationsView(new ObservableList(), - new GrassCoverErosionOutwardsFailureMechanism(), - assessmentSection, - () => 0.01, - "A")) + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -335,11 +330,10 @@ new GrassCoverErosionOutwardsFailureMechanism(), assessmentSectionB); - using (var view = new GrassCoverErosionOutwardsWaveHeightCalculationsView(new ObservableList(), - new GrassCoverErosionOutwardsFailureMechanism(), - assessmentSectionA, - () => 0.01, - "A")) + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSectionA, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -368,11 +362,10 @@ assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); - using (var view = new GrassCoverErosionOutwardsWaveHeightCalculationsView(new ObservableList(), - new GrassCoverErosionOutwardsFailureMechanism(), - assessmentSection, - () => 0.01, - "A")) + using (var view = new WaveHeightCalculationsView(new ObservableList(), + assessmentSection, + () => 0.01, + "A")) using (var plugin = new GrassCoverErosionOutwardsPlugin()) { ViewInfo info = GetInfo(plugin); @@ -389,7 +382,7 @@ private static ViewInfo GetInfo(PluginBase plugin) { - return plugin.GetViewInfos().FirstOrDefault(vi => vi.ViewType == typeof(GrassCoverErosionOutwardsWaveHeightCalculationsView)); + return plugin.GetViewInfos().FirstOrDefault(vi => vi.ViewType == typeof(WaveHeightCalculationsView)); } } } \ No newline at end of file Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/DesignWaterLevelCalculationContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightCalculationContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -rf937806272bc4ed4d04ab0de94937057649b9fe6 -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision f937806272bc4ed4d04ab0de94937057649b9fe6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -36,11 +36,9 @@ - - @@ -104,12 +102,6 @@ FailureMechanismContributionView.cs - - UserControl - - - DesignWaterLevelCalculationsView.cs - @@ -153,12 +145,6 @@ UserControl - - UserControl - - - WaveHeightCalculationsView.cs - @@ -321,18 +307,10 @@ FailureMechanismContributionView.cs Designer - - DesignWaterLevelCalculationsView.cs - Designer - AssessmentSectionAssemblyCategoriesView.cs Designer - - WaveHeightCalculationsView.cs - Designer - Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelCalculationsView.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelCalculationsView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelCalculationsView.resx'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.resx'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelCalculationContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightCalculationContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r04ffe9435f3031323b2eeac4718e85dfd6022dbe -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 04ffe9435f3031323b2eeac4718e85dfd6022dbe) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -41,7 +41,6 @@ - @@ -54,7 +53,6 @@ - @@ -76,7 +74,6 @@ - @@ -96,7 +93,6 @@ - Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightCalculationsViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelCalculationContextPropertyInfoTest.cs =================================================================== diff -u -r1eb7e7ef92a8a08a227ce81e75a2ac95df4b3b57 -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelCalculationContextPropertyInfoTest.cs (.../DesignWaterLevelCalculationContextPropertyInfoTest.cs) (revision 1eb7e7ef92a8a08a227ce81e75a2ac95df4b3b57) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelCalculationContextPropertyInfoTest.cs (.../DesignWaterLevelCalculationContextPropertyInfoTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -25,8 +25,8 @@ using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; -using Ringtoets.Integration.Forms.PresentationObjects; namespace Ringtoets.Integration.Plugin.Test.PropertyInfos { Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightCalculationContextPropertyInfoTest.cs =================================================================== diff -u -r6cd7ed9865da9f211a6e1e3cd4a0ac86b321eef0 -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightCalculationContextPropertyInfoTest.cs (.../WaveHeightCalculationContextPropertyInfoTest.cs) (revision 6cd7ed9865da9f211a6e1e3cd4a0ac86b321eef0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightCalculationContextPropertyInfoTest.cs (.../WaveHeightCalculationContextPropertyInfoTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -25,8 +25,8 @@ using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; -using Ringtoets.Integration.Forms.PresentationObjects; namespace Ringtoets.Integration.Plugin.Test.PropertyInfos { Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelCalculationsViewInfoTest.cs =================================================================== diff -u -recb0e5b29e11012efd3944171530d9310e07804a -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelCalculationsViewInfoTest.cs (.../DesignWaterLevelCalculationsViewInfoTest.cs) (revision ecb0e5b29e11012efd3944171530d9310e07804a) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelCalculationsViewInfoTest.cs (.../DesignWaterLevelCalculationsViewInfoTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -40,7 +40,7 @@ using Ringtoets.Common.Forms.GuiServices; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TestUtil; -using Ringtoets.Integration.Forms.Views; +using Ringtoets.Common.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Plugin.Test.ViewInfos Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightCalculationsViewInfoTest.cs =================================================================== diff -u -recb0e5b29e11012efd3944171530d9310e07804a -r5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightCalculationsViewInfoTest.cs (.../WaveHeightCalculationsViewInfoTest.cs) (revision ecb0e5b29e11012efd3944171530d9310e07804a) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightCalculationsViewInfoTest.cs (.../WaveHeightCalculationsViewInfoTest.cs) (revision 5d13bf8acfe93e7edaeae98d7ef0c0978a74aae2) @@ -40,7 +40,7 @@ using Ringtoets.Common.Forms.GuiServices; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TestUtil; -using Ringtoets.Integration.Forms.Views; +using Ringtoets.Common.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Plugin.Test.ViewInfos