Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanismSectionResult.cs
===================================================================
diff -u -r756f077b356b86d6524dac7234ed6003b51a6d68 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanismSectionResult.cs (.../FailureMechanismSectionResult.cs) (revision 756f077b356b86d6524dac7234ed6003b51a6d68)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanismSectionResult.cs (.../FailureMechanismSectionResult.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -20,13 +20,15 @@
// All rights reserved.
using System;
+using Core.Common.Base;
+using Core.Common.Base.Data;
namespace Ringtoets.Common.Data
{
///
/// This class holds the information of the result of the .
///
- public class FailureMechanismSectionResult
+ public class FailureMechanismSectionResult : Observable
{
private readonly FailureMechanismSection section;
@@ -45,11 +47,6 @@
}
///
- /// Gets and sets the state of the assessment layer one.
- ///
- public bool AssessmentLayerOne { get; set; }
-
- ///
/// Gets the encapsulated .
///
public FailureMechanismSection Section
@@ -59,5 +56,25 @@
return section;
}
}
+
+ ///
+ /// Gets and sets the state of the assessment layer one.
+ ///
+ public bool AssessmentLayerOne { get; set; }
+
+ ///
+ /// Gets and sets the value of assesment layer two a.
+ ///
+ public RoundedDouble AssessmentLayerTwoA { get; set; }
+
+ ///
+ /// Gets and sets the value of assesment layer two b.
+ ///
+ public RoundedDouble AssessmentLayerTwoB { get; set; }
+
+ ///
+ /// Gets and sets the value of assesment layer three.
+ ///
+ public RoundedDouble AssessmentLayerThree { get; set; }
}
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionResultContext.cs
===================================================================
diff -u -r2c58a8ed345659c071f1531edb80bf6fc9e4f913 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionResultContext.cs (.../FailureMechanismSectionResultContext.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionResultContext.cs (.../FailureMechanismSectionResultContext.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -25,11 +25,20 @@
namespace Ringtoets.Common.Forms.PresentationObjects
{
+ ///
+ /// This class is a presentation object for .
+ ///
public class FailureMechanismSectionResultContext
{
private readonly IEnumerable sectionResults;
private readonly IFailureMechanism failureMechanism;
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The of to wrap.
+ /// The belongs to.
+ /// Thrown when or is null.
public FailureMechanismSectionResultContext(IEnumerable sectionResults, IFailureMechanism failureMechanism)
{
if (sectionResults == null)
@@ -44,6 +53,9 @@
this.failureMechanism = failureMechanism;
}
+ ///
+ /// Gets the wrapped of .
+ ///
public IEnumerable SectionResults
{
get
@@ -52,6 +64,9 @@
}
}
+ ///
+ /// Gets the .
+ ///
public IFailureMechanism FailureMechanism
{
get
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.Designer.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.Designer.cs (.../FailureMechanismResultView.Designer.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.Designer.cs (.../FailureMechanismResultView.Designer.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -7,19 +7,6 @@
///
private System.ComponentModel.IContainer components = null;
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
#region Component Designer generated code
///
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs
===================================================================
diff -u -r2c58a8ed345659c071f1531edb80bf6fc9e4f913 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -19,9 +19,12 @@
// 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;
using Core.Common.Base.Data;
using Core.Common.Controls.Views;
using Ringtoets.Common.Data;
@@ -34,7 +37,11 @@
///
public partial class FailureMechanismResultView : UserControl, IView
{
+ private readonly Observer failureMechanismObserver;
+ private readonly RecursiveObserver failureMechanismSectionResultObserver;
+
private IEnumerable pipingFailureMechanismSectionResult;
+ private IFailureMechanism failureMechanism;
///
/// Creates a new instance of .
@@ -43,8 +50,29 @@
{
InitializeComponent();
InitializeDataGridView();
+
+ failureMechanismObserver = new Observer(UpdataDataGridViewDataSource);
+ failureMechanismSectionResultObserver = new RecursiveObserver(RefreshDataGridView, mechanism => mechanism.SectionResults);
}
+ ///
+ /// Gets or sets the failure mechanism.
+ ///
+ public IFailureMechanism FailureMechanism
+ {
+ get
+ {
+ return failureMechanism;
+ }
+ set
+ {
+ failureMechanism = value;
+
+ failureMechanismObserver.Observable = failureMechanism;
+ failureMechanismSectionResultObserver.Observable = failureMechanism;
+ }
+ }
+
public object Data
{
get
@@ -62,10 +90,21 @@
}
}
- public IFailureMechanism FailureMechanism { get; set; }
+ protected override void Dispose(bool disposing)
+ {
+ FailureMechanism = null;
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
private void InitializeDataGridView()
{
+ dataGridView.CurrentCellDirtyStateChanged += DataGridViewCurrentCellDirtyStateChanged;
+
var sectionName = new DataGridViewTextBoxColumn
{
DataPropertyName = "Name",
@@ -113,22 +152,66 @@
private void UpdataDataGridViewDataSource()
{
- if (dataGridView.IsCurrentCellInEditMode)
+ dataGridView.DataSource = pipingFailureMechanismSectionResult.Select(sr => new FailureMechanismSectionResultRow(sr)).ToList();
+ SetRowStyling();
+ }
+
+ private void RefreshDataGridView()
+ {
+ dataGridView.Refresh();
+ dataGridView.AutoResizeColumns();
+
+ SetRowStyling();
+ }
+
+ private void SetRowStyling()
+ {
+ foreach (DataGridViewRow row in dataGridView.Rows)
{
- dataGridView.AutoResizeColumns();
- return;
+ var checkboxSelected = (bool) row.Cells[1].Value;
+
+ SetRowEditMode(row, checkboxSelected);
+
+ SetRowStyle(checkboxSelected, row);
}
+ }
- dataGridView.DataSource = pipingFailureMechanismSectionResult.Select(sr => new PipingFailureMechanismSectionResultRow(sr)).ToList();
+ private static void SetRowEditMode(DataGridViewRow row, bool checkboxSelected)
+ {
+ row.Cells[2].ReadOnly = checkboxSelected;
+ row.Cells[3].ReadOnly = checkboxSelected;
+ row.Cells[4].ReadOnly = checkboxSelected;
}
+ private void SetRowStyle(bool checkboxSelected, DataGridViewRow row)
+ {
+ if (checkboxSelected)
+ {
+ SetCellStyle(row.Cells[2], Color.FromKnownColor(KnownColor.DarkGray), Color.FromKnownColor(KnownColor.GrayText));
+ SetCellStyle(row.Cells[3], Color.FromKnownColor(KnownColor.DarkGray), Color.FromKnownColor(KnownColor.GrayText));
+ SetCellStyle(row.Cells[4], Color.FromKnownColor(KnownColor.DarkGray), Color.FromKnownColor(KnownColor.GrayText));
+ }
+ else
+ {
+ SetCellStyle(row.Cells[2], Color.FromKnownColor(KnownColor.White), Color.FromKnownColor(KnownColor.ControlText));
+ SetCellStyle(row.Cells[3], Color.FromKnownColor(KnownColor.White), Color.FromKnownColor(KnownColor.ControlText));
+ SetCellStyle(row.Cells[4], Color.FromKnownColor(KnownColor.White), Color.FromKnownColor(KnownColor.ControlText));
+ }
+ }
+
+ private void SetCellStyle(DataGridViewCell cell, Color backgroundColor, Color textColor)
+ {
+ cell.Style.BackColor = backgroundColor;
+ cell.Style.ForeColor = textColor;
+ }
+
#region Nested types
- private class PipingFailureMechanismSectionResultRow
+ private class FailureMechanismSectionResultRow
{
private readonly FailureMechanismSectionResult failureMechanismSectionResult;
- public PipingFailureMechanismSectionResultRow(FailureMechanismSectionResult failureMechanismSectionResult)
+ public FailureMechanismSectionResultRow(FailureMechanismSectionResult failureMechanismSectionResult)
{
this.failureMechanismSectionResult = failureMechanismSectionResult;
}
@@ -147,6 +230,11 @@
{
return failureMechanismSectionResult.AssessmentLayerOne;
}
+ set
+ {
+ failureMechanismSectionResult.AssessmentLayerOne = value;
+ failureMechanismSectionResult.NotifyObservers();
+ }
}
public RoundedDouble AssessmentLayerTwoA
@@ -155,6 +243,10 @@
{
return (RoundedDouble) double.NaN;
}
+ set
+ {
+ failureMechanismSectionResult.AssessmentLayerTwoA = value;
+ }
}
public RoundedDouble AssessmentLayerTwoB
@@ -163,6 +255,10 @@
{
return (RoundedDouble) double.NaN;
}
+ set
+ {
+ failureMechanismSectionResult.AssessmentLayerTwoB = value;
+ }
}
public RoundedDouble AssessmentLayerThree
@@ -171,9 +267,28 @@
{
return (RoundedDouble) double.NaN;
}
+ set
+ {
+ failureMechanismSectionResult.AssessmentLayerThree = value;
+ }
}
}
#endregion
+
+ #region Event handling
+
+ private void DataGridViewCurrentCellDirtyStateChanged(object sender, EventArgs e)
+ {
+ // Ensure combobox values are directly committed
+ DataGridViewColumn currentColumn = dataGridView.Columns[dataGridView.CurrentCell.ColumnIndex];
+ if (currentColumn is DataGridViewCheckBoxColumn)
+ {
+ dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
+ dataGridView.EndEdit();
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanismSectionResultTest.cs
===================================================================
diff -u -r756f077b356b86d6524dac7234ed6003b51a6d68 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanismSectionResultTest.cs (.../FailureMechanismSectionResultTest.cs) (revision 756f077b356b86d6524dac7234ed6003b51a6d68)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanismSectionResultTest.cs (.../FailureMechanismSectionResultTest.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -32,15 +32,8 @@
public void Constructor_DefaultValues()
{
// Setup
- var points = new[]
- {
- new Point2D(1, 2),
- new Point2D(3, 4)
- };
+ var section = CreateSection();
- var section = new FailureMechanismSection("test", points);
-
-
// Call
var sectionResult = new FailureMechanismSectionResult(section);
@@ -58,5 +51,33 @@
var exception = Assert.Throws(call);
Assert.AreEqual("section", exception.ParamName);
}
+
+ [Test]
+ [TestCase(false)]
+ [TestCase(true)]
+ public void AssessmentLayerOne_Always_ReturnsAssessmentLayerOne(bool assessmentLayerOneChecked)
+ {
+ // Setup
+ var section = CreateSection();
+ var sectionResult = new FailureMechanismSectionResult(section);
+
+ // Call
+ sectionResult.AssessmentLayerOne = assessmentLayerOneChecked;
+
+ // Assert
+ Assert.AreEqual(assessmentLayerOneChecked, sectionResult.AssessmentLayerOne);
+ }
+
+ private static FailureMechanismSection CreateSection()
+ {
+ var points = new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(3, 4)
+ };
+
+ var section = new FailureMechanismSection("test", points);
+ return section;
+ }
}
-}
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismSectionResultContextTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismSectionResultContextTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismSectionResultContextTest.cs (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -0,0 +1,87 @@
+using System;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Forms.PresentationObjects;
+
+namespace Ringtoets.Common.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class FailureMechanismSectionResultContextTest
+ {
+ [Test]
+ public void Constructor_DefaultValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanismMock = mocks.StrictMock();
+
+ var sectionResult = CreateFailureMechanismSectionResult();
+
+ mocks.ReplayAll();
+
+ // Call
+ var context = new FailureMechanismSectionResultContext(new[]
+ {
+ sectionResult
+ }, failureMechanismMock);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ sectionResult
+ }, context.SectionResults);
+ Assert.AreSame(failureMechanismMock, context.FailureMechanism);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_FailureMechanismSectionResultListNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanismMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new FailureMechanismSectionResultContext(null, failureMechanismMock);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("sectionResults", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var sectionResult = CreateFailureMechanismSectionResult();
+
+ // Call
+ TestDelegate call = () => new FailureMechanismSectionResultContext(new[]
+ {
+ sectionResult
+ }, null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ private static FailureMechanismSectionResult CreateFailureMechanismSectionResult()
+ {
+ var points = new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(3, 4)
+ };
+
+ var section = new FailureMechanismSection("test", points);
+ var sectionResult = new FailureMechanismSectionResult(section);
+ return sectionResult;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -60,6 +60,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs
===================================================================
diff -u -r6f069737c5a49402fc344e4f7e350c6d869b69f2 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs (.../FailureMechanismResultViewTest.cs) (revision 6f069737c5a49402fc344e4f7e350c6d869b69f2)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs (.../FailureMechanismResultViewTest.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -20,6 +20,7 @@
// All rights reserved.
using System.Collections.Generic;
+using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base.Geometry;
@@ -64,7 +65,7 @@
public void Constructor_DataGridViewCorrectlyInitialized()
{
// Call
- var failureMechanismResultView = ShowFailureMechanismResultsView();
+ ShowFailureMechanismResultsView();
// Assert
var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
@@ -85,7 +86,7 @@
}
[Test]
- public void Data_SetPipingFailureMechanismSectionResultListData_DataSet()
+ public void Data_SetFailureMechanismSectionResultListData_DataSet()
{
// Setup
var points = new[]
@@ -107,7 +108,7 @@
}
[Test]
- public void Data_SetOtherThanPipingFailureMechanismSectionResultListData_DataNull()
+ public void Data_SetOtherThanFailureMechanismSectionResultListData_DataNull()
{
// Setup
var testData = new object();
@@ -121,10 +122,10 @@
}
[Test]
- public void PipingFailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized()
+ public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized()
{
// Setup & Call
- ShowFullyConfiguredPipingFailureMechanismResultsView();
+ ShowFullyConfiguredFailureMechanismResultsView();
var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
@@ -149,13 +150,61 @@
Assert.AreEqual(string.Format("{0}", double.NaN), cells[assessmentLayerThreeIndex].FormattedValue);
}
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void FailureMechanismResultsView_ChangCheckBox_DataGridViewCorrectlySyncedAndStylingSet(bool checkBoxSelected)
+ {
+ // Setup
+ ShowFullyConfiguredFailureMechanismResultsView();
+
+ var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+
+ dataGridView.Rows[0].Cells[1].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);
+
+ if (checkBoxSelected)
+ {
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), cells[assessmentLayerTwoAIndex].Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), cells[assessmentLayerTwoAIndex].Style.ForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), cells[assessmentLayerTwoBIndex].Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), cells[assessmentLayerTwoBIndex].Style.ForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), cells[assessmentLayerThreeIndex].Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), cells[assessmentLayerThreeIndex].Style.ForeColor);
+ }
+ else
+ {
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), cells[assessmentLayerTwoAIndex].Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), cells[assessmentLayerTwoAIndex].Style.ForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), cells[assessmentLayerTwoBIndex].Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), cells[assessmentLayerTwoBIndex].Style.ForeColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), cells[assessmentLayerThreeIndex].Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), cells[assessmentLayerThreeIndex].Style.ForeColor);
+ }
+
+ Assert.AreEqual(checkBoxSelected, cells[assessmentLayerTwoAIndex].ReadOnly);
+ Assert.AreEqual(checkBoxSelected, cells[assessmentLayerTwoBIndex].ReadOnly);
+ Assert.AreEqual(checkBoxSelected, cells[assessmentLayerThreeIndex].ReadOnly);
+ }
+
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 FailureMechanismResultView ShowFullyConfiguredPipingFailureMechanismResultsView()
+ private FailureMechanismResultView ShowFullyConfiguredFailureMechanismResultsView()
{
var failureMechanism = new SimpleFailureMechanism();
@@ -171,10 +220,11 @@
new Point2D(10.0, 0.0)
}));
- var pipingFailureMechanismResultView = ShowFailureMechanismResultsView();
- pipingFailureMechanismResultView.Data = failureMechanism.SectionResults;
+ var failureMechanismResultView = ShowFailureMechanismResultsView();
+ failureMechanismResultView.Data = failureMechanism.SectionResults;
+ failureMechanismResultView.FailureMechanism = failureMechanism;
- return pipingFailureMechanismResultView;
+ return failureMechanismResultView;
}
private class SimpleFailureMechanism : BaseFailureMechanism
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismResultViewInfoTest.cs
===================================================================
diff -u -r2c58a8ed345659c071f1531edb80bf6fc9e4f913 -rd49b0c7df08ca616edb5c3945adbb22eab479bf7
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismResultViewInfoTest.cs (.../FailureMechanismResultViewInfoTest.cs) (revision 2c58a8ed345659c071f1531edb80bf6fc9e4f913)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismResultViewInfoTest.cs (.../FailureMechanismResultViewInfoTest.cs) (revision d49b0c7df08ca616edb5c3945adbb22eab479bf7)
@@ -44,7 +44,7 @@
{
mocks = new MockRepository();
plugin = new RingtoetsGuiPlugin();
- info = Enumerable.First(plugin.GetViewInfos(), tni => tni.ViewType == typeof(FailureMechanismResultView));
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(FailureMechanismResultView));
}
[TearDown]
@@ -93,6 +93,36 @@
}
[Test]
+ public void ViewType_Always_ReturnsViewType()
+ {
+ // Call
+ var viewType = info.ViewType;
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismResultView), viewType);
+ }
+
+ [Test]
+ public void DataType_Always_ReturnsDataType()
+ {
+ // Call
+ var dataType = info.DataType;
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), dataType);
+ }
+
+ [Test]
+ public void ViewDataType_Always_ReturnsViewDataType()
+ {
+ // Call
+ var viewDataType = info.ViewDataType;
+
+ // Assert
+ Assert.AreEqual(typeof(IEnumerable), viewDataType);
+ }
+
+ [Test]
public void Image_Always_ReturnsGenericInputOutputIcon()
{
// Call
@@ -169,6 +199,25 @@
Assert.IsTrue(closeForData);
}
+ [Test]
+ public void AfterCreate_Always_SetsSpecificPropertiesToView()
+ {
+ // Setup
+ var viewMock = mocks.StrictMock();
+ var failureMechanism = new SimpleFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism);
+
+ viewMock.Expect(v => v.FailureMechanism = failureMechanism);
+
+ mocks.ReplayAll();
+
+ // Call
+ info.AfterCreate(viewMock, context);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
private class SimpleFailureMechanism : BaseFailureMechanism
{
public SimpleFailureMechanism() : base("simple failure mechanism") {}