Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -rd1c832128168938c7cb5ed4b1ac54382e0fc96fe -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d1c832128168938c7cb5ed4b1ac54382e0fc96fe)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -286,6 +286,15 @@
}
///
+ /// Looks up a localized string similar to Berekenen.
+ ///
+ public static string DesignWaterLevelLocationContextRow_Calculate {
+ get {
+ return ResourceManager.GetString("DesignWaterLevelLocationContextRow_Calculate", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Toetspeilen.
///
public static string DesignWaterLevelLocationsContext_DisplayName {
@@ -534,15 +543,6 @@
}
///
- /// Looks up a localized string similar to Berekenen.
- ///
- public static string HydraulicBoundaryLocationDesignWaterLevelRow_Calculate {
- get {
- return ResourceManager.GetString("HydraulicBoundaryLocationDesignWaterLevelRow_Calculate", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap Map {
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -rd1c832128168938c7cb5ed4b1ac54382e0fc96fe -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision d1c832128168938c7cb5ed4b1ac54382e0fc96fe)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -318,7 +318,7 @@
Convergentie status van de golfhoogte berekening.
-
+
Berekenen
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -rbba9524cfdab4e69348fddab60efe718e7c1865b -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision bba9524cfdab4e69348fddab60efe718e7c1865b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -96,12 +96,12 @@
FailureMechanismContributionView.cs
-
-
+
+
UserControl
-
- HydraulicBoundaryLocationDesignWaterLevelsView.cs
+
+ DesignWaterLevelLocationsView.cs
@@ -261,8 +261,8 @@
FailureMechanismContributionView.cs
Designer
-
- HydraulicBoundaryLocationDesignWaterLevelsView.cs
+
+ DesignWaterLevelLocationsView.cs
Designer
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationContextRow.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationContextRow.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationContextRow.cs (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,114 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.ComponentModel;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Ringtoets.Common.Forms.TypeConverters;
+using Ringtoets.Integration.Forms.PresentationObjects;
+
+namespace Ringtoets.Integration.Forms.Views
+{
+ ///
+ /// This class represents a row of .
+ ///
+ internal class DesignWaterLevelLocationContextRow
+ {
+ private readonly DesignWaterLevelLocationContext designWaterLevelLocationContext;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The for this row.
+ /// Thrown when is null.
+ internal DesignWaterLevelLocationContextRow(DesignWaterLevelLocationContext designWaterLevelLocationContext)
+ {
+ if (designWaterLevelLocationContext == null)
+ {
+ throw new ArgumentNullException("designWaterLevelLocationContext");
+ }
+
+ this.designWaterLevelLocationContext = designWaterLevelLocationContext;
+ }
+
+ ///
+ /// Gets whether the is set to be calculated.
+ ///
+ public bool ToCalculate { get; set; }
+
+ ///
+ /// Gets the .
+ ///
+ public string Name
+ {
+ get
+ {
+ return designWaterLevelLocationContext.HydraulicBoundaryLocation.Name;
+ }
+ }
+
+ ///
+ /// Gets the .
+ ///
+ public long Id
+ {
+ get
+ {
+ return designWaterLevelLocationContext.HydraulicBoundaryLocation.Id;
+ }
+ }
+
+ ///
+ /// Gets the .
+ ///
+ public Point2D Location
+ {
+ get
+ {
+ return designWaterLevelLocationContext.HydraulicBoundaryLocation.Location;
+ }
+ }
+
+ ///
+ /// Gets the .
+ ///
+ [TypeConverter(typeof(FailureMechanismSectionResultNoValueRoundedDoubleConverter))]
+ public RoundedDouble DesignWaterLevel
+ {
+ get
+ {
+ return new RoundedDouble(2, designWaterLevelLocationContext.HydraulicBoundaryLocation.DesignWaterLevel);
+ }
+ }
+
+ ///
+ /// Gets the .
+ ///
+ public DesignWaterLevelLocationContext DesignWaterLevelLocationContext
+ {
+ get
+ {
+ return designWaterLevelLocationContext;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,142 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+namespace Ringtoets.Integration.Forms.Views
+{
+ partial class DesignWaterLevelLocationsView
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ #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()
+ {
+ this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl();
+ this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
+ this.ButtonGroupBox = new System.Windows.Forms.GroupBox();
+ this.CalculateForSelectedButton = new System.Windows.Forms.Button();
+ this.DeselectAllButton = new System.Windows.Forms.Button();
+ this.SelectAllButton = new System.Windows.Forms.Button();
+ this.tableLayoutPanel.SuspendLayout();
+ this.ButtonGroupBox.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // dataGridViewControl
+ //
+ this.dataGridViewControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewControl.Location = new System.Drawing.Point(3, 3);
+ this.dataGridViewControl.MultiSelect = true;
+ this.dataGridViewControl.Name = "dataGridViewControl";
+ this.dataGridViewControl.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect;
+ this.dataGridViewControl.Size = new System.Drawing.Size(529, 264);
+ this.dataGridViewControl.TabIndex = 0;
+ //
+ // tableLayoutPanel
+ //
+ this.tableLayoutPanel.ColumnCount = 1;
+ this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel.Controls.Add(this.dataGridViewControl, 0, 0);
+ this.tableLayoutPanel.Controls.Add(this.ButtonGroupBox, 0, 1);
+ this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
+ this.tableLayoutPanel.Name = "tableLayoutPanel";
+ this.tableLayoutPanel.RowCount = 2;
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel.Size = new System.Drawing.Size(535, 329);
+ this.tableLayoutPanel.TabIndex = 1;
+ //
+ // ButtonGroupBox
+ //
+ this.ButtonGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.ButtonGroupBox.Controls.Add(this.CalculateForSelectedButton);
+ this.ButtonGroupBox.Controls.Add(this.DeselectAllButton);
+ this.ButtonGroupBox.Controls.Add(this.SelectAllButton);
+ this.ButtonGroupBox.Location = new System.Drawing.Point(3, 275);
+ this.ButtonGroupBox.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
+ this.ButtonGroupBox.Name = "ButtonGroupBox";
+ this.ButtonGroupBox.Size = new System.Drawing.Size(529, 51);
+ this.ButtonGroupBox.TabIndex = 1;
+ this.ButtonGroupBox.TabStop = false;
+ this.ButtonGroupBox.Text = "Toetspeilen berekenen";
+ //
+ // CalculateForSelectedButton
+ //
+ this.CalculateForSelectedButton.Location = new System.Drawing.Point(227, 19);
+ this.CalculateForSelectedButton.Name = "CalculateForSelectedButton";
+ this.CalculateForSelectedButton.Size = new System.Drawing.Size(207, 23);
+ this.CalculateForSelectedButton.TabIndex = 2;
+ this.CalculateForSelectedButton.Text = "Bereken voor geselecteerde locaties";
+ this.CalculateForSelectedButton.UseVisualStyleBackColor = true;
+ this.CalculateForSelectedButton.Click += new System.EventHandler(this.CalculateForSelectedButton_Click);
+ //
+ // DeselectAllButton
+ //
+ this.DeselectAllButton.Location = new System.Drawing.Point(110, 19);
+ this.DeselectAllButton.Name = "DeselectAllButton";
+ this.DeselectAllButton.Size = new System.Drawing.Size(111, 23);
+ this.DeselectAllButton.TabIndex = 1;
+ this.DeselectAllButton.Text = "Deselecteer alles";
+ this.DeselectAllButton.UseVisualStyleBackColor = true;
+ this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click);
+ //
+ // SelectAllButton
+ //
+ this.SelectAllButton.Location = new System.Drawing.Point(6, 19);
+ this.SelectAllButton.Name = "SelectAllButton";
+ this.SelectAllButton.Size = new System.Drawing.Size(98, 23);
+ this.SelectAllButton.TabIndex = 0;
+ this.SelectAllButton.Text = "Selecteer alles";
+ this.SelectAllButton.UseVisualStyleBackColor = true;
+ this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click);
+ //
+ // DesignWaterLevelLocationsView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.tableLayoutPanel);
+ this.Name = "DesignWaterLevelLocationsView";
+ this.Size = new System.Drawing.Size(535, 329);
+ this.tableLayoutPanel.ResumeLayout(false);
+ this.ButtonGroupBox.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Core.Common.Controls.DataGrid.DataGridViewControl dataGridViewControl;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
+ private System.Windows.Forms.GroupBox ButtonGroupBox;
+ private System.Windows.Forms.Button CalculateForSelectedButton;
+ private System.Windows.Forms.Button DeselectAllButton;
+ private System.Windows.Forms.Button SelectAllButton;
+ }
+}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,222 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Controls.Views;
+using Core.Common.Gui.Selection;
+using Core.Common.Utils.Extensions;
+using Core.Common.Utils.Reflection;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Forms.Commands;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Properties;
+
+namespace Ringtoets.Integration.Forms.Views
+{
+ ///
+ /// View for the with .
+ ///
+ public partial class DesignWaterLevelLocationsView : UserControl, ISelectionProvider
+ {
+ private readonly Observer assessmentSectionObserver;
+ private readonly Observer hydraulicBoundaryDatabaseObserver;
+ private IAssessmentSection assessmentSection;
+ private bool updatingDataSource;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ public DesignWaterLevelLocationsView()
+ {
+ InitializeComponent();
+ InitializeDataGridView();
+
+ assessmentSectionObserver = new Observer(UpdateDataGridViewDataSource);
+ hydraulicBoundaryDatabaseObserver = new Observer(RefreshDataGridView);
+ }
+
+ ///
+ /// Gets or sets the .
+ ///
+ public IApplicationSelection ApplicationSelection { get; set; }
+
+ ///
+ /// Gets or sets the .
+ ///
+ public ICalculateDesignWaterLevelCommandHandler CalculationCommandHandler { private get; set; }
+
+ public object Data
+ {
+ get
+ {
+ return assessmentSection;
+ }
+ set
+ {
+ assessmentSection = value as IAssessmentSection;
+
+ UpdateDataGridViewDataSource();
+ assessmentSectionObserver.Observable = assessmentSection;
+ SetHydraulicBoundaryDatabaseObserver();
+ }
+ }
+
+ private void SetHydraulicBoundaryDatabaseObserver()
+ {
+ hydraulicBoundaryDatabaseObserver.Observable = assessmentSection != null ? assessmentSection.HydraulicBoundaryDatabase : null;
+ }
+
+ public object Selection
+ {
+ get
+ {
+ return CreateSelectedItemFromCurrentRow();
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ assessmentSectionObserver.Dispose();
+ hydraulicBoundaryDatabaseObserver.Dispose();
+
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ private void RefreshDataGridView()
+ {
+ dataGridViewControl.RefreshDataGridView();
+ }
+
+ private void InitializeDataGridView()
+ {
+ dataGridViewControl.AddCellClickHandler(DataGridViewOnCellClick);
+
+ dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate),
+ Resources.DesignWaterLevelLocationContextRow_Calculate);
+ dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name),
+ Resources.HydraulicBoundaryDatabase_Locations_Name_DisplayName);
+ dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id),
+ Resources.HydraulicBoundaryDatabase_Locations_Id_DisplayName);
+ dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Location),
+ Resources.HydraulicBoundaryDatabase_Locations_Coordinates_DisplayName);
+ dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.DesignWaterLevel),
+ Resources.HydraulicBoundaryDatabase_Locations_DesignWaterLevel_DisplayName);
+ }
+
+ private void UpdateDataGridViewDataSource()
+ {
+ SetHydraulicBoundaryDatabaseObserver();
+
+ updatingDataSource = true;
+ dataGridViewControl.SetDataSource(assessmentSection != null && assessmentSection.HydraulicBoundaryDatabase != null
+ ? assessmentSection.HydraulicBoundaryDatabase.Locations.Select(
+ hl => new DesignWaterLevelLocationContextRow(
+ new DesignWaterLevelLocationContext(assessmentSection.HydraulicBoundaryDatabase, hl))).ToArray()
+ : null);
+ RefreshDataGridView();
+ updatingDataSource = false;
+ }
+
+ private IEnumerable GetDesignWaterLevelLocationContextRows()
+ {
+ return from DataGridViewRow row in dataGridViewControl.Rows select (DesignWaterLevelLocationContextRow) row.DataBoundItem;
+ }
+
+ private IEnumerable GetSelectedDesignWaterLevelLocationContext()
+ {
+ return GetDesignWaterLevelLocationContextRows().Where(r => r.ToCalculate).Select(r => r.DesignWaterLevelLocationContext.HydraulicBoundaryLocation);
+ }
+
+ #region Event handling
+
+ private void DataGridViewOnCellClick(object sender, DataGridViewCellEventArgs e)
+ {
+ if (updatingDataSource)
+ {
+ return;
+ }
+
+ UpdateApplicationSelection();
+ }
+
+ private void UpdateApplicationSelection()
+ {
+ if (ApplicationSelection == null)
+ {
+ return;
+ }
+
+ HydraulicBoundaryLocationContext selection = CreateSelectedItemFromCurrentRow();
+ if ((ApplicationSelection.Selection == null && selection != null) ||
+ (ApplicationSelection.Selection != null && !ReferenceEquals(selection, ApplicationSelection.Selection)))
+ {
+ ApplicationSelection.Selection = selection;
+ }
+ }
+
+ private HydraulicBoundaryLocationContext CreateSelectedItemFromCurrentRow()
+ {
+ var currentRow = dataGridViewControl.CurrentRow;
+
+ var designWaterLevelRow = currentRow != null
+ ? (DesignWaterLevelLocationContextRow) currentRow.DataBoundItem
+ : null;
+
+ return designWaterLevelRow != null
+ ? designWaterLevelRow.DesignWaterLevelLocationContext
+ : null;
+ }
+
+ private void SelectAllButton_Click(object sender, EventArgs e)
+ {
+ GetDesignWaterLevelLocationContextRows().ForEachElementDo(row => row.ToCalculate = true);
+ dataGridViewControl.RefreshDataGridView();
+ }
+
+ private void DeselectAllButton_Click(object sender, EventArgs e)
+ {
+ GetDesignWaterLevelLocationContextRows().ForEachElementDo(row => row.ToCalculate = false);
+ dataGridViewControl.RefreshDataGridView();
+ }
+
+ private void CalculateForSelectedButton_Click(object sender, EventArgs e)
+ {
+ if (CalculationCommandHandler == null)
+ {
+ return;
+ }
+ var locations = GetSelectedDesignWaterLevelLocationContext();
+ CalculationCommandHandler.CalculateDesignWaterLevels(locations);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.resx
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.resx (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.resx (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelRow.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelsView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelsView.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelsView.resx'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -rbba9524cfdab4e69348fddab60efe718e7c1865b -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision bba9524cfdab4e69348fddab60efe718e7c1865b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -286,7 +286,7 @@
}
};
- yield return new ViewInfo
+ yield return new ViewInfo
{
GetViewName = (v, o) => RingtoetsFormsResources.DesignWaterLevelLocationsContext_DisplayName,
GetViewData = context => context.WrappedData,
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -rbba9524cfdab4e69348fddab60efe718e7c1865b -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision bba9524cfdab4e69348fddab60efe718e7c1865b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -120,8 +120,8 @@
-
-
+
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationContextRowTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationContextRowTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationContextRowTest.cs (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,96 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Views;
+
+namespace Ringtoets.Integration.Forms.Test.Views
+{
+ [TestFixture]
+ public class DesignWaterLevelLocationContextRowTest
+ {
+ [Test]
+ public void Constructor_WithoutHydraulicBoundaryLocation_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new DesignWaterLevelLocationContextRow(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("designWaterLevelLocationContext", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithHydraulicBoundaryLocation_PropertiesFromHydraulicBoundaryLocation()
+ {
+ // Setup
+ const int id = 1;
+ const string locationname = "LocationName";
+ const double coordinateX = 1.0;
+ const double coordinateY = 2.0;
+ const double designWaterLevel = 3.0;
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, locationname, coordinateX, coordinateY)
+ {
+ DesignWaterLevel = designWaterLevel
+ };
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation);
+
+ var context = new DesignWaterLevelLocationContext(hydraulicBoundaryDatabase, hydraulicBoundaryLocation);
+
+ // Call
+ var row = new DesignWaterLevelLocationContextRow(context);
+
+ // Assert
+ Assert.AreEqual(id, row.Id);
+ Assert.AreEqual(locationname, row.Name);
+ var expectedDesignWaterLevel = new RoundedDouble(2, designWaterLevel);
+ Assert.AreEqual(expectedDesignWaterLevel, row.DesignWaterLevel);
+ var expectedPoint2D = new Point2D(coordinateX, coordinateY);
+ Assert.AreEqual(expectedPoint2D, row.Location);
+ Assert.AreEqual(context, row.DesignWaterLevelLocationContext);
+ Assert.IsFalse(row.ToCalculate);
+ }
+
+ [Test]
+ public void Constructor_Property_SetPropertyAsExpected()
+ {
+ // Setup
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "LocationName", 1.0, 2.0);
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation);
+
+ var context = new DesignWaterLevelLocationContext(hydraulicBoundaryDatabase, hydraulicBoundaryLocation);
+ var row = new DesignWaterLevelLocationContextRow(context);
+
+ // Call
+ row.ToCalculate = true;
+
+ // Assert
+ Assert.IsTrue(row.ToCalculate);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,494 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.Views;
+using Core.Common.Gui.Selection;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Forms.Commands;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Views;
+
+namespace Ringtoets.Integration.Forms.Test.Views
+{
+ [TestFixture]
+ public class DesignWaterLevelLocationsViewTest
+ {
+ private Form testForm;
+
+ [SetUp]
+ public void Setup()
+ {
+ testForm = new Form();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ testForm.Dispose();
+ }
+
+ [Test]
+ public void DefaultConstructor_DefaultValues()
+ {
+ // Call
+ using (var view = new DesignWaterLevelLocationsView())
+ {
+ // Assert
+ Assert.IsInstanceOf(view);
+ Assert.IsInstanceOf(view);
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void Constructor_DataGridViewCorrectlyInitialized()
+ {
+ // Setup & Call
+ ShowDesignWaterLevelLocationsView();
+
+ // Assert
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ Assert.AreEqual(5, dataGridView.ColumnCount);
+
+ var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationCalculateColumnIndex];
+ const string expectedLocationCalculateHeaderText = "Berekenen";
+ Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText);
+
+ var locationNameColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationNameColumnIndex];
+ const string expectedLocationNameHeaderText = "Naam";
+ Assert.AreEqual(expectedLocationNameHeaderText, locationNameColumn.HeaderText);
+
+ var locationIdColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationIdColumnIndex];
+ const string expectedLocationIdHeaderText = "ID";
+ Assert.AreEqual(expectedLocationIdHeaderText, locationIdColumn.HeaderText);
+
+ var locationColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationColumnIndex];
+ const string expectedLocationHeaderText = "Coördinaten [m]";
+ Assert.AreEqual(expectedLocationHeaderText, locationColumn.HeaderText);
+
+ var locationDesignWaterlevelColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationDesignWaterlevelColumnIndex];
+ const string expectedLocationDesignWaterHeaderText = "Toetspeil [m+NAP]";
+ Assert.AreEqual(expectedLocationDesignWaterHeaderText, locationDesignWaterlevelColumn.HeaderText);
+ }
+
+ [Test]
+ public void Data_IAssessmentSection_DataSet()
+ {
+ // Setup
+ using (var view = new DesignWaterLevelLocationsView())
+ {
+ var assessmentSection = new TestAssessmentSection();
+
+ // Call
+ view.Data = assessmentSection;
+
+ // Assert
+ Assert.AreSame(assessmentSection, view.Data);
+ }
+ }
+
+ [Test]
+ public void Data_OtherThanIAssessmentSection_DataNull()
+ {
+ // Setup
+ using (var view = new DesignWaterLevelLocationsView())
+ {
+ var data = new object();
+
+ // Call
+ view.Data = data;
+
+ // Assert
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void DesignWaterLevelLocationsView_AssessmentSectionWithData_DataGridViewCorrectlyInitialized()
+ {
+ // Setup & Call
+ ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ // Assert
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(3, rows.Count);
+
+ var cells = rows[0].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual(false, cells[locationCalculateColumnIndex].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[locationDesignWaterlevelColumnIndex].FormattedValue);
+
+ cells = rows[1].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual(false, cells[locationCalculateColumnIndex].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[locationDesignWaterlevelColumnIndex].FormattedValue);
+
+ cells = rows[2].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual(false, cells[locationCalculateColumnIndex].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[locationDesignWaterlevelColumnIndex].FormattedValue);
+ }
+
+ [Test]
+ public void DesignWaterLevelLocationsView_HydraulicBoundaryDatabaseUpdated_DataGridViewCorrectlyUpdated()
+ {
+ // Setup
+ DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+ IAssessmentSection assessmentSection = (IAssessmentSection) view.Data;
+ HydraulicBoundaryDatabase newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ newHydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(10, "10", 10.0, 10.0)
+ {
+ DesignWaterLevel = 10.23
+ });
+
+ // Precondition
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(3, rows.Count);
+
+ // Call
+ assessmentSection.HydraulicBoundaryDatabase = newHydraulicBoundaryDatabase;
+ assessmentSection.NotifyObservers();
+
+ // Assert
+ Assert.AreEqual(1, rows.Count);
+ var cells = rows[0].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual(false, cells[locationCalculateColumnIndex].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(10.23.ToString(CultureInfo.CurrentCulture), cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+ }
+
+ [Test]
+ public void DesignWaterLevelLocationsView_AssessmentSectionUpdated_DataGridViewCorrectlyUpdated()
+ {
+ // Setup
+ DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+ IAssessmentSection assessmentSection = (IAssessmentSection) view.Data;
+
+ // Precondition
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(3, rows.Count);
+ Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+ Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), rows[1].Cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+ Assert.AreEqual("-", rows[2].Cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+
+ // Call
+ assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.DesignWaterLevel = double.NaN);
+ assessmentSection.NotifyObservers();
+
+ // Assert
+ Assert.AreEqual(3, rows.Count);
+ Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+ Assert.AreEqual("-", rows[1].Cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+ Assert.AreEqual("-", rows[2].Cells[locationDesignWaterlevelColumnIndex].FormattedValue);
+ }
+
+ [Test]
+ public void DesignWaterLevelLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced()
+ {
+ // Setup
+ var view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+ IAssessmentSection assessmentSection = (IAssessmentSection) view.Data;
+ var secondHydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.Skip(1).First();
+
+ var mocks = new MockRepository();
+ var applicationSelectionMock = mocks.StrictMock();
+ applicationSelectionMock.Stub(asm => asm.Selection).Return(null);
+ applicationSelectionMock.Expect(asm => asm.Selection = new DesignWaterLevelLocationContext(
+ assessmentSection.HydraulicBoundaryDatabase,
+ secondHydraulicBoundaryLocation));
+ mocks.ReplayAll();
+
+ view.ApplicationSelection = applicationSelectionMock;
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+
+ // Call
+ dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex];
+ EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0));
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void DesignWaterLevelLocationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly()
+ {
+ // Setup
+ var view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex];
+
+ var mocks = new MockRepository();
+ var applicationSelectionMock = mocks.StrictMock();
+ applicationSelectionMock.Stub(asm => asm.Selection).Return(view.Selection);
+ mocks.ReplayAll();
+
+ view.ApplicationSelection = applicationSelectionMock;
+
+ // Call
+ dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationNameColumnIndex];
+ EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(locationNameColumnIndex, 0));
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(0)]
+ [TestCase(1)]
+ [TestCase(2)]
+ public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow)
+ {
+ // Setup
+ var view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ dataGridView.CurrentCell = dataGridView.Rows[selectedRow].Cells[locationNameColumnIndex];
+
+ // Call
+ var selection = view.Selection;
+
+ // Assert
+ Assert.IsInstanceOf(selection);
+ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase;
+ Assert.AreSame(hydraulicBoundaryDatabase, ((DesignWaterLevelLocationContext) selection).WrappedData);
+ }
+
+ [Test]
+ public void SelectAllButton_SelectAllButtonClicked_AllLocationsSelected()
+ {
+ // Setup
+ ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ var button = new ButtonTester("SelectAllButton", testForm);
+
+ // Precondition
+ Assert.IsFalse((bool) rows[0].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsFalse((bool) rows[1].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsFalse((bool) rows[2].Cells[locationCalculateColumnIndex].Value);
+
+ // Call
+ button.Click();
+
+ // Assert
+ Assert.IsTrue((bool) rows[0].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsTrue((bool) rows[1].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsTrue((bool) rows[2].Cells[locationCalculateColumnIndex].Value);
+ }
+
+ [Test]
+ public void DeselectAllButton_AllLocationsSelectedDeselectAllButtonClicked_AllLocationsNotSelected()
+ {
+ // Setup
+ ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ var button = new ButtonTester("DeselectAllButton", testForm);
+
+ foreach (DataGridViewRow row in rows)
+ {
+ row.Cells[locationCalculateColumnIndex].Value = true;
+ }
+
+ // Precondition
+ Assert.IsTrue((bool) rows[0].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsTrue((bool) rows[1].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsTrue((bool) rows[2].Cells[locationCalculateColumnIndex].Value);
+
+ // Call
+ button.Click();
+
+ // Assert
+ Assert.IsFalse((bool) rows[0].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsFalse((bool) rows[1].Cells[locationCalculateColumnIndex].Value);
+ Assert.IsFalse((bool) rows[2].Cells[locationCalculateColumnIndex].Value);
+ }
+
+ [Test]
+ public void CalculateForSelectedButton_NoneSelected_CallsCalculateDesignWaterLevels()
+ {
+ // Setup
+ DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ var mockRepository = new MockRepository();
+ var commandHandlerMock = mockRepository.StrictMock();
+
+ IEnumerable locations = null;
+ commandHandlerMock.Expect(ch => ch.CalculateDesignWaterLevels(null)).IgnoreArguments().WhenCalled(
+ invocation => { locations = (IEnumerable) invocation.Arguments[0]; });
+ mockRepository.ReplayAll();
+
+ view.CalculationCommandHandler = commandHandlerMock;
+ var button = new ButtonTester("CalculateForSelectedButton", testForm);
+
+ // Call
+ button.Click();
+
+ // Assert
+ Assert.AreEqual(0, locations.Count());
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CalculateForSelectedButton_OneSelected_CallsCalculateDesignWaterLevels()
+ {
+ // Setup
+ DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ rows[0].Cells[locationCalculateColumnIndex].Value = true;
+
+ var mockRepository = new MockRepository();
+ var commandHandlerMock = mockRepository.StrictMock();
+
+ IEnumerable locations = null;
+ commandHandlerMock.Expect(ch => ch.CalculateDesignWaterLevels(null)).IgnoreArguments().WhenCalled(
+ invocation => { locations = (IEnumerable) invocation.Arguments[0]; });
+ mockRepository.ReplayAll();
+
+ view.CalculationCommandHandler = commandHandlerMock;
+ var button = new ButtonTester("CalculateForSelectedButton", testForm);
+
+ // Call
+ button.Click();
+
+ // Assert
+ var hydraulicBoundaryLocations = locations.ToArray();
+ Assert.AreEqual(1, hydraulicBoundaryLocations.Length);
+ HydraulicBoundaryLocation expectedLocation = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase.Locations.First();
+ Assert.AreEqual(expectedLocation, hydraulicBoundaryLocations.First());
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CalculateForSelectedButton_CalculationCommandHandlerNotSet_DoesNotThrowException()
+ {
+ // Setup
+ ShowFullyConfiguredDesignWaterLevelLocationsView();
+ var button = new ButtonTester("CalculateForSelectedButton", testForm);
+
+ // Call
+ TestDelegate test = () => button.Click();
+
+ // Assert
+ Assert.DoesNotThrow(test);
+ }
+
+ private const int locationCalculateColumnIndex = 0;
+ private const int locationNameColumnIndex = 1;
+ private const int locationIdColumnIndex = 2;
+ private const int locationColumnIndex = 3;
+ private const int locationDesignWaterlevelColumnIndex = 4;
+
+ private DesignWaterLevelLocationsView ShowDesignWaterLevelLocationsView()
+ {
+ var view = new DesignWaterLevelLocationsView();
+
+ testForm.Controls.Add(view);
+ testForm.Show();
+
+ return view;
+ }
+
+ private DesignWaterLevelLocationsView ShowFullyConfiguredDesignWaterLevelLocationsView()
+ {
+ var view = ShowDesignWaterLevelLocationsView();
+
+ var assessmentSection = new TestAssessmentSection()
+ {
+ HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase()
+ };
+
+ view.Data = assessmentSection;
+ return view;
+ }
+
+ private class TestHydraulicBoundaryDatabase : HydraulicBoundaryDatabase
+ {
+ public TestHydraulicBoundaryDatabase()
+ {
+ Locations.Add(new HydraulicBoundaryLocation(1, "1", 1.0, 1.0));
+ Locations.Add(new HydraulicBoundaryLocation(2, "2", 2.0, 2.0)
+ {
+ DesignWaterLevel = 1.23
+ });
+ Locations.Add(new HydraulicBoundaryLocation(3, "3", 3.0, 3.0)
+ {
+ WaveHeight = 2.45
+ });
+ }
+ }
+
+ private class TestAssessmentSection : Observable, IAssessmentSection
+ {
+ public string Comments { get; set; }
+ public long StorageId { get; set; }
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public AssessmentSectionComposition Composition { get; private set; }
+ public ReferenceLine ReferenceLine { get; set; }
+ public FailureMechanismContribution FailureMechanismContribution { get; private set; }
+ public HydraulicBoundaryDatabase HydraulicBoundaryDatabase { get; set; }
+
+ public IEnumerable GetFailureMechanisms()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ChangeComposition(AssessmentSectionComposition newComposition)
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationDesignWaterLevelRowTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationDesignWaterLevelsViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -r6f741425dc85f3d9d868d76002a92aa9bd3cb6cb -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 6f741425dc85f3d9d868d76002a92aa9bd3cb6cb)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -78,7 +78,7 @@
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs
===================================================================
diff -u -rbba9524cfdab4e69348fddab60efe718e7c1865b -red0ac171987ec828fb4aebf32493a41d43c7599c
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision bba9524cfdab4e69348fddab60efe718e7c1865b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -299,7 +299,7 @@
TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismContributionIcon, contributionViewInfo.Image);
var designWaterLevelLocationsViewInfo = viewInfos.Single(vi => vi.DataType == typeof(DesignWaterLevelLocationsContext));
- Assert.AreEqual(typeof(HydraulicBoundaryLocationDesignWaterLevelsView), designWaterLevelLocationsViewInfo.ViewType);
+ Assert.AreEqual(typeof(DesignWaterLevelLocationsView), designWaterLevelLocationsViewInfo.ViewType);
TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, designWaterLevelLocationsViewInfo.Image);
var mapViewInfo = viewInfos.Single(vi => vi.DataType == typeof(IAssessmentSection));
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
@@ -0,0 +1,158 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Gui;
+using Core.Common.Gui.Commands;
+using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.Properties;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.Views;
+
+namespace Ringtoets.Integration.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class DesignWaterLevelLocationsViewInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsViewName()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+ var view = new DesignWaterLevelLocationsView();
+
+ // Call
+ var viewName = info.GetViewName(view, assessmentSection);
+
+ // Assert
+ Assert.AreEqual("Toetspeilen", viewName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ViewDataType_Always_ReturnsViewDataType()
+ {
+ // Call
+ var viewDataType = info.ViewDataType;
+
+ // Assert
+ Assert.AreEqual(typeof(IAssessmentSection), viewDataType);
+ }
+
+ [Test]
+ public void DataType_Always_ReturnsDataType()
+ {
+ // Call
+ var dataType = info.DataType;
+
+ // Assert
+ Assert.AreEqual(typeof(DesignWaterLevelLocationsContext), dataType);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Call
+ var image = info.Image;
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(Resources.GenericInputOutputIcon, image);
+ }
+
+ [Test]
+ public void GetViewData_Always_ReturnsHydraulicBoundaryDatabase()
+ {
+ // Setup
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase;
+ mocks.ReplayAll();
+ var context = new DesignWaterLevelLocationsContext(assessmentSection);
+
+ // Call
+ var viewData = info.GetViewData(context);
+
+ // Assert
+ Assert.AreSame(assessmentSection, viewData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView()
+ {
+ // Setup
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase;
+
+ IGui guiStub = mocks.Stub();
+ guiStub.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiStub.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ guiStub.Stub(g => g.MainWindow).Return(mocks.Stub());
+
+ mocks.ReplayAll();
+
+ var context = new DesignWaterLevelLocationsContext(assessmentSection);
+
+ var view = new DesignWaterLevelLocationsView();
+
+ using (var ringtoetsPlugin = new RingtoetsPlugin())
+ {
+ info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView));
+ ringtoetsPlugin.Gui = guiStub;
+
+ // Call
+ info.AfterCreate(view, context);
+
+ // Assert
+ Assert.AreSame(view.ApplicationSelection, guiStub);
+ }
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag ed0ac171987ec828fb4aebf32493a41d43c7599c refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/HydraulicBoundaryLocationDesignWaterLevelsViewInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?