Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs
===================================================================
diff -u -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f -r8f257d2094036e69e5da32dce96b5195f59508ea
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -25,10 +25,11 @@
using Core.Common.Base;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
-using Ringtoets.Common.Forms.Properties;
using Ringtoets.Common.Forms.Views;
using Ringtoets.GrassCoverErosionInwards.Data;
+
using CoreCommonResources = Core.Common.Base.Properties.Resources;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.GrassCoverErosionInwards.Forms.Views
{
@@ -103,22 +104,22 @@
yield return new DataGridViewTextBoxColumn
{
DataPropertyName = "AssessmentLayerTwoA",
- HeaderText = Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a,
+ HeaderText = RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a,
Name = "column_AssessmentLayerTwoA",
ReadOnly = true
};
yield return new DataGridViewTextBoxColumn
{
DataPropertyName = "AssessmentLayerTwoB",
- HeaderText = Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b,
+ HeaderText = RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_b,
Name = "column_AssessmentLayerTwoB"
};
yield return new DataGridViewTextBoxColumn
{
DataPropertyName = "AssessmentLayerThree",
- HeaderText = Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three,
+ HeaderText = RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three,
Name = "column_AssessmentLayerThree"
};
}
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/AssemblyInfo.cs
===================================================================
diff -u -r07efb7c80815d1747386437cf8dcd6db25b9160a -r8f257d2094036e69e5da32dce96b5195f59508ea
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 07efb7c80815d1747386437cf8dcd6db25b9160a)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -20,8 +20,10 @@
// All rights reserved.
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Ringtoets.HeightStructures.Forms")]
[assembly: AssemblyProduct("Ringtoets.HeightStructures.Forms")]
-[assembly: Guid("59547e5b-3119-41e3-adf7-5f94b6cf0a5b")]
\ No newline at end of file
+[assembly: Guid("59547e5b-3119-41e3-adf7-5f94b6cf0a5b")]
+[assembly: InternalsVisibleTo("Ringtoets.HeightStructures.Forms.Test")]
\ No newline at end of file
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj
===================================================================
diff -u -r47d80506f9f8166de93579dbba94e57f4101927b -r8f257d2094036e69e5da32dce96b5195f59508ea
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 47d80506f9f8166de93579dbba94e57f4101927b)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -34,7 +34,10 @@
+
+
+
@@ -52,6 +55,13 @@
True
Resources.resx
+
+ UserControl
+
+
+ HeightStructuresFailureMechanismResultView.cs
+
+
@@ -95,6 +105,9 @@
Resources.Designer.cs
Designer
+
+ HeightStructuresFailureMechanismResultView.cs
+
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.Designer.cs
===================================================================
diff -u
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.Designer.cs (revision 0)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.Designer.cs (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -0,0 +1,46 @@
+namespace Ringtoets.HeightStructures.Forms.Views
+{
+ partial class HeightStructuresFailureMechanismResultView
+ {
+ ///
+ /// 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.dataGridView = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.Size = new System.Drawing.Size(150, 150);
+ this.dataGridView.TabIndex = 0;
+ //
+ // HeightStructuresFailureMechanismResultView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.dataGridView);
+ this.Name = "HeightStructuresFailureMechanismResultView";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridView;
+ }
+}
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs
===================================================================
diff -u
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs (revision 0)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -0,0 +1,128 @@
+// 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.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.Views;
+using Ringtoets.HeightStructures.Data;
+
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.HeightStructures.Forms.Views
+{
+ public partial class HeightStructuresFailureMechanismResultView : FailureMechanismResultView
+ {
+ private readonly RecursiveObserver calculationInputObserver;
+ private readonly RecursiveObserver calculationOutputObserver;
+ private readonly RecursiveObserver calculationGroupObserver;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ public HeightStructuresFailureMechanismResultView()
+ {
+ AddCellFormattingHandler(DisableIrrelevantFieldsFormatting);
+
+ // The concat is needed to observe the input of calculations in child groups.
+ calculationInputObserver = new RecursiveObserver(UpdataDataGridViewDataSource, cg => cg.Children.Concat
@@ -104,6 +109,10 @@
{4d840673-3812-4338-a352-84854e32b8a0}
Ringtoets.Common.Forms
+
+ {4843D6E5-066F-4795-94F5-1D53932DD03C}
+ Ringtoets.Common.Data.TestUtil
+
{1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99}
Ringtoets.HeightStructures.Data
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs
===================================================================
diff -u
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (revision 0)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -0,0 +1,349 @@
+// 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.Drawing;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.Views;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.HeightStructures.Forms.Views;
+
+namespace Ringtoets.HeightStructures.Forms.Test.Views
+{
+ [TestFixture]
+ public class HeightStructuresFailureMechanismResultViewTest
+ {
+ 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 HeightStructuresFailureMechanismResultView())
+ {
+ // Assert
+ Assert.IsInstanceOf(view);
+ Assert.IsInstanceOf(view);
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void Constructor_DataGridViewCorrectlyInitialized()
+ {
+ // Call
+ using (ShowFailureMechanismResultsView())
+ {
+ // Assert
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ Assert.AreEqual(5, dataGridView.ColumnCount);
+ Assert.IsTrue(dataGridView.Columns[assessmentLayerTwoAIndex].ReadOnly);
+
+ foreach (var column in dataGridView.Columns.OfType())
+ {
+ Assert.AreEqual("This", column.ValueMember);
+ Assert.AreEqual("DisplayName", column.DisplayMember);
+ }
+
+ Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode);
+ Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment);
+ }
+ }
+
+ [Test]
+ public void Data_DataAlreadySetNewDataSet_DataSetAndDataGridViewUpdated()
+ {
+ // Setup
+ using (var view = ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ var points = new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(3, 4)
+ };
+
+ var section = new FailureMechanismSection("test", points);
+ var sectionResult = new HeightStructuresFailureMechanismSectionResult(section);
+ var testData = new List
+ {
+ sectionResult
+ };
+
+ // Precondition
+ Assert.AreEqual(2, dataGridView.RowCount);
+
+ // Call
+ view.Data = testData;
+
+ // Assert
+ Assert.AreSame(testData, view.Data);
+
+ Assert.AreEqual(testData.Count, dataGridView.RowCount);
+ Assert.AreEqual(sectionResult.Section.Name, dataGridView.Rows[0].Cells[0].Value);
+ }
+ }
+
+ [Test]
+ public void Data_SetOtherThanFailureMechanismSectionResultListData_DataNullAndDataGridViewOneEmtpyRow()
+ {
+ // Setup
+ var testData = new object();
+ using (var view = ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ // Call
+ view.Data = testData;
+
+ // Assert
+ Assert.IsNull(view.Data);
+
+ Assert.AreEqual(0, dataGridView.RowCount);
+ }
+ }
+
+ [Test]
+ public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized()
+ {
+ // Setup & Call
+ using (ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ // Assert
+ var rows = dataGridView.Rows;
+ Assert.AreEqual(2, rows.Count);
+
+ var cells = rows[0].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue);
+ Assert.IsFalse((bool)cells[assessmentLayerOneIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cells[assessmentLayerTwoAIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cells[assessmentLayerTwoBIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cells[assessmentLayerThreeIndex].FormattedValue);
+
+ cells = rows[1].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue);
+ Assert.IsFalse((bool)cells[assessmentLayerOneIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cells[assessmentLayerTwoAIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cells[assessmentLayerTwoBIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cells[assessmentLayerThreeIndex].FormattedValue);
+ }
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void FailureMechanismResultsView_ChangeCheckBox_DataGridViewCorrectlySyncedAndStylingSet(bool checkBoxSelected)
+ {
+ // Setup
+ using (ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ dataGridView.Rows[0].Cells[assessmentLayerOneIndex].Value = checkBoxSelected;
+
+ // Assert
+ var rows = dataGridView.Rows;
+
+ var cells = rows[0].Cells;
+ Assert.AreEqual(5, cells.Count);
+ Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue);
+ var cellAssessmentLayerTwoA = cells[assessmentLayerTwoAIndex];
+ var cellAssessmentLayerTwoB = cells[assessmentLayerTwoBIndex];
+ var cellAssessmentLayerThree = cells[assessmentLayerThreeIndex];
+
+ Assert.AreEqual(checkBoxSelected, (bool)cells[assessmentLayerOneIndex].FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cellAssessmentLayerTwoA.FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cellAssessmentLayerTwoB.FormattedValue);
+ Assert.AreEqual(string.Format("{0}", 0), cellAssessmentLayerThree.FormattedValue);
+
+ var cellAssessmentLayerTwoABackColor = cellAssessmentLayerTwoA.Style.BackColor;
+ var cellAssessmentLayerTwoAForeColor = cellAssessmentLayerTwoA.Style.ForeColor;
+ var cellAssessmentLayerTwoBBackColor = cellAssessmentLayerTwoB.Style.BackColor;
+ var cellAssessmentLayerTwoBForeColor = cellAssessmentLayerTwoB.Style.ForeColor;
+ var cellAssessmentLayerThreeBackColor = cellAssessmentLayerThree.Style.BackColor;
+ var cellAssessmentLayerThreeForeColor = cellAssessmentLayerThree.Style.ForeColor;
+
+ if (checkBoxSelected)
+ {
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), cellAssessmentLayerTwoABackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), cellAssessmentLayerTwoAForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), cellAssessmentLayerTwoBBackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), cellAssessmentLayerTwoBForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), cellAssessmentLayerThreeBackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), cellAssessmentLayerThreeForeColor);
+ }
+ else
+ {
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), cellAssessmentLayerTwoABackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), cellAssessmentLayerTwoAForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), cellAssessmentLayerTwoBBackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), cellAssessmentLayerTwoBForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), cellAssessmentLayerThreeBackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), cellAssessmentLayerThreeForeColor);
+ }
+
+ Assert.AreEqual(checkBoxSelected, cellAssessmentLayerTwoB.ReadOnly);
+ Assert.AreEqual(checkBoxSelected, cellAssessmentLayerThree.ReadOnly);
+ }
+ }
+
+ [Test]
+ [TestCase("test", assessmentLayerTwoBIndex)]
+ [TestCase("test", assessmentLayerThreeIndex)]
+ [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerTwoBIndex)]
+ [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerThreeIndex)]
+ public void FailureMechanismResultView_EditValueInvalid_ShowsErrorTooltip(string newValue, int cellIndex)
+ {
+ // Setup
+ using (ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ // Call
+ dataGridView.Rows[0].Cells[cellIndex].Value = newValue;
+
+ // Assert
+ Assert.AreEqual("De tekst moet een getal zijn.", dataGridView.Rows[0].ErrorText);
+ }
+ }
+
+ [Test]
+ [TestCase("1", assessmentLayerTwoBIndex, "AssessmentLayerTwoB")]
+ [TestCase("1e-6", assessmentLayerTwoBIndex, "AssessmentLayerTwoB")]
+ [TestCase("1e+6", assessmentLayerTwoBIndex, "AssessmentLayerTwoB")]
+ [TestCase("14.3", assessmentLayerTwoBIndex, "AssessmentLayerTwoB")]
+ [TestCase("1", assessmentLayerThreeIndex, "AssessmentLayerThree")]
+ [TestCase("1e-6", assessmentLayerThreeIndex, "AssessmentLayerThree")]
+ [TestCase("1e+6", assessmentLayerThreeIndex, "AssessmentLayerThree")]
+ [TestCase("14.3", assessmentLayerThreeIndex, "AssessmentLayerThree")]
+ public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(string newValue, int cellIndex, string propertyName)
+ {
+ // Setup
+ using (var view = ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ // Call
+ dataGridView.Rows[0].Cells[cellIndex].Value = newValue;
+
+ // Assert
+ Assert.IsEmpty(dataGridView.Rows[0].ErrorText);
+
+ var dataObject = view.Data as List;
+ Assert.IsNotNull(dataObject);
+ var row = dataObject.First();
+
+ var propertyValue = row.GetType().GetProperty(propertyName).GetValue(row, null);
+
+ Assert.AreEqual((RoundedDouble)double.Parse(newValue), propertyValue);
+ }
+ }
+
+ [Test]
+ public void FailureMechanismResultView_EditValueDirtyStateChangedEventFired_ValueCommittedCellInEditMode()
+ {
+ // Setup
+ using (var view = ShowFullyConfiguredFailureMechanismResultsView())
+ {
+ var sections = (List)view.Data;
+ sections[0].AssessmentLayerOne = false;
+
+ var gridTester = new ControlTester("dataGridView");
+ var dataGridView = (DataGridView)gridTester.TheObject;
+ var dataGridViewCell = dataGridView.Rows[0].Cells[assessmentLayerOneIndex];
+
+ dataGridView.CurrentCell = dataGridViewCell;
+ dataGridView.BeginEdit(false);
+ gridTester.FireEvent("KeyUp", new KeyEventArgs(Keys.Space));
+
+ // Call
+ gridTester.FireEvent("CurrentCellDirtyStateChanged", EventArgs.Empty);
+
+ // Assert
+ Assert.IsTrue(dataGridViewCell.IsInEditMode);
+ Assert.IsTrue(sections[0].AssessmentLayerOne);
+ }
+ }
+
+ private const int nameColumnIndex = 0;
+ private const int assessmentLayerOneIndex = 1;
+ private const int assessmentLayerTwoAIndex = 2;
+ private const int assessmentLayerTwoBIndex = 3;
+ private const int assessmentLayerThreeIndex = 4;
+
+ private HeightStructuresFailureMechanismResultView ShowFullyConfiguredFailureMechanismResultsView()
+ {
+ var failureMechanism = new HeightStructuresFailureMechanism();
+
+ failureMechanism.AddSection(new FailureMechanismSection("Section 1", new List
+ {
+ new Point2D(0.0, 0.0),
+ new Point2D(5.0, 0.0)
+ }));
+
+ failureMechanism.AddSection(new FailureMechanismSection("Section 2", new List
+ {
+ new Point2D(5.0, 0.0),
+ new Point2D(10.0, 0.0)
+ }));
+
+ var failureMechanismResultView = ShowFailureMechanismResultsView();
+ failureMechanismResultView.Data = failureMechanism.SectionResults;
+ failureMechanismResultView.FailureMechanism = failureMechanism;
+
+ return failureMechanismResultView;
+ }
+
+ private HeightStructuresFailureMechanismResultView ShowFailureMechanismResultsView()
+ {
+ HeightStructuresFailureMechanismResultView failureMechanismResultView = new HeightStructuresFailureMechanismResultView();
+ testForm.Controls.Add(failureMechanismResultView);
+ testForm.Show();
+
+ return failureMechanismResultView;
+ }
+ }
+}
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismSectionResultRowTest.cs
===================================================================
diff -u
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismSectionResultRowTest.cs (revision 0)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismSectionResultRowTest.cs (revision 8f257d2094036e69e5da32dce96b5195f59508ea)
@@ -0,0 +1,133 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.HeightStructures.Forms.Views;
+
+namespace Ringtoets.HeightStructures.Forms.Test.Views
+{
+ [TestFixture]
+ public class HeightStructuresFailureMechanismSectionResultRowTest
+ {
+ [Test]
+ public void Constructor_WithoutSectionResult_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new HeightStructuresFailureMechanismSectionResultRow(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("sectionResult", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithSectionResult_PropertiesFromSectionAndResult()
+ {
+ // Setup
+ var section = CreateSection();
+ var result = new HeightStructuresFailureMechanismSectionResult(section);
+
+ // Call
+ var row = new HeightStructuresFailureMechanismSectionResultRow(result);
+
+ // Assert
+ Assert.AreEqual(section.Name, row.Name);
+ Assert.AreEqual(result.AssessmentLayerOne, row.AssessmentLayerOne);
+ Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA);
+ Assert.AreEqual(result.AssessmentLayerTwoB, row.AssessmentLayerTwoB);
+ Assert.AreEqual(result.AssessmentLayerThree, row.AssessmentLayerThree);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void AssessmentLayerOne_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged(bool newValue)
+ {
+ // Setup
+ var section = CreateSection();
+ var result = new HeightStructuresFailureMechanismSectionResult(section);
+ var row = new HeightStructuresFailureMechanismSectionResultRow(result);
+
+ int counter = 0;
+ using (new Observer(() => counter++)
+ {
+ Observable = result
+ })
+ {
+ // Call
+ row.AssessmentLayerOne = newValue;
+
+ // Assert
+ Assert.AreEqual(1, counter);
+ Assert.AreEqual(newValue, result.AssessmentLayerOne);
+ }
+ }
+
+ [Test]
+ public void AssessmentLayerTwoB_AlwaysOnChange_ResultPropertyChanged()
+ {
+ // Setup
+ var random = new Random(21);
+ var newValue = random.NextDouble();
+ var section = CreateSection();
+ var result = new HeightStructuresFailureMechanismSectionResult(section);
+ var row = new HeightStructuresFailureMechanismSectionResultRow(result);
+
+ // Call
+ row.AssessmentLayerTwoB = (RoundedDouble)newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, result.AssessmentLayerTwoB, row.AssessmentLayerTwoB.GetAccuracy());
+ }
+
+ [Test]
+ public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged()
+ {
+ // Setup
+ var random = new Random(21);
+ var newValue = random.NextDouble();
+ var section = CreateSection();
+ var result = new HeightStructuresFailureMechanismSectionResult(section);
+ var row = new HeightStructuresFailureMechanismSectionResultRow(result);
+
+ // Call
+ row.AssessmentLayerThree = (RoundedDouble)newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, result.AssessmentLayerThree, row.AssessmentLayerThree.GetAccuracy());
+ }
+
+ private static FailureMechanismSection CreateSection()
+ {
+ return new FailureMechanismSection("name", new[]
+ {
+ new Point2D(0, 0)
+ });
+ }
+ }
+}
\ No newline at end of file