Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsContext.cs =================================================================== diff -u -r71fda574a476b830bd4b767b624fb52426658701 -r6eba4a9d9763f1177d692dd9c557714df1de802b --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsContext.cs (.../DuneLocationCalculationsContext.cs) (revision 71fda574a476b830bd4b767b624fb52426658701) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsContext.cs (.../DuneLocationCalculationsContext.cs) (revision 6eba4a9d9763f1177d692dd9c557714df1de802b) @@ -35,14 +35,20 @@ /// /// Creates a new instance of . /// - /// The dune locations for dune erosion failure mechanism. + /// The calculations the context belongs to. /// The dune erosion failure mechanism which the calculations belong to. /// The assessment section the calculations belong to. - /// Thrown when any input argument is null. - public DuneLocationCalculationsContext(IObservableEnumerable duneLocations, + /// for obtaining the norm to use during calculations. + /// The name of the category boundary. + /// Thrown when , , + /// or is null. + /// Thrown when is null or empty. + public DuneLocationCalculationsContext(IObservableEnumerable wrappedData, DuneErosionFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) - : base(duneLocations) + IAssessmentSection assessmentSection, + Func getNormFunc, + string categoryBoundaryName) + : base(wrappedData) { if (failureMechanism == null) { @@ -54,8 +60,20 @@ throw new ArgumentNullException(nameof(assessmentSection)); } + if (getNormFunc == null) + { + throw new ArgumentNullException(nameof(getNormFunc)); + } + + if (string.IsNullOrEmpty(categoryBoundaryName)) + { + throw new ArgumentException($"'{nameof(categoryBoundaryName)}' must have a value."); + } + AssessmentSection = assessmentSection; FailureMechanism = failureMechanism; + GetNormFunc = getNormFunc; + CategoryBoundaryName = categoryBoundaryName; } /// @@ -67,5 +85,15 @@ /// Gets the failure mechanism. /// public DuneErosionFailureMechanism FailureMechanism { get; } + + /// + /// Gets the for obtaining the norm to use during calculations. + /// + public Func GetNormFunc { get; } + + /// + /// Gets the name of the category boundary. + /// + public string CategoryBoundaryName { get; } } } \ No newline at end of file Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsContextTest.cs =================================================================== diff -u -r71fda574a476b830bd4b767b624fb52426658701 -r6eba4a9d9763f1177d692dd9c557714df1de802b --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsContextTest.cs (.../DuneLocationCalculationsContextTest.cs) (revision 71fda574a476b830bd4b767b624fb52426658701) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsContextTest.cs (.../DuneLocationCalculationsContextTest.cs) (revision 6eba4a9d9763f1177d692dd9c557714df1de802b) @@ -43,15 +43,23 @@ var failureMechanism = new DuneErosionFailureMechanism(); var duneLocationCalculations = new ObservableList(); + Func getNormFunc = () => 0.01; + const string categoryBoundaryName = "Name"; // Call - var context = new DuneLocationCalculationsContext(duneLocationCalculations, failureMechanism, assessmentSection); + var context = new DuneLocationCalculationsContext(duneLocationCalculations, + failureMechanism, + assessmentSection, + getNormFunc, + categoryBoundaryName); // Assert Assert.IsInstanceOf>>(context); Assert.AreSame(duneLocationCalculations, context.WrappedData); Assert.AreSame(failureMechanism, context.FailureMechanism); Assert.AreSame(assessmentSection, context.AssessmentSection); + Assert.AreSame(getNormFunc, context.GetNormFunc); + Assert.AreSame(categoryBoundaryName, context.CategoryBoundaryName); mockRepository.VerifyAll(); } @@ -66,7 +74,9 @@ // Call TestDelegate call = () => new DuneLocationCalculationsContext(new ObservableList(), null, - assessmentSection); + assessmentSection, + () => 0.01, + "Name"); // Assert string paramName = Assert.Throws(call).ParamName; @@ -80,11 +90,75 @@ // Call TestDelegate call = () => new DuneLocationCalculationsContext(new ObservableList(), new DuneErosionFailureMechanism(), - null); + null, + () => 0.01, + "Name"); // Assert string paramName = Assert.Throws(call).ParamName; Assert.AreEqual("assessmentSection", paramName); } + + [Test] + public void Constructor_GetNormFuncNull_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + TestDelegate call = () => new DuneLocationCalculationsContext(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection, + null, + "Name"); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("getNormFunc", exception.ParamName); + + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_CategoryBoundaryNameNull_ThrowsArgumentException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + TestDelegate call = () => new DuneLocationCalculationsContext(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection, + () => 0.01, + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("'categoryBoundaryName' must have a value.", exception.Message); + } + + [Test] + public void Constructor_CategoryBoundaryNameEmpty_ThrowsArgumentException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + TestDelegate call = () => new DuneLocationCalculationsContext(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection, + () => 0.01, + string.Empty); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("'categoryBoundaryName' must have a value.", exception.Message); + } } } \ No newline at end of file