Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -re8ddc7a63f03cb28eeb3974363d6edb4ba51c896 -r8f71111fae4dc2d04afae34491748404c0466ce8
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision e8ddc7a63f03cb28eeb3974363d6edb4ba51c896)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -77,11 +77,11 @@
FailureMechanismContributionView.cs
-
+
UserControl
-
- DesignWaterLevelLocationsView.cs
+
+ DesignWaterLevelCalculationsView.cs
@@ -116,11 +116,11 @@
UserControl
-
+
UserControl
-
- WaveHeightLocationsView.cs
+
+ WaveHeightCalculationsView.cs
@@ -240,12 +240,12 @@
FailureMechanismContributionView.cs
Designer
-
- DesignWaterLevelLocationsView.cs
+
+ DesignWaterLevelCalculationsView.cs
Designer
-
- WaveHeightLocationsView.cs
+
+ WaveHeightCalculationsView.cs
Designer
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.Designer.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.Designer.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.Designer.cs (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -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.Integration.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/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.cs (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -0,0 +1,99 @@
+// 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.Views;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Properties;
+using Ringtoets.Integration.Service.MessageProviders;
+
+namespace Ringtoets.Integration.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(ObservableList 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(((HydraulicBoundaryLocationRow) 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(HydraulicBoundaryLocationRow.Result),
+ Resources.HydraulicBoundaryDatabase_Location_WaveHeight_DisplayName);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.resx
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.resx (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightCalculationsView.resx (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -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
Fisheye: Tag 8f71111fae4dc2d04afae34491748404c0466ce8 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 8f71111fae4dc2d04afae34491748404c0466ce8 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 8f71111fae4dc2d04afae34491748404c0466ce8 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.resx'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -rc00b1c9a3f2e8eeb36d5f6493bfde8920d767729 -r8f71111fae4dc2d04afae34491748404c0466ce8
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision c00b1c9a3f2e8eeb36d5f6493bfde8920d767729)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -408,16 +408,16 @@
AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; }
};
- yield return new ViewInfo, WaveHeightLocationsView>
+ yield return new ViewInfo, WaveHeightCalculationsView>
{
GetViewName = (view, context) => $"{RingtoetsFormsResources.WaveHeightLocationsContext_DisplayName} - {context.CategoryBoundaryName}",
GetViewData = context => context.WrappedData,
Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
CloseForData = CloseHydraulicBoundaryLocationsViewForData,
- CreateInstance = context => new WaveHeightLocationsView(GetHydraulicBoundaryLocationCalculations(context.WrappedData, context.GetCalculationFunc),
- context.AssessmentSection,
- context.GetNormFunc,
- context.CategoryBoundaryName),
+ CreateInstance = context => new WaveHeightCalculationsView(GetHydraulicBoundaryLocationCalculations(context.WrappedData, context.GetCalculationFunc),
+ context.AssessmentSection,
+ context.GetNormFunc,
+ context.CategoryBoundaryName),
AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; }
};
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -re8ddc7a63f03cb28eeb3974363d6edb4ba51c896 -r8f71111fae4dc2d04afae34491748404c0466ce8
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision e8ddc7a63f03cb28eeb3974363d6edb4ba51c896)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -67,7 +67,7 @@
-
+
@@ -87,7 +87,7 @@
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelCalculationsViewTest.cs (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -0,0 +1,691 @@
+// 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.TestUtil;
+using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Service.MessageProviders;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Views;
+using Ringtoets.Integration.Service.MessageProviders;
+
+namespace Ringtoets.Integration.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,
+ "Category");
+
+ // 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,
+ "Category"))
+ {
+ // Assert
+ Assert.IsInstanceOf(view);
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void Constructor_DataGridViewCorrectlyInitialized()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository);
+ mockRepository.ReplayAll();
+
+ // Call
+ ShowDesignWaterLevelLocationsView(new ObservableList(),
+ assessmentSection,
+ 0.01,
+ "Category",
+ 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("Toetspeil [m+NAP]", designWaterLevelColumn.HeaderText);
+
+ var button = (Button) testForm.Controls.Find("CalculateForSelectedButton", true).First();
+ Assert.IsFalse(button.Enabled);
+ }
+
+ [Test]
+ public void Constructor_WithCalculations_DataGridViewCorrectlyInitialized()
+ {
+ // Call
+ ShowFullyConfiguredDesignWaterLevelLocationsView(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 DesignWaterLevelLocationsView_CalculationsUpdated_DataGridViewCorrectlyUpdated()
+ {
+ // Setup
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ ShowFullyConfiguredDesignWaterLevelLocationsView(hydraulicBoundaryLocationCalculations, testForm);
+
+ const double designWaterLevel = 10.23;
+ var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(10, "10", 10.0, 10.0))
+ {
+ InputParameters =
+ {
+ ShouldIllustrationPointsBeCalculated = true
+ },
+ Output = new TestHydraulicBoundaryLocationOutput(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 DesignWaterLevelLocationsView_CalculationUpdated_DataGridViewCorrectlyUpdated()
+ {
+ // Setup
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ ShowFullyConfiguredDesignWaterLevelLocationsView(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 DesignWaterLevelLocationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated()
+ {
+ // Setup
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ ShowFullyConfiguredDesignWaterLevelLocationsView(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 TestHydraulicBoundaryLocationOutput(generalResult);
+
+ // Call
+ HydraulicBoundaryLocationCalculation boundaryLocationCalculation = hydraulicBoundaryLocationCalculations[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
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ DesignWaterLevelCalculationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(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
+ ShowFullyConfiguredDesignWaterLevelLocationsView(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 = "Category";
+
+ 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();
+
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ DesignWaterLevelCalculationsView view = ShowDesignWaterLevelLocationsView(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($"Toetspeil berekenen voor locatie 'Location name' ({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 = "Category";
+
+ 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();
+
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ DesignWaterLevelCalculationsView view = ShowDesignWaterLevelLocationsView(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($"Toetspeil berekenen voor locatie 'Location name' ({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 = "Category";
+
+ 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();
+
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ DesignWaterLevelCalculationsView view = ShowDesignWaterLevelLocationsView(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($"Toetspeil berekenen voor locatie 'Location name' ({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 ShowDesignWaterLevelLocationsView(ObservableList 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 ShowFullyConfiguredDesignWaterLevelLocationsView(ObservableList calculations,
+ Form form)
+ {
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ return ShowDesignWaterLevelLocationsView(calculations, assessmentSection, 0.01, "Category", 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 TestHydraulicBoundaryLocationOutput(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 TestHydraulicBoundaryLocationOutput(1.01, generalResult)
+ }
+ };
+ }
+
+ [TestFixture]
+ private class ViewSynchronizationTest : LocationsViewSynchronizationTester
+ {
+ 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(((HydraulicBoundaryLocationRow) selectedRowObject).CalculatableObject);
+ }
+
+ protected override CalculationsView ShowFullyConfiguredCalculationsView(Form form)
+ {
+ return ShowFullyConfiguredDesignWaterLevelLocationsView(calculations, form);
+ }
+
+ protected override ObservableList GetCalculationsInView(CalculationsView view)
+ {
+ return calculations;
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 8f71111fae4dc2d04afae34491748404c0466ce8 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightCalculationsViewTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightCalculationsViewTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightCalculationsViewTest.cs (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -0,0 +1,691 @@
+// 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.TestUtil;
+using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Service.MessageProviders;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Views;
+using Ringtoets.Integration.Service.MessageProviders;
+
+namespace Ringtoets.Integration.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,
+ "Category");
+
+ // 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,
+ "Category"))
+ {
+ // Assert
+ Assert.IsInstanceOf(view);
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void Constructor_DataGridViewCorrectlyInitialized()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository);
+ mockRepository.ReplayAll();
+
+ // Call
+ ShowWaveHeightLocationsView(new ObservableList(),
+ assessmentSection,
+ 0.01,
+ "Category",
+ 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("Hs [m]", waveHeightColumn.HeaderText);
+
+ var button = (Button) testForm.Controls.Find("CalculateForSelectedButton", true).First();
+ Assert.IsFalse(button.Enabled);
+ }
+
+ [Test]
+ public void Constructor_WithCalculations_DataGridViewCorrectlyInitialized()
+ {
+ // Call
+ ShowFullyConfiguredWaveHeightLocationsView(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 WaveHeightLocationsView_CalculationsUpdated_DataGridViewCorrectlyUpdated()
+ {
+ // Setup
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ ShowFullyConfiguredWaveHeightLocationsView(hydraulicBoundaryLocationCalculations, testForm);
+
+ const double waveHeight = 10.23;
+ var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(10, "10", 10.0, 10.0))
+ {
+ InputParameters =
+ {
+ ShouldIllustrationPointsBeCalculated = true
+ },
+ Output = new TestHydraulicBoundaryLocationOutput(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 WaveHeightLocationsView_CalculationUpdated_DataGridViewCorrectlyUpdated()
+ {
+ // Setup
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ ShowFullyConfiguredWaveHeightLocationsView(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 WaveHeightLocationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated()
+ {
+ // Setup
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ ShowFullyConfiguredWaveHeightLocationsView(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 TestHydraulicBoundaryLocationOutput(generalResult);
+
+ // Call
+ HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculations[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
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ WaveHeightCalculationsView view = ShowFullyConfiguredWaveHeightLocationsView(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
+ ShowFullyConfiguredWaveHeightLocationsView(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 = "Category";
+
+ 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();
+
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ WaveHeightCalculationsView view = ShowWaveHeightLocationsView(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' ({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 = "Category";
+
+ 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();
+
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ WaveHeightCalculationsView view = ShowWaveHeightLocationsView(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' ({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 = "Category";
+
+ 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();
+
+ ObservableList hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();
+
+ WaveHeightCalculationsView view = ShowWaveHeightLocationsView(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' ({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 ShowWaveHeightLocationsView(ObservableList 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 ShowFullyConfiguredWaveHeightLocationsView(ObservableList calculations,
+ Form form)
+ {
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ return ShowWaveHeightLocationsView(calculations, assessmentSection, 0.01, "Category", 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 TestHydraulicBoundaryLocationOutput(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 TestHydraulicBoundaryLocationOutput(1.01, generalResult)
+ }
+ };
+ }
+
+ [TestFixture]
+ public class ViewSynchronizationTest : LocationsViewSynchronizationTester
+ {
+ 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(((HydraulicBoundaryLocationRow) selectedRowObject).CalculatableObject);
+ }
+
+ protected override CalculationsView ShowFullyConfiguredCalculationsView(Form form)
+ {
+ return ShowFullyConfiguredWaveHeightLocationsView(calculations, form);
+ }
+
+ protected override ObservableList GetCalculationsInView(CalculationsView view)
+ {
+ return calculations;
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 8f71111fae4dc2d04afae34491748404c0466ce8 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs
===================================================================
diff -u -rc00b1c9a3f2e8eeb36d5f6493bfde8920d767729 -r8f71111fae4dc2d04afae34491748404c0466ce8
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision c00b1c9a3f2e8eeb36d5f6493bfde8920d767729)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -381,7 +381,7 @@
viewInfos,
typeof(WaveHeightLocationsContext),
typeof(IEnumerable),
- typeof(WaveHeightLocationsView));
+ typeof(WaveHeightCalculationsView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs
===================================================================
diff -u -r31c4f7ce05aa2e32499eab25eb02494eb959441e -r8f71111fae4dc2d04afae34491748404c0466ce8
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 31c4f7ce05aa2e32499eab25eb02494eb959441e)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 8f71111fae4dc2d04afae34491748404c0466ce8)
@@ -148,7 +148,7 @@
"Category");
// Call
- var view = (WaveHeightLocationsView) info.CreateInstance(context);
+ var view = (WaveHeightCalculationsView) info.CreateInstance(context);
// Assert
Assert.AreSame(assessmentSection, view.AssessmentSection);
@@ -185,7 +185,7 @@
"Category");
// Call
- var view = (WaveHeightLocationsView) info.CreateInstance(context);
+ var view = (WaveHeightCalculationsView) info.CreateInstance(context);
// Assert
using (var testForm = new Form())
@@ -237,7 +237,7 @@
mockRepository.ReplayAll();
// Call
- var view = (WaveHeightLocationsView) info.CreateInstance(context);
+ var view = (WaveHeightCalculationsView) info.CreateInstance(context);
// Assert
using (var testForm = new Form())
@@ -291,10 +291,10 @@
getCalculationFunc,
categoryBoundaryName);
- using (var view = new WaveHeightLocationsView(new ObservableList(),
- assessmentSection,
- getNormFunc,
- categoryBoundaryName))
+ using (var view = new WaveHeightCalculationsView(new ObservableList(),
+ assessmentSection,
+ getNormFunc,
+ categoryBoundaryName))
using (var ringtoetsPlugin = new RingtoetsPlugin())
{
@@ -318,10 +318,10 @@
// Setup
var assessmentSection = new ObservableTestAssessmentSectionStub();
- using (var view = new WaveHeightLocationsView(new ObservableList(),
- assessmentSection,
- () => 0.01,
- "Category"))
+ using (var view = new WaveHeightCalculationsView(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ "Category"))
{
// Call
bool closeForData = info.CloseForData(view, assessmentSection);
@@ -338,10 +338,10 @@
var assessmentSectionA = new ObservableTestAssessmentSectionStub();
var assessmentSectionB = new ObservableTestAssessmentSectionStub();
- using (var view = new WaveHeightLocationsView(new ObservableList(),
- assessmentSectionA,
- () => 0.01,
- "Category"))
+ using (var view = new WaveHeightCalculationsView(new ObservableList(),
+ assessmentSectionA,
+ () => 0.01,
+ "Category"))
{
// Call
bool closeForData = info.CloseForData(view, assessmentSectionB);
@@ -357,10 +357,10 @@
// Setup
var assessmentSectionA = new ObservableTestAssessmentSectionStub();
- using (var view = new WaveHeightLocationsView(new ObservableList(),
- assessmentSectionA,
- () => 0.01,
- "Category"))
+ using (var view = new WaveHeightCalculationsView(new ObservableList(),
+ assessmentSectionA,
+ () => 0.01,
+ "Category"))
{
// Call
bool closeForData = info.CloseForData(view, new object());
@@ -372,7 +372,7 @@
private static ViewInfo GetViewInfo(RingtoetsPlugin plugin)
{
- return plugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView));
+ return plugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightCalculationsView));
}
}
}
\ No newline at end of file