Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs =================================================================== diff -u -rb19067a9e44fb765a082ccc252bc786827b9e350 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision b19067a9e44fb765a082ccc252bc786827b9e350) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -1475,6 +1475,7 @@ // Assert Assert.AreEqual(sourcePath, failureMechanism.HeightStructures.SourcePath); + Assert.IsEmpty(failureMechanism.HeightStructures); } #endregion Index: Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs =================================================================== diff -u -rce24d4fc808e32e5cebe7114ab03919770240d07 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs (.../StructureBase.cs) (revision ce24d4fc808e32e5cebe7114ab03919770240d07) +++ Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs (.../StructureBase.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -131,7 +131,7 @@ } Name = fromStructure.Name; - Location = fromStructure.Location; + Location = new Point2D(fromStructure.Location.X, fromStructure.Location.Y); StructureNormalOrientation = fromStructure.StructureNormalOrientation; } Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/StructuresImporter.cs =================================================================== diff -u -r14a2ddce690d976333b925febdd04fb974e08e49 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/StructuresImporter.cs (.../StructuresImporter.cs) (revision 14a2ddce690d976333b925febdd04fb974e08e49) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/StructuresImporter.cs (.../StructuresImporter.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -113,7 +113,6 @@ /// /// The read structure locations. /// The read structure parameters, grouped by location identifier. - /// The created structures. /// Thrown when the validation of the structure fails. protected abstract void CreateSpecificStructures(ICollection structureLocations, Dictionary> groupedStructureParameterRows); Index: Ringtoets/Common/src/Ringtoets.Common.IO/Structures/IStructureUpdateStrategy.cs =================================================================== diff -u -r8b389428ece343431969fce2e902a7b241f2b372 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/Common/src/Ringtoets.Common.IO/Structures/IStructureUpdateStrategy.cs (.../IStructureUpdateStrategy.cs) (revision 8b389428ece343431969fce2e902a7b241f2b372) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Structures/IStructureUpdateStrategy.cs (.../IStructureUpdateStrategy.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -34,7 +34,8 @@ public interface IStructureUpdateStrategy where TStructure : StructureBase { /// - /// Adds the imported data to the . + /// Updates the and its dependent data with data + /// from . /// /// The target collection which needs to be updated. /// The imported structures. Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs =================================================================== diff -u -rce24d4fc808e32e5cebe7114ab03919770240d07 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs (.../StructureBaseTest.cs) (revision ce24d4fc808e32e5cebe7114ab03919770240d07) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs (.../StructureBaseTest.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -199,24 +199,29 @@ { Name = "aName", Id = "anId", - Location = new Point2D(0, 0) + Location = new Point2D(0, 0), + StructureNormalOrientation = RoundedDouble.NaN }); var otherStructure = new TestStructure(new StructureBase.ConstructionProperties { Name = "otherName", Id = "otherId", - Location = new Point2D(1, 1) + Location = new Point2D(1, 1), + StructureNormalOrientation = (RoundedDouble) 89 }); // Call structure.CopyProperties(otherStructure); // Assert - Assert.AreNotEqual(structure.Id, otherStructure.Id); - Assert.AreEqual(structure.Name, otherStructure.Name); - Assert.AreEqual(structure.Location, otherStructure.Location); - Assert.AreEqual(structure.StructureNormalOrientation, otherStructure.StructureNormalOrientation); + Assert.AreNotEqual(otherStructure.Id, structure.Id); + Assert.AreEqual(otherStructure.Name, structure.Name); + Assert.AreEqual(otherStructure.Location, structure.Location); + Assert.AreEqual(otherStructure.StructureNormalOrientation, structure.StructureNormalOrientation); + + Assert.AreNotSame(otherStructure.Location, structure.Location); + Assert.AreNotSame(otherStructure.StructureNormalOrientation, structure.StructureNormalOrientation); } [Test] Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -rb6c01797d9fc7112c4106a08c41c82534fe8b62d -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision b6c01797d9fc7112c4106a08c41c82534fe8b62d) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -100,8 +100,8 @@ Name = RingtoetsCommonFormsResources.StructuresImporter_DisplayName, Category = RingtoetsCommonFormsResources.Ringtoets_Category, Image = RingtoetsCommonFormsResources.StructuresIcon, - IsEnabled = IsHeightStructuresImporterEnabled, - FileFilterGenerator = HeightStructureFileFilter(), + IsEnabled = IsHeightStructuresImportEnabled, + FileFilterGenerator = CreateHeightStructureFileFilter(), CreateFileImporter = (context, filePath) => CreateHeightStructuresImporter( context, filePath, new ImportMessageProvider(), new HeightStructureReplaceDataStrategy(context.FailureMechanism)), VerifyUpdates = context => VerifyHeightStructuresShouldUpdate(context, Resources.HeightStructuresPlugin_VerifyHeightStructuresShouldUpdate_When_importing_Calculation_with_Structure_data_output_will_be_cleared_confirm) @@ -124,8 +124,8 @@ Name = RingtoetsCommonDataResources.StructureCollection_TypeDescriptor, Category = RingtoetsCommonFormsResources.Ringtoets_Category, Image = RingtoetsCommonFormsResources.StructuresIcon, - IsEnabled = IsHeightStructuresImporterEnabled, - FileFilterGenerator = HeightStructureFileFilter(), + IsEnabled = context => context.WrappedData.SourcePath != null, + FileFilterGenerator = CreateHeightStructureFileFilter(), CreateFileImporter = (context, filePath) => CreateHeightStructuresImporter( context, filePath, new UpdateMessageProvider(), new HeightStructureUpdateDataStrategy(context.FailureMechanism)), CurrentPath = context => context.WrappedData.SourcePath, @@ -216,7 +216,7 @@ ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), ChildNodeObjects = context => context.WrappedData.Cast().ToArray(), - ContextMenuStrip = HeightStructuresContextContextMenuStrip + ContextMenuStrip = CreateHeightStructuresContextContextMenuStrip }; yield return new TreeNodeInfo @@ -374,8 +374,8 @@ #region HeightStructuresContext TreeNodeInfo - private ContextMenuStrip HeightStructuresContextContextMenuStrip(HeightStructuresContext nodeData, - object parentData, TreeViewControl treeViewControl) + private ContextMenuStrip CreateHeightStructuresContextContextMenuStrip(HeightStructuresContext nodeData, + object parentData, TreeViewControl treeViewControl) { return Gui.Get(nodeData, treeViewControl) .AddImportItem() @@ -878,12 +878,12 @@ filePath, messageProvider, strategy); } - private static bool IsHeightStructuresImporterEnabled(HeightStructuresContext context) + private static bool IsHeightStructuresImportEnabled(HeightStructuresContext context) { return context.AssessmentSection.ReferenceLine != null; } - private static FileFilterGenerator HeightStructureFileFilter() + private static FileFilterGenerator CreateHeightStructureFileFilter() { return new FileFilterGenerator(RingtoetsCommonIOResources.Shape_file_filter_Extension, RingtoetsCommonIOResources.Shape_file_filter_Description); Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresDataSynchronizationService.cs =================================================================== diff -u -r8b389428ece343431969fce2e902a7b241f2b372 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresDataSynchronizationService.cs (.../HeightStructuresDataSynchronizationService.cs) (revision 8b389428ece343431969fce2e902a7b241f2b372) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresDataSynchronizationService.cs (.../HeightStructuresDataSynchronizationService.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -122,8 +122,8 @@ } /// - /// Removes the given height structure and all dependent data, either directly or indirectly, - /// from the . + /// Removes the given and all dependent data, either directly + /// or indirectly, from the . /// /// The failure mechanism containing . /// The structure to be removed. @@ -137,9 +137,9 @@ .Where(c => ReferenceEquals(c.InputParameters.Structure, structure)) .ToArray(); - HashSet changedObservables = RemoveStructureDependentData(failureMechanism, - calculationWithRemovedHeightStructure, - heightStructureCalculations); + ICollection changedObservables = RemoveStructureDependentData(failureMechanism, + calculationWithRemovedHeightStructure, + heightStructureCalculations); failureMechanism.HeightStructures.Remove(structure); changedObservables.Add(failureMechanism.HeightStructures); @@ -169,19 +169,19 @@ .Where(c => c.InputParameters.Structure != null) .ToArray(); - HashSet changedObservables = RemoveStructureDependentData(failureMechanism, - calculationWithRemovedHeightStructure, - heightStructureCalculations); + ICollection changedObservables = RemoveStructureDependentData(failureMechanism, + calculationWithRemovedHeightStructure, + heightStructureCalculations); failureMechanism.HeightStructures.Clear(); changedObservables.Add(failureMechanism.HeightStructures); return changedObservables; } - private static HashSet RemoveStructureDependentData(HeightStructuresFailureMechanism failureMechanism, - StructuresCalculation[] calculationWithRemovedHeightStructure, - StructuresCalculation[] heightStructureCalculations) + private static ICollection RemoveStructureDependentData(HeightStructuresFailureMechanism failureMechanism, + StructuresCalculation[] calculationWithRemovedHeightStructure, + StructuresCalculation[] heightStructureCalculations) { var changedObservables = new HashSet(); foreach (StructuresCalculation calculation in calculationWithRemovedHeightStructure) Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructureTest.cs =================================================================== diff -u -rce24d4fc808e32e5cebe7114ab03919770240d07 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructureTest.cs (.../HeightStructureTest.cs) (revision ce24d4fc808e32e5cebe7114ab03919770240d07) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructureTest.cs (.../HeightStructureTest.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -331,6 +331,7 @@ public void CopyProperties_FromStructure_UpdatesProperties() { // Setup + var random = new Random(123); var structure = new HeightStructure(new HeightStructure.ConstructionProperties { Name = "aName", @@ -342,39 +343,73 @@ { Name = "otherName", Id = "otherId", - Location = new Point2D(1, 1) + Location = new Point2D(1, 1), + StructureNormalOrientation = (RoundedDouble) random.Next(), + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) random.Next(), + Shift = (RoundedDouble) random.NextDouble(), + StandardDeviation = (RoundedDouble) random.NextDouble() + }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) random.Next(), + CoefficientOfVariation = (RoundedDouble) random.NextDouble() + }, + FailureProbabilityStructureWithErosion = random.NextDouble(), + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) random.Next(), + Shift = (RoundedDouble) random.NextDouble(), + StandardDeviation = (RoundedDouble) random.NextDouble() + }, + LevelCrestStructure = + { + Mean = (RoundedDouble) random.Next(), + StandardDeviation = (RoundedDouble) random.NextDouble() + }, + StorageStructureArea = + { + Mean = (RoundedDouble) random.Next(), + CoefficientOfVariation = (RoundedDouble) random.NextDouble() + }, + WidthFlowApertures = + { + Mean = (RoundedDouble) random.Next(), + StandardDeviation = (RoundedDouble) random.NextDouble() + } }); // Call structure.CopyProperties(otherStructure); // Assert - Assert.AreNotEqual(structure.Id, otherStructure.Id); - Assert.AreEqual(structure.Name, otherStructure.Name); - Assert.AreEqual(structure.Location, otherStructure.Location); - Assert.AreEqual(structure.StructureNormalOrientation, otherStructure.StructureNormalOrientation); + Assert.AreNotEqual(otherStructure.Id, structure.Id); + Assert.AreEqual(otherStructure.Name, structure.Name); + Assert.AreEqual(otherStructure.Location, structure.Location); + Assert.AreEqual(otherStructure.StructureNormalOrientation, structure.StructureNormalOrientation); - Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Mean, structure.AllowedLevelIncreaseStorage.Mean); - Assert.AreEqual(structure.AllowedLevelIncreaseStorage.StandardDeviation, structure.AllowedLevelIncreaseStorage.StandardDeviation); - Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Shift, structure.AllowedLevelIncreaseStorage.Shift); + Assert.AreEqual(otherStructure.AllowedLevelIncreaseStorage.Mean, structure.AllowedLevelIncreaseStorage.Mean); + Assert.AreEqual(otherStructure.AllowedLevelIncreaseStorage.StandardDeviation, structure.AllowedLevelIncreaseStorage.StandardDeviation); + Assert.AreEqual(otherStructure.AllowedLevelIncreaseStorage.Shift, structure.AllowedLevelIncreaseStorage.Shift); - Assert.AreEqual(structure.CriticalOvertoppingDischarge.Mean, structure.CriticalOvertoppingDischarge.Mean); - Assert.AreEqual(structure.CriticalOvertoppingDischarge.CoefficientOfVariation, structure.CriticalOvertoppingDischarge.CoefficientOfVariation); + Assert.AreEqual(otherStructure.CriticalOvertoppingDischarge.Mean, structure.CriticalOvertoppingDischarge.Mean); + Assert.AreEqual(otherStructure.CriticalOvertoppingDischarge.CoefficientOfVariation, structure.CriticalOvertoppingDischarge.CoefficientOfVariation); - Assert.AreEqual(structure.FailureProbabilityStructureWithErosion, structure.FailureProbabilityStructureWithErosion); + Assert.AreEqual(otherStructure.FailureProbabilityStructureWithErosion, structure.FailureProbabilityStructureWithErosion); - Assert.AreEqual(structure.FlowWidthAtBottomProtection.Mean, structure.FlowWidthAtBottomProtection.Mean); - Assert.AreEqual(structure.FlowWidthAtBottomProtection.StandardDeviation, structure.FlowWidthAtBottomProtection.StandardDeviation); - Assert.AreEqual(structure.FlowWidthAtBottomProtection.Shift, structure.FlowWidthAtBottomProtection.Shift); + Assert.AreEqual(otherStructure.FlowWidthAtBottomProtection.Mean, structure.FlowWidthAtBottomProtection.Mean); + Assert.AreEqual(otherStructure.FlowWidthAtBottomProtection.StandardDeviation, structure.FlowWidthAtBottomProtection.StandardDeviation); + Assert.AreEqual(otherStructure.FlowWidthAtBottomProtection.Shift, structure.FlowWidthAtBottomProtection.Shift); - Assert.AreEqual(structure.LevelCrestStructure.Mean, structure.LevelCrestStructure.Mean); - Assert.AreEqual(structure.LevelCrestStructure.StandardDeviation, structure.LevelCrestStructure.StandardDeviation); + Assert.AreEqual(otherStructure.LevelCrestStructure.Mean, structure.LevelCrestStructure.Mean); + Assert.AreEqual(otherStructure.LevelCrestStructure.StandardDeviation, structure.LevelCrestStructure.StandardDeviation); - Assert.AreEqual(structure.StorageStructureArea.Mean, structure.StorageStructureArea.Mean); - Assert.AreEqual(structure.StorageStructureArea.CoefficientOfVariation, structure.StorageStructureArea.CoefficientOfVariation); + Assert.AreEqual(otherStructure.StorageStructureArea.Mean, structure.StorageStructureArea.Mean); + Assert.AreEqual(otherStructure.StorageStructureArea.CoefficientOfVariation, structure.StorageStructureArea.CoefficientOfVariation); - Assert.AreEqual(structure.WidthFlowApertures.Mean, structure.WidthFlowApertures.Mean); - Assert.AreEqual(structure.WidthFlowApertures.StandardDeviation, structure.WidthFlowApertures.StandardDeviation); + Assert.AreEqual(otherStructure.WidthFlowApertures.Mean, structure.WidthFlowApertures.Mean); + Assert.AreEqual(otherStructure.WidthFlowApertures.StandardDeviation, structure.WidthFlowApertures.StandardDeviation); } [Test] Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/UpdateInfos/HeightStructuresContextUpdateInfoTest.cs =================================================================== diff -u -rbc752890b4f52991a673a59c089db400be0e6fc3 -r2f41eb6eb560911cd4ebe2d4d6924c26df911c40 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/UpdateInfos/HeightStructuresContextUpdateInfoTest.cs (.../HeightStructuresContextUpdateInfoTest.cs) (revision bc752890b4f52991a673a59c089db400be0e6fc3) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/UpdateInfos/HeightStructuresContextUpdateInfoTest.cs (.../HeightStructuresContextUpdateInfoTest.cs) (revision 2f41eb6eb560911cd4ebe2d4d6924c26df911c40) @@ -91,7 +91,7 @@ } [Test] - public void IsEnabled_ReferenceLineNull_ReturnFalse() + public void IsEnabled_SourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); @@ -112,17 +112,16 @@ } [Test] - public void IsEnabled_ReferenceLineSet_ReturnTrue() + public void IsEnabled_SourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - assessmentSection.ReferenceLine = new ReferenceLine(); - var failureMechanism = new HeightStructuresFailureMechanism(); var structures = new StructureCollection(); + structures.AddRange(Enumerable.Empty(), "some path"); var context = new HeightStructuresContext(structures, failureMechanism, assessmentSection);