Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/AssessmentSectionHelper.cs
===================================================================
diff -u -r22698a70d1838fdba7389a33eb2ad47be945249f -rc003f01e1166d2272e102ab6b37dedf7716cd2f9
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/AssessmentSectionHelper.cs (.../AssessmentSectionHelper.cs) (revision 22698a70d1838fdba7389a33eb2ad47be945249f)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/AssessmentSectionHelper.cs (.../AssessmentSectionHelper.cs) (revision c003f01e1166d2272e102ab6b37dedf7716cd2f9)
@@ -34,43 +34,21 @@
public static class AssessmentSectionHelper
{
///
- /// Creates a stub of without the set.
+ /// Creates a stub of .
///
- /// The failure mechanism to set the contribution for.
/// The mock repository to create the stub with.
+ /// The failure mechanism to set the contribution for (optional).
+ /// The file path to the hydraulic boundary database (optional).
/// A stubbed .
- public static IAssessmentSection CreateAssessmentSectionStubWithoutBoundaryDatabase(IFailureMechanism failureMechanism,
- MockRepository mockRepository)
- {
- return CreateAssessmentSectionStub(failureMechanism, mockRepository, false, null);
- }
-
- ///
- /// Creates a stub of with the set.
- ///
- /// The failure mechanism to set the contribution for.
- /// The mock repository to create the stub with.
- /// The file path to the hydraulic boundary database.
- /// A stubbed .
- public static IAssessmentSection CreateAssessmentSectionStub(IFailureMechanism failureMechanism,
- MockRepository mockRepository,
+ /// When is provided, a dummy location with id 1300001 is added to the
+ /// hydraulic boundary database too.
+ public static IAssessmentSection CreateAssessmentSectionStub(MockRepository mockRepository,
+ IFailureMechanism failureMechanism = null,
string filePath = null)
{
- return CreateAssessmentSectionStub(failureMechanism, mockRepository, true, filePath);
- }
+ IFailureMechanism[] failureMechanisms = GetFailureMechanisms(failureMechanism);
+ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = GetHydraulicBoundaryDatabase(filePath);
- private static IAssessmentSection CreateAssessmentSectionStub(IFailureMechanism failureMechanism,
- MockRepository mockRepository,
- bool addBoundaryDatabase,
- string filePath)
- {
- IFailureMechanism[] failureMechanisms = failureMechanism == null
- ? Enumerable.Empty().ToArray()
- : new[]
- {
- failureMechanism
- };
-
var assessmentSection = mockRepository.Stub();
assessmentSection.Stub(a => a.Id).Return("21");
assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(
@@ -79,22 +57,34 @@
0.1,
1.0 / 30000));
assessmentSection.Stub(a => a.GetFailureMechanisms()).Return(failureMechanisms);
+ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);
- if (addBoundaryDatabase)
- {
- var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
- {
- FilePath = filePath,
- Locations =
- {
- new HydraulicBoundaryLocation(1300001, string.Empty, 0, 0)
- }
- };
+ assessmentSection.Replay();
- assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);
+ return assessmentSection;
+ }
+
+ private static IFailureMechanism[] GetFailureMechanisms(IFailureMechanism failureMechanism)
+ {
+ return failureMechanism == null
+ ? Enumerable.Empty().ToArray()
+ : new[]
+ {
+ failureMechanism
+ };
+ }
+
+ private static HydraulicBoundaryDatabase GetHydraulicBoundaryDatabase(string filePath)
+ {
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+
+ if (!string.IsNullOrEmpty(filePath))
+ {
+ hydraulicBoundaryDatabase.FilePath = filePath;
+ hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(1300001, string.Empty, 0, 0));
}
- return assessmentSection;
+ return hydraulicBoundaryDatabase;
}
}
}
\ No newline at end of file