Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingFailureMechanismSectionResultContext.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingFailureMechanismSectionResultContext.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingFailureMechanismSectionResultContext.cs (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -0,0 +1,62 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Piping.Data;
+
+namespace Ringtoets.Piping.Forms.PresentationObjects
+{
+ ///
+ /// This class is a presentation object for a collection of
+ /// for piping.
+ ///
+ public class PipingFailureMechanismSectionResultContext : FailureMechanismSectionResultContext
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The of to wrap.
+ /// The the belongs to.
+ /// The assessment section the section results belong to.
+ /// Thrown when any parameter is null.
+ public PipingFailureMechanismSectionResultContext(IEnumerable wrappedSectionResults,
+ IFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ : base(wrappedSectionResults, failureMechanism)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ AssessmentSection = assessmentSection;
+ }
+
+ ///
+ /// Gets the .
+ ///
+ public IAssessmentSection AssessmentSection { get; }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj
===================================================================
diff -u -raf990fe02513d7cd12034e597037025ecf5aa948 -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision af990fe02513d7cd12034e597037025ecf5aa948)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -23,6 +23,7 @@
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs
===================================================================
diff -u -red08434acc8f5619842f1c6cb0b7f9a56cf8dad0 -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision ed08434acc8f5619842f1c6cb0b7f9a56cf8dad0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -42,13 +42,23 @@
private readonly RecursiveObserver calculationInputObserver;
private readonly RecursiveObserver calculationOutputObserver;
private readonly RecursiveObserver calculationGroupObserver;
- private IAssessmentSection assessmentSection;
+ private readonly IAssessmentSection assessmentSection;
///
/// Creates a new instance of .
///
- public PipingFailureMechanismResultView()
+ /// The assessment section that the failure mechanism belongs to.
+ /// Thrown when
+ /// is null.
+ public PipingFailureMechanismResultView(IAssessmentSection assessmentSection)
{
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ this.assessmentSection = assessmentSection;
+
DataGridViewControl.CellFormatting += ShowAssessmentLayerTwoAErrors;
DataGridViewControl.CellFormatting += DisableIrrelevantFieldsFormatting;
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs
===================================================================
diff -u -r171eda478707e1f059c568074c7be10ecc93abb8 -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 171eda478707e1f059c568074c7be10ecc93abb8)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -205,15 +205,16 @@
};
yield return new ViewInfo<
- FailureMechanismSectionResultContext,
+ PipingFailureMechanismSectionResultContext,
IEnumerable,
PipingFailureMechanismResultView>
{
GetViewName = (view, results) => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName,
Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon,
CloseForData = CloseFailureMechanismResultViewForData,
GetViewData = context => context.WrappedData,
- AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism
+ AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism,
+ CreateInstance = context => new PipingFailureMechanismResultView(context.AssessmentSection)
};
yield return new ViewInfo
@@ -268,7 +269,7 @@
PipingCalculationGroupContextContextMenuStrip,
PipingCalculationGroupContextOnNodeRemoved);
- yield return new TreeNodeInfo>
+ yield return new TreeNodeInfo
{
Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName,
Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon,
@@ -708,8 +709,7 @@
return new object[]
{
new PipingScenariosContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection),
- new FailureMechanismSectionResultContext(
- failureMechanism.SectionResults, failureMechanism),
+ new PipingFailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism, assessmentSection),
failureMechanism.OutputComments
};
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismSectionResultContextTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismSectionResultContextTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismSectionResultContextTest.cs (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -0,0 +1,70 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms.PresentationObjects;
+
+namespace Ringtoets.Piping.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class PipingFailureMechanismSectionResultContextTest
+ {
+ [Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new PipingFailureMechanismSectionResultContext(Enumerable.Empty(),
+ new PipingFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ IEnumerable sectionResults = Enumerable.Empty();
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ var context = new PipingFailureMechanismSectionResultContext(sectionResults, failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf>(context);
+ Assert.AreSame(sectionResults, context.WrappedData);
+ Assert.AreSame(failureMechanism, context.FailureMechanism);
+ Assert.AreSame(assessmentSection, context.AssessmentSection);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj
===================================================================
diff -u -raf990fe02513d7cd12034e597037025ecf5aa948 -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision af990fe02513d7cd12034e597037025ecf5aa948)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -28,6 +28,7 @@
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs
===================================================================
diff -u -red08434acc8f5619842f1c6cb0b7f9a56cf8dad0 -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision ed08434acc8f5619842f1c6cb0b7f9a56cf8dad0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -19,6 +19,7 @@
// 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;
@@ -29,7 +30,10 @@
using Core.Common.TestUtil;
using NUnit.Extensions.Forms;
using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Data.TestUtil;
using Ringtoets.Piping.Forms.Views;
@@ -58,16 +62,34 @@
}
[Test]
- public void DefaultConstructor_DefaultValues()
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
{
// Call
- using (var view = new PipingFailureMechanismResultView())
+ TestDelegate call = () => new PipingFailureMechanismResultView(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ using (var view = new PipingFailureMechanismResultView(assessmentSection))
{
// Assert
Assert.IsInstanceOf(view);
Assert.IsInstanceOf(view);
Assert.IsNull(view.Data);
}
+
+ mocks.VerifyAll();
}
[Test]
@@ -525,7 +547,7 @@
private PipingFailureMechanismResultView ShowFailureMechanismResultsView()
{
- var failureMechanismResultView = new PipingFailureMechanismResultView();
+ var failureMechanismResultView = new PipingFailureMechanismResultView(new ObservableTestAssessmentSectionStub());
testForm.Controls.Add(failureMechanismResultView);
testForm.Show();
Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingFailureMechanismResultViewIntegrationTest.cs
===================================================================
diff -u -red08434acc8f5619842f1c6cb0b7f9a56cf8dad0 -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingFailureMechanismResultViewIntegrationTest.cs (.../PipingFailureMechanismResultViewIntegrationTest.cs) (revision ed08434acc8f5619842f1c6cb0b7f9a56cf8dad0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingFailureMechanismResultViewIntegrationTest.cs (.../PipingFailureMechanismResultViewIntegrationTest.cs) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -46,16 +46,17 @@
{
using (var form = new Form())
{
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
// Show the view
- var failureMechanismResultView = new PipingFailureMechanismResultView();
+ var failureMechanismResultView = new PipingFailureMechanismResultView(assessmentSection);
form.Controls.Add(failureMechanismResultView);
form.Show();
// Obtain the data grid view
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
// Set all necessary data to the view
- var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
failureMechanismResultView.Data = assessmentSection.Piping.SectionResults;
failureMechanismResultView.FailureMechanism = assessmentSection.Piping;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingFailureMechanismResultViewInfoTest.cs
===================================================================
diff -u -r3178e116f5e59e03078d465efeb303c5e232c7bf -rf4c4fe2feedd73d2f45395017b77df2bb56d5c27
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingFailureMechanismResultViewInfoTest.cs (.../PipingFailureMechanismResultViewInfoTest.cs) (revision 3178e116f5e59e03078d465efeb303c5e232c7bf)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingFailureMechanismResultViewInfoTest.cs (.../PipingFailureMechanismResultViewInfoTest.cs) (revision f4c4fe2feedd73d2f45395017b77df2bb56d5c27)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using Core.Common.Controls.Views;
using Core.Common.Gui.Plugin;
using Core.Common.TestUtil;
using NUnit.Framework;
@@ -85,15 +86,20 @@
public void GetViewName_Always_ReturnsViewName()
{
// Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
var failureMechanism = new PipingFailureMechanism();
- using (var view = new PipingFailureMechanismResultView())
+ using (var view = new PipingFailureMechanismResultView(assessmentSection))
{
// Call
string viewName = info.GetViewName(view, failureMechanism.SectionResults);
// Assert
Assert.AreEqual("Resultaat", viewName);
}
+
+ mocks.VerifyAll();
}
[Test]
@@ -146,7 +152,7 @@
var failureMechanism = new PipingFailureMechanism();
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -157,6 +163,7 @@
// Assert
Assert.IsFalse(closeForData);
}
+
mocks.VerifyAll();
}
@@ -176,7 +183,7 @@
var failureMechanism = new PipingFailureMechanism();
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -187,6 +194,7 @@
// Assert
Assert.IsFalse(closeForData);
}
+
mocks.VerifyAll();
}
@@ -205,7 +213,7 @@
mocks.ReplayAll();
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -216,16 +224,20 @@
// Assert
Assert.IsTrue(closeForData);
}
+
mocks.VerifyAll();
}
[Test]
public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue()
{
// Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
var failureMechanism = new PipingFailureMechanism();
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -236,14 +248,19 @@
// Assert
Assert.IsTrue(closeForData);
}
+
+ mocks.VerifyAll();
}
[Test]
public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse()
{
// Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
var failureMechanism = new PipingFailureMechanism();
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -254,6 +271,8 @@
// Assert
Assert.IsFalse(closeForData);
}
+
+ mocks.VerifyAll();
}
[Test]
@@ -265,7 +284,7 @@
var failureMechanism = new PipingFailureMechanism();
var failureMechanismContext = new PipingFailureMechanismContext(failureMechanism, assessmentSection);
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -276,6 +295,7 @@
// Assert
Assert.IsTrue(closeForData);
}
+
mocks.VerifyAll();
}
@@ -287,7 +307,7 @@
mocks.ReplayAll();
var failureMechanism = new PipingFailureMechanism();
- using (var view = new PipingFailureMechanismResultView
+ using (var view = new PipingFailureMechanismResultView(assessmentSection)
{
Data = failureMechanism.SectionResults
})
@@ -302,6 +322,7 @@
// Assert
Assert.IsFalse(closeForData);
}
+
mocks.VerifyAll();
}
@@ -310,7 +331,8 @@
{
// Setup
var failureMechanism = new PipingFailureMechanism();
- var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism);
+ var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults,
+ failureMechanism);
var view = mocks.StrictMock();
view.Expect(v => v.FailureMechanism = failureMechanism);
@@ -322,5 +344,21 @@
// Assert
mocks.VerifyAll();
}
+
+ [Test]
+ public void CreateInstance_Always_ReturnsView()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(failureMechanism.SectionResults,
+ failureMechanism);
+
+ // Call
+ IView view = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(view);
+ mocks.VerifyAll();
+ }
}
}
\ No newline at end of file