Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureReplaceDataStrategyTest.cs =================================================================== diff -u -rcda0b786ef4c81469fb4213e7fc82cb74493fcf9 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureReplaceDataStrategyTest.cs (.../ClosingStructureReplaceDataStrategyTest.cs) (revision cda0b786ef4c81469fb4213e7fc82cb74493fcf9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureReplaceDataStrategyTest.cs (.../ClosingStructureReplaceDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -140,6 +140,30 @@ } [Test] + public void UpdateStructuresWithImportedData_NoCurrentStructures_SetsSourcePath() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + var targetCollection = new StructureCollection(); + + var strategy = new ClosingStructureReplaceDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + targetCollection, + Enumerable.Empty(), + sourceFilePath); + + // Assert + CollectionAssert.IsEmpty(targetCollection); + CollectionAssert.AreEqual(new[] + { + targetCollection + }, affectedObjects); + Assert.AreEqual(sourceFilePath, targetCollection.SourcePath); + } + + [Test] public void UpdateStructuresWithImportedData_NoCurrentStructuresWithImportedData_AddsNewStructure() { // Setup Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs =================================================================== diff -u -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs (.../ClosingStructureUpdateDataStrategyTest.cs) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs (.../ClosingStructureUpdateDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -390,6 +390,133 @@ } [Test] + public void UpdateStructuresWithImportedData_CalculationWithRemovedStructure_UpdatesCalculation() + { + // Setup + const string sameId = "sameId"; + ClosingStructure structure = new TestClosingStructure(sameId, "original structure"); + + var calculation = new TestClosingStructuresCalculation + { + InputParameters = + { + Structure = structure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new ClosingStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + + StructureCollection targetDataCollection = + failureMechanism.ClosingStructures; + targetDataCollection.AddRange(new[] + { + structure + }, sourceFilePath); + + var strategy = new ClosingStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + targetDataCollection, + Enumerable.Empty(), + sourceFilePath); + + // Assert + Assert.IsFalse(calculation.HasOutput); + Assert.IsNull(calculation.InputParameters.Structure); + CollectionAssert.AreEqual(new IObservable[] + { + targetDataCollection, + calculation, + calculation.InputParameters + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_MultipleCalculationWithStructureOneWithRemovedStructure_OnlyUpdatesCalculationWithRemovedStructure() + { + // Setup + const string removedId = "affectedId"; + const string unaffectedId = "unaffectedId"; + const string unaffectedStructureName = "unaffectedStructure"; + var removedStructure = new TestClosingStructure(removedId, "Old name"); + var unaffectedStructure = new TestClosingStructure(unaffectedId, unaffectedStructureName); + + var affectedCalculation = new TestClosingStructuresCalculation + { + InputParameters = + { + Structure = removedStructure + }, + Output = new TestStructuresOutput() + }; + + var unaffectedCalculation = new TestClosingStructuresCalculation + { + InputParameters = + { + Structure = unaffectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new ClosingStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + unaffectedCalculation + } + } + }; + + StructureCollection targetDataCollection = failureMechanism.ClosingStructures; + targetDataCollection.AddRange(new[] + { + removedStructure, + unaffectedStructure + }, sourceFilePath); + + var strategy = new ClosingStructureUpdateDataStrategy(failureMechanism); + + ClosingStructure readUnaffectedStructure = new TestClosingStructure(unaffectedId, unaffectedStructureName); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetDataCollection, + new[] + { + readUnaffectedStructure + }, sourceFilePath); + // Assert + Assert.IsFalse(affectedCalculation.HasOutput); + Assert.IsNull(affectedCalculation.InputParameters.Structure); + + Assert.IsTrue(unaffectedCalculation.HasOutput); + ClosingStructure inputParametersUnaffectedStructure = unaffectedCalculation.InputParameters.Structure; + Assert.AreSame(unaffectedStructure, inputParametersUnaffectedStructure); + AssertClosingStructures(readUnaffectedStructure, inputParametersUnaffectedStructure); + + CollectionAssert.AreEquivalent(new IObservable[] + { + affectedCalculation, + affectedCalculation.InputParameters, + targetDataCollection + }, affectedObjects); + } + + [Test] public void UpdateStructuresWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculationInput() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/UpdateDataStrategyBaseTest.cs =================================================================== diff -u -r4e8fa8a9a88207029ec813bcf15f1eff9e0ab118 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/UpdateDataStrategyBaseTest.cs (.../UpdateDataStrategyBaseTest.cs) (revision 4e8fa8a9a88207029ec813bcf15f1eff9e0ab118) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/UpdateDataStrategyBaseTest.cs (.../UpdateDataStrategyBaseTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -128,7 +128,7 @@ } [Test] - public void UpdateTargetCollectionData_WithEmptyCollectionAndImportedData_DoesNothing() + public void UpdateTargetCollectionData_WithEmptyCollectionAndImportedData_SetsSourcePath() { // Setup var collection = new TestUniqueItemCollection(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs =================================================================== diff -u -rc6b6a1a125535151416a5426d75472d045943d1a -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs) (revision c6b6a1a125535151416a5426d75472d045943d1a) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -523,6 +523,69 @@ } [Test] + public void UpdateDikeProfilesWithImportedData_MultipleCalculationWithAssignedProfileOneRemovedProfile_OnlyUpdatesCalculationWithRemovedProfile() + { + // Setup + var removedProfile = new TestDikeProfile("Profile to be removed", "ID of removed profile"); + var affectedCalculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = removedProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + + const string unaffectedProfileName = "Unaffected Profile"; + const string unaffectedProfileId = "unaffected profile Id"; + var unaffectedProfile = new TestDikeProfile(unaffectedProfileName, unaffectedProfileId); + var unaffectedCalculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = unaffectedProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + DikeProfileCollection dikeProfiles = failureMechanism.DikeProfiles; + dikeProfiles.AddRange(new[] + { + removedProfile, + unaffectedProfile + }, sourceFilePath); + failureMechanism.CalculationsGroup.Children.Add(affectedCalculation); + failureMechanism.CalculationsGroup.Children.Add(unaffectedCalculation); + + var importedUnaffectedProfile = new TestDikeProfile(unaffectedProfileName, unaffectedProfileId); + + var strategy = new GrassCoverErosionInwardsDikeProfileUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateDikeProfilesWithImportedData(dikeProfiles, + new[] + { + importedUnaffectedProfile + }, sourceFilePath); + // Assert + Assert.IsTrue(unaffectedCalculation.HasOutput); + DikeProfile inputParametersUnaffectedDikeProfile = unaffectedCalculation.InputParameters.DikeProfile; + Assert.AreSame(unaffectedProfile, inputParametersUnaffectedDikeProfile); + AssertDikeProfile(unaffectedProfile, inputParametersUnaffectedDikeProfile); + + Assert.IsFalse(affectedCalculation.HasOutput); + Assert.IsNull(affectedCalculation.InputParameters.DikeProfile); + + CollectionAssert.AreEquivalent(new IObservable[] + { + affectedCalculation, + affectedCalculation.InputParameters, + dikeProfiles + }, affectedObjects); + } + + [Test] public void UpdateDikeProfilesWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculation() { // Setup Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureReplaceDataStrategyTest.cs =================================================================== diff -u -r8c97f59adda15f1eb2a4550a06d2f7fb8bee91bf -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureReplaceDataStrategyTest.cs (.../HeightStructureReplaceDataStrategyTest.cs) (revision 8c97f59adda15f1eb2a4550a06d2f7fb8bee91bf) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureReplaceDataStrategyTest.cs (.../HeightStructureReplaceDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -140,6 +140,30 @@ } [Test] + public void UpdateStructuresWithImportedData_NoCurrentStructures_SetsSourcePath() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + var targetCollection = new StructureCollection(); + + var strategy = new HeightStructureReplaceDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + targetCollection, + Enumerable.Empty(), + sourceFilePath); + + // Assert + CollectionAssert.IsEmpty(targetCollection); + CollectionAssert.AreEqual(new[] + { + targetCollection + }, affectedObjects); + Assert.AreEqual(sourceFilePath, targetCollection.SourcePath); + } + + [Test] public void UpdateStructuresWithImportedData_NoCurrentStructuresWithImportedData_AddsNewStructure() { // Setup Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs =================================================================== diff -u -r9b0d18547885c18342a9ab149538b137f0b004d0 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision 9b0d18547885c18342a9ab149538b137f0b004d0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -390,6 +390,132 @@ } [Test] + public void UpdateStructuresWithImportedData_CalculationWithRemovedStructure_UpdatesCalculation() + { + // Setup + const string removedId = "sameId"; + HeightStructure structure = new TestHeightStructure(removedId, "original structure"); + + var calculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = structure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + + StructureCollection targetDataCollection = + failureMechanism.HeightStructures; + targetDataCollection.AddRange(new[] + { + structure + }, sourceFilePath); + + var strategy = new HeightStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + targetDataCollection, + Enumerable.Empty(), + sourceFilePath); + + // Assert + Assert.IsFalse(calculation.HasOutput); + Assert.IsNull(calculation.InputParameters.Structure); + CollectionAssert.AreEqual(new IObservable[] + { + targetDataCollection, + calculation, + calculation.InputParameters + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_MultipleCalculationWithStructuresOneWithRemovedStructure_OnlyUpdatesCalculationWithRemovedStructure() + { + // Setup + const string removedId = "affectedId"; + const string unaffectedId = "unaffectedId"; + const string unaffectedStructureName = "unaffectedStructure"; + var removedStructure = new TestHeightStructure(removedId, "Old name"); + var unaffectedStructure = new TestHeightStructure(unaffectedId, unaffectedStructureName); + + var affectedCalculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = removedStructure + }, + Output = new TestStructuresOutput() + }; + + var unaffectedCalculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = unaffectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + unaffectedCalculation + } + } + }; + StructureCollection targetDataCollection = failureMechanism.HeightStructures; + targetDataCollection.AddRange(new[] + { + removedStructure, + unaffectedStructure + }, sourceFilePath); + + var strategy = new HeightStructureUpdateDataStrategy(failureMechanism); + + HeightStructure readUnaffectedStructure = new TestHeightStructure(unaffectedId, unaffectedStructureName); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetDataCollection, + new[] + { + readUnaffectedStructure + }, sourceFilePath); + // Assert + Assert.IsFalse(affectedCalculation.HasOutput); + Assert.IsNull(affectedCalculation.InputParameters.Structure); + + Assert.IsTrue(unaffectedCalculation.HasOutput); + HeightStructure inputParametersUnaffectedStructure = unaffectedCalculation.InputParameters.Structure; + Assert.AreSame(unaffectedStructure, inputParametersUnaffectedStructure); + AssertHeightStructures(readUnaffectedStructure, inputParametersUnaffectedStructure); + + CollectionAssert.AreEquivalent(new IObservable[] + { + affectedCalculation, + affectedCalculation.InputParameters, + targetDataCollection + }, affectedObjects); + } + + [Test] public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameId_UpdatesCalculation() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs =================================================================== diff -u -rb7f91e5d6aaac3c9a52cfda9b1bdd3a74ee4f8b1 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs (.../RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs) (revision b7f91e5d6aaac3c9a52cfda9b1bdd3a74ee4f8b1) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs (.../RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -620,7 +620,7 @@ } [Test] - public void UpdateSurfaceLinesWithImportedData_MultipleCalculationsWithSurfaceLines_OnlyUpdatesCalculationWithUpdatedSurfaceLine() + public void UpdateSurfaceLinesWithImportedData_MultipleCalculationsWithSurfaceLinesOneWithUpdatedLine_OnlyUpdatesCalculationWithUpdatedSurfaceLine() { // Setup const string updatedSurfaceLineName = "Name A"; @@ -711,6 +711,92 @@ } [Test] + public void UpdateSurfaceLinesWithImportedData_MultipleCalculationsWithSurfaceLinesOneWithRemovedLine_OnlyUpdatesCalculationWithRemovedSurfaceLine() + { + // Setup + const string removedSurfaceLineName = "Name A"; + const string unaffectedSurfaceLineName = "Name B"; + + var removedSurfaceLine = new RingtoetsPipingSurfaceLine + { + Name = removedSurfaceLineName + }; + removedSurfaceLine.SetGeometry(new[] + { + new Point3D(1, 2, 3), + new Point3D(4, 5, 6) + }); + var affectedCalculation = new PipingCalculation(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = removedSurfaceLine + }, + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() + }; + + var unaffectedGeometry = new[] + { + new Point3D(10, 9, 8), + new Point3D(7, 6, 5) + }; + var unaffectedSurfaceLine = new RingtoetsPipingSurfaceLine + { + Name = unaffectedSurfaceLineName + }; + unaffectedSurfaceLine.SetGeometry(unaffectedGeometry); + var unAffectedCalculation = new PipingCalculation(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = unaffectedSurfaceLine + }, + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() + }; + + var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLineCollection collection = failureMechanism.SurfaceLines; + collection.AddRange(new[] + { + removedSurfaceLine, + unaffectedSurfaceLine + }, sourceFilePath); + failureMechanism.CalculationsGroup.Children.Add(affectedCalculation); + failureMechanism.CalculationsGroup.Children.Add(unAffectedCalculation); + + RingtoetsPipingSurfaceLine importedUnaffectedSurfaceLine = DeepCloneName(unaffectedSurfaceLine); + importedUnaffectedSurfaceLine.SetGeometry(unaffectedGeometry); + + var strategy = new RingtoetsPipingSurfaceLineUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(collection, + new[] + { + importedUnaffectedSurfaceLine + }, "path").ToArray(); + + // Assert + Assert.IsTrue(unAffectedCalculation.HasOutput); + PipingInput unaffectedInput = unAffectedCalculation.InputParameters; + Assert.AreSame(unaffectedSurfaceLine, unaffectedInput.SurfaceLine); + Assert.AreEqual(unaffectedSurfaceLine, unaffectedInput.SurfaceLine); + + Assert.IsFalse(affectedCalculation.HasOutput); + PipingInput affectedInput = affectedCalculation.InputParameters; + Assert.IsNull(affectedInput.SurfaceLine); + + CollectionAssert.AreEquivalent(new IObservable[] + { + collection, + affectedCalculation, + affectedInput + }, affectedObjects); + } + + [Test] public void UpdateSurfaceLinesWithImportedData_WithCalculationAssignedToUpdatedLine_UpdatesCalculationAndStochasticSoilModel() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs =================================================================== diff -u -rb7f91e5d6aaac3c9a52cfda9b1bdd3a74ee4f8b1 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision b7f91e5d6aaac3c9a52cfda9b1bdd3a74ee4f8b1) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -470,6 +470,67 @@ }, affectedObjects); } + [Test] + public void UpdateModelWithImportedData_ProfilesAssignedToCalculationsOneWithRemovedProfile_OnlyCalculationWithRemovedProfileUpdated() + { + // Setup + const string modelsName = "same model"; + var existingModel = new TestStochasticSoilModel(modelsName); + + var targetCollection = new StochasticSoilModelCollection(); + targetCollection.AddRange(new[] + { + existingModel + }, sourceFilePath); + StochasticSoilProfile removedProfile = existingModel.StochasticSoilProfiles[0]; + StochasticSoilProfile unaffectedProfile = existingModel.StochasticSoilProfiles[1]; + + StochasticSoilModel readModel = new TestStochasticSoilModel(modelsName); + readModel.StochasticSoilProfiles.RemoveAt(0); + + var calculationWithRemovedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithRemovedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithRemovedProfile.InputParameters.StochasticSoilProfile = removedProfile; + calculationWithRemovedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + var calculationWithNotUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = unaffectedProfile; + calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); + + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); + failureMechanism.CalculationsGroup.Children.Add(calculationWithRemovedProfile); + + var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, new[] + { + readModel + }, sourceFilePath).ToArray(); + + // Assert + StochasticSoilModel firstSoilModel = targetCollection[0]; + Assert.AreSame(existingModel, firstSoilModel); + Assert.AreEqual(1, firstSoilModel.StochasticSoilProfiles.Count); + Assert.AreSame(unaffectedProfile, firstSoilModel.StochasticSoilProfiles[0]); + + Assert.IsFalse(calculationWithRemovedProfile.HasOutput); + Assert.IsNull(calculationWithRemovedProfile.InputParameters.StochasticSoilProfile); + + Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput); + Assert.AreSame(unaffectedProfile, calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile); + + CollectionAssert.AreEquivalent(new IObservable[] + { + targetCollection, + firstSoilModel, + calculationWithRemovedProfile, + calculationWithRemovedProfile.InputParameters + }, affectedObjects); + } + /// /// Creates a simple model with names for the model and profiles in the model set as specified. /// Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/FileImporters/StabilityPointStructureReplaceStrategy.cs =================================================================== diff -u -r61d70c3a93405d74b984ebea39a0ecc746dc03f5 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/FileImporters/StabilityPointStructureReplaceStrategy.cs (.../StabilityPointStructureReplaceStrategy.cs) (revision 61d70c3a93405d74b984ebea39a0ecc746dc03f5) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/FileImporters/StabilityPointStructureReplaceStrategy.cs (.../StabilityPointStructureReplaceStrategy.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -43,7 +43,7 @@ /// Creates a new instance of . /// /// The failure mechanism in which the - /// are updated. + /// structures are updated. /// Thrown when /// is null. public StabilityPointStructureReplaceStrategy(StabilityPointStructuresFailureMechanism failureMechanism) Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/FileImporters/StabilityPointStructureUpdateDataStrategy.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/FileImporters/StabilityPointStructureUpdateDataStrategy.cs (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/FileImporters/StabilityPointStructureUpdateDataStrategy.cs (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -0,0 +1,86 @@ +// 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 Core.Common.Base; +using Ringtoets.Common.Data; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.UpdateDataStrategies; +using Ringtoets.Common.Forms; +using Ringtoets.Common.IO.Structures; +using Ringtoets.Common.Service; +using Ringtoets.StabilityPointStructures.Data; + +namespace Ringtoets.StabilityPointStructures.Plugin.FileImporters +{ + /// + /// An + /// implementation for updating stability point structures based on imported + /// data. + /// + public class StabilityPointStructureUpdateDataStrategy : UpdateDataStrategyBase, + IStructureUpdateStrategy + { + /// + /// Creates a new instance of . + /// + /// The failure mechanism in which the + /// structures are updated. + /// Thrown when + /// is null. + public StabilityPointStructureUpdateDataStrategy(StabilityPointStructuresFailureMechanism failureMechanism) + : base(failureMechanism, new StructureIdEqualityComparer()) {} + + public IEnumerable UpdateStructuresWithImportedData(StructureCollection targetDataCollection, + IEnumerable readStructures, + string sourceFilePath) + { + return UpdateTargetCollectionData(targetDataCollection, readStructures, sourceFilePath); + } + + protected override IEnumerable UpdateObjectAndDependentData(StabilityPointStructure objectToUpdate, StabilityPointStructure objectToUpdateFrom) + { + objectToUpdate.CopyProperties(objectToUpdateFrom); + + var affectedObjects = new List + { + objectToUpdate + }; + affectedObjects.AddRange(FailureMechanism.Calculations + .OfType>() + .Select(calc => calc.InputParameters) + .Where(inp => ReferenceEquals(inp.Structure, objectToUpdate))); + + return affectedObjects; + } + + protected override IEnumerable RemoveObjectAndDependentData(StabilityPointStructure removedObject) + { + return RingtoetsCommonDataSynchronizationService.RemoveStructure(removedObject, FailureMechanism.Calculations + .OfType>() + .Where(calc => ReferenceEquals(calc.InputParameters.Structure, removedObject)), + FailureMechanism.StabilityPointStructures, + FailureMechanism.SectionResults); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/Ringtoets.StabilityPointStructures.Plugin.csproj =================================================================== diff -u -r61d70c3a93405d74b984ebea39a0ecc746dc03f5 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/Ringtoets.StabilityPointStructures.Plugin.csproj (.../Ringtoets.StabilityPointStructures.Plugin.csproj) (revision 61d70c3a93405d74b984ebea39a0ecc746dc03f5) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/Ringtoets.StabilityPointStructures.Plugin.csproj (.../Ringtoets.StabilityPointStructures.Plugin.csproj) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -42,6 +42,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructureReplaceDataStrategyTest.cs =================================================================== diff -u -r61d70c3a93405d74b984ebea39a0ecc746dc03f5 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructureReplaceDataStrategyTest.cs (.../StabilityPointStructureReplaceDataStrategyTest.cs) (revision 61d70c3a93405d74b984ebea39a0ecc746dc03f5) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructureReplaceDataStrategyTest.cs (.../StabilityPointStructureReplaceDataStrategyTest.cs) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -148,7 +148,7 @@ } [Test] - public void UpdateStructuresWithImportedData_CurrentCollectionAndImportedCollectionEmpty_DoesNothing() + public void UpdateStructuresWithImportedData_NoCurrentStructures_SetsSourcePath() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -168,6 +168,7 @@ { targetCollection }, affectedObjects); + Assert.AreEqual(sourcePath, targetCollection.SourcePath); } [Test] @@ -198,7 +199,7 @@ } [Test] - public void UpdateStructuresWithImportedData_CurrentCollectionEmptyAndImportedCollectionNotEmpty_AddsNewStructures() + public void UpdateStructuresWithImportedData_NoCurrentStructuresWithImportedData_AddsNewStructure() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -227,7 +228,7 @@ } [Test] - public void UpdateStructuresWithImportedData_CurrentCollectionNotEmptyAndImportedCollectionEmpty_ClearsCollection() + public void UpdateStructuresWithImportedData_WithCurrentStructuresAndImportedCollectionEmpty_ClearsCollection() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -255,7 +256,7 @@ } [Test] - public void UpdateStructuresWithImportedData_CurrentCollectionNotEmptyAndImportedCollectionNotEmpty_ReplacesCurrentWithImportedData() + public void UpdateStructuresWithImportedData_WithCurrentAndImportedDataAreDifferent_ReplacesCurrentWithImportedData() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructuresUpdateDataStrategyTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructuresUpdateDataStrategyTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructuresUpdateDataStrategyTest.cs (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -0,0 +1,526 @@ +// 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 Core.Common.Base; +using NUnit.Framework; +using Ringtoets.Common.Data; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Data.UpdateDataStrategies; +using Ringtoets.Common.IO.Structures; +using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityPointStructures.Data.TestUtil; +using Ringtoets.StabilityPointStructures.Plugin.FileImporters; + +namespace Ringtoets.StabilityPointStructures.Plugin.Test.FileImporters +{ + [TestFixture] + public class StabilityPointStructuresUpdateDataStrategyTest + { + private const string sourceFilePath = "some/path/to/Structures"; + + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new StabilityPointStructureUpdateDataStrategy(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + } + + [Test] + public void Constructor_WithFailureMechanism_CreatesNewInstance() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + // Call + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + // Assert + Assert.IsInstanceOf>(strategy); + Assert.IsInstanceOf>(strategy); + } + + [Test] + public void UpdateStructuresWithImportedData_CurrentCollectionAndImportedCollectionEmpty_DoesNothing() + { + // Setup + var targetCollection = new StructureCollection(); + var strategy = new StabilityPointStructureUpdateDataStrategy(new StabilityPointStructuresFailureMechanism()); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetCollection, + Enumerable.Empty(), + sourceFilePath); + + // Assert + CollectionAssert.IsEmpty(targetCollection); + CollectionAssert.IsEmpty(affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_WithoutCurrentStructuresAndReadStructuresHaveDuplicateNames_ThrowsUpdateDataException() + { + // Setup + const string duplicateId = "I am a duplicate id"; + var readStructures = new[] + { + new TestStabilityPointStructure("First Name", duplicateId), + new TestStabilityPointStructure("Second Name", duplicateId), + }; + + var targetCollection = new StructureCollection(); + var strategy = new StabilityPointStructureUpdateDataStrategy(new StabilityPointStructuresFailureMechanism()); + + // Call + TestDelegate call = () => strategy.UpdateStructuresWithImportedData(targetCollection, + readStructures, + sourceFilePath); + + // Assert + var exception = Assert.Throws(call); + + const string expectedMessage = "Geïmporteerde data moet unieke elementen bevatten."; + Assert.AreEqual(expectedMessage, exception.Message); + + CollectionAssert.IsEmpty(targetCollection); + } + + [Test] + public void UpdateStructuresWithImportedData_WithCurrentStructuresAndImportedDataEmpty_StructuresRemoved() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + StructureCollection structures = failureMechanism.StabilityPointStructures; + structures.AddRange(new[] + { + new TestStabilityPointStructure("name", "id"), + new TestStabilityPointStructure("other name", "other id"), + }, sourceFilePath); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + structures, Enumerable.Empty(), sourceFilePath); + + // Assert + CollectionAssert.IsEmpty(structures); + CollectionAssert.AreEqual(new[] + { + structures + }, affectedObjects); + } + + [Test] + [TestCaseSource(typeof(StabilityPointStructurePermutationHelper), + nameof(StabilityPointStructurePermutationHelper.DifferentStabilityPointStructuresWithSameId), + new object[] + { + "UpdateStructuresWithImportedData", + "UpdatesOnlySingleChange" + })] + public void UpdateStructuresWithImportedData_SingleChange_UpdatesOnlySingleChange(StabilityPointStructure readStructure) + { + // Setup + StabilityPointStructure structure = new TestStabilityPointStructure(); + + var targetCollection = new StructureCollection(); + targetCollection.AddRange(new[] + { + structure + }, sourceFilePath); + var strategy = new StabilityPointStructureUpdateDataStrategy(new StabilityPointStructuresFailureMechanism()); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetCollection, + new[] + { + readStructure + }, + sourceFilePath); + + // Assert + AssertStabilityPointStructure(readStructure, structure); + CollectionAssert.AreEqual(new IObservable[] + { + targetCollection, + structure + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_CalculationWithStructureImportedStructureWithSameId_UpdatesCalculationInput() + { + // Setup + const string sameId = "sameId"; + StabilityPointStructure readStructure = new TestStabilityPointStructure("new structure", sameId); + StabilityPointStructure structure = new TestStabilityPointStructure("original structure", sameId); + + var calculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = structure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + + StructureCollection targetDataCollection = + failureMechanism.StabilityPointStructures; + targetDataCollection.AddRange(new[] + { + structure + }, sourceFilePath); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + targetDataCollection, + new[] + { + readStructure + }, + sourceFilePath); + + // Assert + Assert.IsTrue(calculation.HasOutput); + AssertStabilityPointStructure(readStructure, structure); + CollectionAssert.AreEqual(new IObservable[] + { + targetDataCollection, + structure, + calculation.InputParameters + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_MultipleCalculationWithAssignedStructure_OnlyUpdatesCalculationInputWithUpdatedStructure() + { + // Setup + const string affectedId = "affectedId"; + const string unaffectedId = "unaffectedId"; + const string unaffectedStructureName = "unaffectedStructure"; + var affectedStructure = new TestStabilityPointStructure("Old name", affectedId); + var unaffectedStructure = new TestStabilityPointStructure(unaffectedStructureName, unaffectedId); + + var affectedCalculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = affectedStructure + }, + Output = new TestStructuresOutput() + }; + + var unaffectedCalculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = unaffectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + unaffectedCalculation + } + } + }; + + StructureCollection targetDataCollection = failureMechanism.StabilityPointStructures; + targetDataCollection.AddRange(new[] + { + affectedStructure, + unaffectedStructure + }, sourceFilePath); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + StabilityPointStructure readAffectedStructure = new TestStabilityPointStructure("New name", affectedId); + StabilityPointStructure readUnaffectedStructure = new TestStabilityPointStructure(unaffectedStructureName, unaffectedId); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetDataCollection, + new[] + { + readAffectedStructure, + readUnaffectedStructure + }, sourceFilePath); + // Assert + Assert.IsTrue(affectedCalculation.HasOutput); + StabilityPointStructure inputParametersAffectedStructure = affectedCalculation.InputParameters.Structure; + Assert.AreSame(affectedStructure, inputParametersAffectedStructure); + AssertStabilityPointStructure(affectedStructure, inputParametersAffectedStructure); + + Assert.IsTrue(unaffectedCalculation.HasOutput); + StabilityPointStructure inputParametersUnaffectedStructure = unaffectedCalculation.InputParameters.Structure; + Assert.AreSame(unaffectedStructure, inputParametersUnaffectedStructure); + AssertStabilityPointStructure(readUnaffectedStructure, inputParametersUnaffectedStructure); + + CollectionAssert.AreEquivalent(new IObservable[] + { + affectedStructure, + affectedCalculation.InputParameters, + targetDataCollection + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_CalculationWithRemovedStructure_UpdatesCalculation() + { + // Setup + const string removedId = "sameId"; + StabilityPointStructure structure = new TestStabilityPointStructure("original structure", removedId); + + var calculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = structure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + + StructureCollection targetDataCollection = + failureMechanism.StabilityPointStructures; + targetDataCollection.AddRange(new[] + { + structure + }, sourceFilePath); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + targetDataCollection, + Enumerable.Empty(), + sourceFilePath); + + // Assert + Assert.IsFalse(calculation.HasOutput); + Assert.IsNull(calculation.InputParameters.Structure); + CollectionAssert.AreEqual(new IObservable[] + { + targetDataCollection, + calculation, + calculation.InputParameters + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_MultipleCalculationWithStructuresOneWithRemovedStructure_OnlyUpdatesCalculationWithRemovedStructure() + { + // Setup + const string removedId = "removedId"; + const string unaffectedId = "unaffectedId"; + const string unaffectedStructureName = "unaffectedStructure"; + var removedStructure = new TestStabilityPointStructure("Old name", removedId); + var unaffectedStructure = new TestStabilityPointStructure(unaffectedStructureName, unaffectedId); + + var affectedCalculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = removedStructure + }, + Output = new TestStructuresOutput() + }; + + var unaffectedCalculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = unaffectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + unaffectedCalculation + } + } + }; + + StructureCollection targetDataCollection = failureMechanism.StabilityPointStructures; + targetDataCollection.AddRange(new[] + { + removedStructure, + unaffectedStructure + }, sourceFilePath); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + StabilityPointStructure readUnaffectedStructure = new TestStabilityPointStructure(unaffectedStructureName, unaffectedId); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetDataCollection, + new[] + { + readUnaffectedStructure + }, sourceFilePath); + // Assert + Assert.IsFalse(affectedCalculation.HasOutput); + Assert.IsNull(affectedCalculation.InputParameters.Structure); + + Assert.IsTrue(unaffectedCalculation.HasOutput); + StabilityPointStructure inputParametersUnaffectedStructure = unaffectedCalculation.InputParameters.Structure; + Assert.AreSame(unaffectedStructure, inputParametersUnaffectedStructure); + AssertStabilityPointStructure(readUnaffectedStructure, inputParametersUnaffectedStructure); + + CollectionAssert.AreEquivalent(new IObservable[] + { + affectedCalculation, + affectedCalculation.InputParameters, + targetDataCollection + }, affectedObjects); + } + + [Test] + public void UpdateStructuresWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculationInput() + { + // Setup + const string affectedId = "affectedId"; + var affectedStructure = new TestStabilityPointStructure("Old name", affectedId); + var affectedCalculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = affectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + affectedCalculation + } + } + }; + + StructureCollection structures = failureMechanism.StabilityPointStructures; + structures.AddRange(new[] + { + affectedStructure + }, sourceFilePath); + + var structureToUpdateFrom = new TestStabilityPointStructure("New name", affectedId); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(structures, + new[] + { + structureToUpdateFrom + }, sourceFilePath); + // Assert + CollectionAssert.AreEquivalent(new IObservable[] + { + structures, + affectedStructure, + affectedCalculation.InputParameters + }, affectedObjects); + } + + private static void AssertStabilityPointStructure(StabilityPointStructure expectedStabilityPointStructure, + StabilityPointStructure actualStabilityPointStructure) + { + Assert.AreEqual(expectedStabilityPointStructure.Name, actualStabilityPointStructure.Name); + Assert.AreEqual(expectedStabilityPointStructure.Id, actualStabilityPointStructure.Id); + Assert.AreEqual(expectedStabilityPointStructure.Location, actualStabilityPointStructure.Location); + Assert.AreEqual(expectedStabilityPointStructure.StructureNormalOrientation, actualStabilityPointStructure.StructureNormalOrientation); + + DistributionAssert.AreEqual(expectedStabilityPointStructure.StorageStructureArea, actualStabilityPointStructure.StorageStructureArea); + DistributionAssert.AreEqual(expectedStabilityPointStructure.AllowedLevelIncreaseStorage, actualStabilityPointStructure.AllowedLevelIncreaseStorage); + DistributionAssert.AreEqual(expectedStabilityPointStructure.WidthFlowApertures, actualStabilityPointStructure.WidthFlowApertures); + DistributionAssert.AreEqual(expectedStabilityPointStructure.InsideWaterLevel, actualStabilityPointStructure.InsideWaterLevel); + DistributionAssert.AreEqual(expectedStabilityPointStructure.ThresholdHeightOpenWeir, actualStabilityPointStructure.ThresholdHeightOpenWeir); + DistributionAssert.AreEqual(expectedStabilityPointStructure.CriticalOvertoppingDischarge, actualStabilityPointStructure.CriticalOvertoppingDischarge); + DistributionAssert.AreEqual(expectedStabilityPointStructure.FlowWidthAtBottomProtection, actualStabilityPointStructure.FlowWidthAtBottomProtection); + DistributionAssert.AreEqual(expectedStabilityPointStructure.ConstructiveStrengthLinearLoadModel, actualStabilityPointStructure.ConstructiveStrengthLinearLoadModel); + DistributionAssert.AreEqual(expectedStabilityPointStructure.ConstructiveStrengthQuadraticLoadModel, actualStabilityPointStructure.ConstructiveStrengthQuadraticLoadModel); + DistributionAssert.AreEqual(expectedStabilityPointStructure.BankWidth, actualStabilityPointStructure.BankWidth); + DistributionAssert.AreEqual(expectedStabilityPointStructure.InsideWaterLevelFailureConstruction, actualStabilityPointStructure.InsideWaterLevelFailureConstruction); + Assert.AreEqual(expectedStabilityPointStructure.EvaluationLevel, actualStabilityPointStructure.EvaluationLevel); + DistributionAssert.AreEqual(expectedStabilityPointStructure.LevelCrestStructure, actualStabilityPointStructure.LevelCrestStructure); + Assert.AreEqual(expectedStabilityPointStructure.VerticalDistance, actualStabilityPointStructure.VerticalDistance); + Assert.AreEqual(expectedStabilityPointStructure.FailureProbabilityRepairClosure, actualStabilityPointStructure.FailureProbabilityRepairClosure); + DistributionAssert.AreEqual(expectedStabilityPointStructure.FailureCollisionEnergy, actualStabilityPointStructure.FailureCollisionEnergy); + DistributionAssert.AreEqual(expectedStabilityPointStructure.ShipMass, actualStabilityPointStructure.ShipMass); + DistributionAssert.AreEqual(expectedStabilityPointStructure.ShipVelocity, actualStabilityPointStructure.ShipVelocity); + Assert.AreEqual(expectedStabilityPointStructure.LevellingCount, actualStabilityPointStructure.LevellingCount); + Assert.AreEqual(expectedStabilityPointStructure.ProbabilityCollisionSecondaryStructure, actualStabilityPointStructure.ProbabilityCollisionSecondaryStructure); + DistributionAssert.AreEqual(expectedStabilityPointStructure.FlowVelocityStructureClosable, actualStabilityPointStructure.FlowVelocityStructureClosable); + DistributionAssert.AreEqual(expectedStabilityPointStructure.StabilityLinearLoadModel, actualStabilityPointStructure.StabilityLinearLoadModel); + DistributionAssert.AreEqual(expectedStabilityPointStructure.StabilityQuadraticLoadModel, actualStabilityPointStructure.StabilityQuadraticLoadModel); + DistributionAssert.AreEqual(expectedStabilityPointStructure.AreaFlowApertures, actualStabilityPointStructure.AreaFlowApertures); + Assert.AreEqual(expectedStabilityPointStructure.InflowModelType, actualStabilityPointStructure.InflowModelType); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj =================================================================== diff -u -r61d70c3a93405d74b984ebea39a0ecc746dc03f5 -r89541dc8ef2d8b38372169ddecc0b37e9b225f6d --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision 61d70c3a93405d74b984ebea39a0ecc746dc03f5) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision 89541dc8ef2d8b38372169ddecc0b37e9b225f6d) @@ -62,6 +62,7 @@ +