Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs =================================================================== diff -u -r16df8541528639fd1e8d9f2584fae28808b63fad -ra940166534b3dd6e778de2e7c8e7e5241f3d3381 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 16df8541528639fd1e8d9f2584fae28808b63fad) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision a940166534b3dd6e778de2e7c8e7e5241f3d3381) @@ -69,7 +69,7 @@ var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(new StochasticSoilModelCollection(), null, string.Empty); + TestDelegate test = () => strategy.UpdateModelWithImportedData(null, string.Empty); // Assert string paramName = Assert.Throws(test).ParamName; @@ -83,28 +83,14 @@ var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(new StochasticSoilModelCollection(), new List(), null); + TestDelegate test = () => strategy.UpdateModelWithImportedData(new List(), null); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("sourceFilePath", paramName); } [Test] - public void UpdateModelWithImportedData_TargetCollectionNull_ThrowsArgumentNullException() - { - // Setup - var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); - - // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(null, new List(), string.Empty); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("targetDataCollection", paramName); - } - - [Test] public void UpdateModelWithImportedData_WithCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsUpdateDataException() { // Setup @@ -124,7 +110,7 @@ }; // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, sourceFilePath); + TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, sourceFilePath); // Assert var exception = Assert.Throws(test); @@ -148,7 +134,7 @@ }; // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, sourceFilePath); + TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, sourceFilePath); // Assert var exception = Assert.Throws(test); @@ -167,7 +153,7 @@ var targetCollection = new StochasticSoilModelCollection(); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, "path"); + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(importedStochasticSoilModels, "path"); // Assert Assert.IsEmpty(targetCollection); @@ -189,12 +175,10 @@ var readModel = new TestStochasticSoilModel("read"); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData( - pipingFailureMechanism.StochasticSoilModels, - new[] - { - readModel - }, sourceFilePath); + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] + { + readModel + }, sourceFilePath); // Assert Assert.AreSame(readModel, pipingFailureMechanism.StochasticSoilModels[0]); @@ -211,17 +195,18 @@ const string modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new StochasticSoilModelCollection(); + var failureMechanism = new PipingFailureMechanism(); + var targetCollection = failureMechanism.StochasticSoilModels; targetCollection.AddRange(new[] { existingModel }, sourceFilePath); - var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); var readModel = new TestStochasticSoilModel(modelsName); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, new[] + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] { readModel }, sourceFilePath); @@ -243,17 +228,18 @@ const string modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new StochasticSoilModelCollection(); + var failureMechanism = new PipingFailureMechanism(); + var targetCollection = failureMechanism.StochasticSoilModels; targetCollection.AddRange(new[] { existingModel }, sourceFilePath); - var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); StochasticSoilModel readModel = CreateSimpleModel(modelsName, "new profile A", "new profile B"); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, new[] + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] { readModel }, sourceFilePath); @@ -276,7 +262,8 @@ const string modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new StochasticSoilModelCollection(); + var failureMechanism = new PipingFailureMechanism(); + var targetCollection = failureMechanism.StochasticSoilModels; targetCollection.AddRange(new[] { existingModel @@ -295,14 +282,13 @@ calculationWithDeletedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[1]; calculationWithDeletedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); - var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculationWithDeletedProfile); failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, new[] + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] { readModel }, sourceFilePath).ToArray(); @@ -330,7 +316,8 @@ const string modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new StochasticSoilModelCollection(); + var failureMechanism = new PipingFailureMechanism(); + var targetCollection = failureMechanism.StochasticSoilModels; targetCollection.AddRange(new[] { existingModel @@ -350,14 +337,13 @@ calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[1]; calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); - var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); failureMechanism.CalculationsGroup.Children.Add(calculationWithUpdatedProfile); var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, new[] + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] { readModel }, sourceFilePath).ToArray(); @@ -406,7 +392,7 @@ var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); // Call - IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(stochasticSoilModelCollection, new List(), sourceFilePath).ToArray(); + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new List(), sourceFilePath).ToArray(); // Assert Assert.IsFalse(calculation.HasOutput); @@ -427,7 +413,8 @@ const string modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new StochasticSoilModelCollection(); + var failureMechanism = new PipingFailureMechanism(); + var targetCollection = failureMechanism.StochasticSoilModels; targetCollection.AddRange(new[] { existingModel @@ -447,15 +434,14 @@ 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[] + IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(new[] { readModel }, sourceFilePath).ToArray();