Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -r2c58a8ed345659c071f1531edb80bf6fc9e4f913 -rc6f57328aeeabd813c96aee9ef763f54b6267214
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision c6f57328aeeabd813c96aee9ef763f54b6267214)
@@ -80,26 +80,11 @@
Core.Common.Base
False
-
- {1d27f91f-4e62-4eaf-a0a8-a32708b9a9b1}
- Core.Common.Controls.TreeView
- False
-
{9a2d67e6-26ac-4d17-b11a-2b4372f2f572}
Core.Common.Controls
False
-
- {30E4C2AE-719E-4D70-9FA9-668A9767FBFA}
- Core.Common.Gui
- False
-
-
- {f49bd8b2-332a-4c91-a196-8cce0a2c7d98}
- Core.Common.Utils
- False
-
{c90b77da-e421-43cc-b82e-529651bc21ac}
Core.Common.Version
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs
===================================================================
diff -u -rd49b0c7df08ca616edb5c3945adbb22eab479bf7 -rc6f57328aeeabd813c96aee9ef763f54b6267214
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision c6f57328aeeabd813c96aee9ef763f54b6267214)
@@ -42,6 +42,7 @@
private IEnumerable pipingFailureMechanismSectionResult;
private IFailureMechanism failureMechanism;
+ private string cellEditValue;
///
/// Creates a new instance of .
@@ -104,6 +105,9 @@
private void InitializeDataGridView()
{
dataGridView.CurrentCellDirtyStateChanged += DataGridViewCurrentCellDirtyStateChanged;
+ dataGridView.CellValidating += DataGridViewCellValidating;
+ dataGridView.DataError += DataGridViewDataError;
+ dataGridView.CellEndEdit += DataGridViewCellEndEdit;
var sectionName = new DataGridViewTextBoxColumn
{
@@ -241,7 +245,7 @@
{
get
{
- return (RoundedDouble) double.NaN;
+ return failureMechanismSectionResult.AssessmentLayerTwoA;
}
set
{
@@ -253,7 +257,7 @@
{
get
{
- return (RoundedDouble) double.NaN;
+ return failureMechanismSectionResult.AssessmentLayerTwoB;
}
set
{
@@ -265,7 +269,7 @@
{
get
{
- return (RoundedDouble) double.NaN;
+ return failureMechanismSectionResult.AssessmentLayerThree;
}
set
{
@@ -280,7 +284,7 @@
private void DataGridViewCurrentCellDirtyStateChanged(object sender, EventArgs e)
{
- // Ensure combobox values are directly committed
+ // Ensure checkbox values are directly committed
DataGridViewColumn currentColumn = dataGridView.Columns[dataGridView.CurrentCell.ColumnIndex];
if (currentColumn is DataGridViewCheckBoxColumn)
{
@@ -289,6 +293,34 @@
}
}
+ private void DataGridViewCellValidating(object sender, DataGridViewCellValidatingEventArgs e)
+ {
+ cellEditValue = e.FormattedValue.ToString();
+ if (string.IsNullOrWhiteSpace(cellEditValue))
+ {
+ dataGridView.Rows[e.RowIndex].ErrorText = "De tekst mag niet leeg zijn.";
+ }
+ }
+
+ private void DataGridViewDataError(object sender, DataGridViewDataErrorEventArgs e)
+ {
+ e.ThrowException = false;
+ e.Cancel = true;
+
+ if (string.IsNullOrWhiteSpace(cellEditValue) || e.Exception == null)
+ {
+ return;
+ }
+
+ dataGridView.Rows[e.RowIndex].ErrorText = e.Exception.Message;
+ }
+
+ private void DataGridViewCellEndEdit(object sender, DataGridViewCellEventArgs e)
+ {
+ cellEditValue = string.Empty;
+ dataGridView.Rows[e.RowIndex].ErrorText = String.Empty;
+ }
+
#endregion
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs
===================================================================
diff -u -rd49b0c7df08ca616edb5c3945adbb22eab479bf7 -rc6f57328aeeabd813c96aee9ef763f54b6267214
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs (.../FailureMechanismResultViewTest.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs (.../FailureMechanismResultViewTest.cs) (revision c6f57328aeeabd813c96aee9ef763f54b6267214)
@@ -23,10 +23,12 @@
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 Rhino.Mocks;
using Ringtoets.Common.Data;
using Ringtoets.Common.Forms.Views;
@@ -59,6 +61,7 @@
Assert.IsInstanceOf(view);
Assert.IsInstanceOf(view);
Assert.IsNull(view.Data);
+ Assert.IsNull(view.FailureMechanism);
}
[Test]
@@ -122,6 +125,29 @@
}
[Test]
+ public void Dispose_FailureMechanismResultViewWithAdditionalPropertiesSet_AdditionalPropertiesSetToNull()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = new SimpleFailureMechanism();
+ mocks.ReplayAll();
+
+ var view = new FailureMechanismResultView
+ {
+ FailureMechanism = failureMechanism
+ };
+
+ // Precondition
+ Assert.IsNotNull(view.FailureMechanism);
+
+ // Call
+ view.Dispose();
+
+ // Assert
+ Assert.IsNull(view.FailureMechanism);
+ }
+
+ [Test]
public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized()
{
// Setup & Call
@@ -137,17 +163,17 @@
Assert.AreEqual(5, cells.Count);
Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue);
Assert.IsFalse((bool) cells[assessmentLayerOneIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerTwoAIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerTwoBIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerThreeIndex].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}", double.NaN), cells[assessmentLayerTwoAIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerTwoBIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerThreeIndex].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]
@@ -160,19 +186,18 @@
var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
- dataGridView.Rows[0].Cells[1].Value = checkBoxSelected;
+ dataGridView.Rows[0].Cells[assessmentLayerOneIndex].Value = checkBoxSelected;
// 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.AreEqual(checkBoxSelected, (bool)cells[assessmentLayerOneIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerTwoAIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerTwoBIndex].FormattedValue);
- Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerThreeIndex].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);
if (checkBoxSelected)
{
@@ -198,6 +223,62 @@
Assert.AreEqual(checkBoxSelected, cells[assessmentLayerThreeIndex].ReadOnly);
}
+ [Test]
+ [TestCase("test", assessmentLayerTwoAIndex)]
+ [TestCase("test", assessmentLayerTwoBIndex)]
+ [TestCase("test", assessmentLayerThreeIndex)]
+ [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerTwoAIndex)]
+ [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerTwoBIndex)]
+ [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerThreeIndex)]
+ public void FailureMechanismResultView_EditValueInvalid_ShowsErrorTooltip(string newValue, int cellIndex)
+ {
+ // Setup
+ 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", assessmentLayerTwoAIndex, "AssessmentLayerTwoA")]
+ [TestCase("1e-6", assessmentLayerTwoAIndex, "AssessmentLayerTwoA")]
+ [TestCase("1e+6", assessmentLayerTwoAIndex, "AssessmentLayerTwoA")]
+ [TestCase("14.3", assessmentLayerTwoAIndex, "AssessmentLayerTwoA")]
+ [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
+ 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);
+ }
+
private const int nameColumnIndex = 0;
private const int assessmentLayerOneIndex = 1;
private const int assessmentLayerTwoAIndex = 2;
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -r2c58a8ed345659c071f1531edb80bf6fc9e4f913 -rc6f57328aeeabd813c96aee9ef763f54b6267214
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision c6f57328aeeabd813c96aee9ef763f54b6267214)
@@ -52,7 +52,6 @@
using Ringtoets.Integration.Plugin.Properties;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
-using Ringtoets.Piping.Forms.Views;
using RingtoetsDataResources = Ringtoets.Integration.Data.Properties.Resources;
using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -rc6f57328aeeabd813c96aee9ef763f54b6267214
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision c6f57328aeeabd813c96aee9ef763f54b6267214)
@@ -68,7 +68,7 @@
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision c6f57328aeeabd813c96aee9ef763f54b6267214)
@@ -0,0 +1,122 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Plugin;
+using Ringtoets.Piping.Data;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class FailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsGuiPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsGuiPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new PipingFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Oordeel", text);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var gui = mocks.StrictMultiMock();
+ var treeViewControl = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag c6f57328aeeabd813c96aee9ef763f54b6267214 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismSectionResultTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?