Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -re7b22b417acc51a88beb210ba39fef0f75e2760e -r242268fc2adc055cc3ac4f28b14b4db26251b30e --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision e7b22b417acc51a88beb210ba39fef0f75e2760e) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 242268fc2adc055cc3ac4f28b14b4db26251b30e) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; using NUnit.Framework; @@ -32,6 +33,7 @@ using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Data.TestUtil; using Ringtoets.HeightStructures.Forms.PresentationObjects; @@ -70,16 +72,20 @@ [Test] public void Constructor_WithoutData_ExpectedValues() { + // Setup + var handler = mockRepository.Stub(); + mockRepository.ReplayAll(); + // Call - TestDelegate test = () => new HeightStructuresInputContextProperties(null); + TestDelegate test = () => new HeightStructuresInputContextProperties(null, handler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("data", paramName); } [Test] - public void Constructor_WithData_ExpectedValues() + public void Constructor_WithoutHandler_ExpectedValues() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -94,9 +100,33 @@ assessmentSectionStub); // Call - var properties = new HeightStructuresInputContextProperties(inputContext); + TestDelegate test = () => new HeightStructuresInputContextProperties(inputContext, null); // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("propertyChangeHandler", paramName); + } + + [Test] + public void Constructor_WithDataAndHandler_ExpectedValues() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + + var inputContext = new HeightStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + + // Call + var properties = new HeightStructuresInputContextProperties(inputContext, handler); + + // Assert Assert.IsInstanceOf, HeightStructuresFailureMechanism>>(properties); Assert.AreSame(inputContext, properties.Data); @@ -111,6 +141,7 @@ { // Setup var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -121,7 +152,7 @@ assessmentSectionStub); // Call - var properties = new HeightStructuresInputContextProperties(inputContext); + var properties = new HeightStructuresInputContextProperties(inputContext, handler); // Assert const string schematizationCategory = "Schematisatie"; @@ -164,6 +195,7 @@ { // Setup var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism @@ -178,7 +210,7 @@ calculation, failureMechanism, assessmentSectionStub); - var properties = new HeightStructuresInputContextProperties(inputContext); + var properties = new HeightStructuresInputContextProperties(inputContext, handler); // Call var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles(); @@ -193,6 +225,7 @@ { // Setup var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism @@ -207,7 +240,7 @@ calculation, failureMechanism, assessmentSectionStub); - var properties = new HeightStructuresInputContextProperties(inputContext); + var properties = new HeightStructuresInputContextProperties(inputContext, handler); // Call var availableStructures = properties.GetAvailableStructures(); @@ -230,8 +263,15 @@ calculation, failureMechanism, assessmentSectionStub); - var properties = new HeightStructuresInputContextProperties(inputContext); + var newStructure = new TestHeightStructure(); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester( + calculation.InputParameters, + calculation, + newStructure, + Enumerable.Empty()); + var properties = new HeightStructuresInputContextProperties(inputContext, handler); + failureMechanism.AddSection(new FailureMechanismSection("Section", new List { new Point2D(-10.0, -10.0), @@ -240,7 +280,7 @@ failureMechanism.CalculationsGroup.Children.Add(calculation); // Call - properties.Structure = new TestHeightStructure(); + properties.Structure = newStructure; // Assert Assert.AreSame(calculation, failureMechanism.SectionResults.ElementAt(0).Calculation);