public void UpdateModelWithImportedData_WithCurrentModelAndImportedModel_ModelReplaced() { // Setup PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("existing"); var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { existingModel }, sourceFilePath); var strategy = new PipingStochasticSoilModelReplaceDataStrategy(pipingFailureMechanism); PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("read"); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(new[] { readModel }, sourceFilePath); // Assert Assert.AreSame(readModel, pipingFailureMechanism.StochasticSoilModels[0]); CollectionAssert.AreEqual(new[] { pipingFailureMechanism.StochasticSoilModels }, affectedObjects); }
public void Constructor_WitFailureMechanism_CreatesNewInstance() { // Call var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); // Assert Assert.IsInstanceOf <IStochasticSoilModelUpdateModelStrategy <PipingStochasticSoilModel> >(strategy); Assert.IsInstanceOf <ReplaceDataStrategyBase <PipingStochasticSoilModel, PipingFailureMechanism> >(strategy); }
public void UpdateModelWithImportedData_SourceFilePathNull_ThrowsArgumentNullException() { // Setup var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); // Call void Call() => strategy.UpdateModelWithImportedData(new List <PipingStochasticSoilModel>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("sourceFilePath", exception.ParamName); }
public void UpdateModelWithImportedData_ReadStochasticSoilModelsNull_ThrowsArgumentNullException() { // Setup var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); // Call void Call() => strategy.UpdateModelWithImportedData(null, string.Empty); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("importedDataCollection", exception.ParamName); }
public void UpdateModelWithImportedData_ImportedModelsContainDuplicateNames_ThrowsUpdateDataException() { // Setup PipingStochasticSoilModel[] importedStochasticSoilModels = { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B"), PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B") }; var strategy = new PipingStochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); // Call TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, "path"); // Assert var exception = Assert.Throws <UpdateDataException>(test); Assert.AreEqual("Stochastische ondergrondmodellen moeten een unieke naam hebben. " + "Gevonden dubbele elementen: B.", exception.Message); }
public void UpdateModelWithImportedData_CalculationWithOutputAssignedRemovedSoilModelAndProfile_CalculationUpdatedAndCalculationAndInputReturned() { // Setup PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); var calculation = new SemiProbabilisticPipingCalculationScenario { InputParameters = { StochasticSoilModel = existingModel, StochasticSoilProfile = existingModel.StochasticSoilProfiles.First() }, Output = new SemiProbabilisticPipingOutput(new SemiProbabilisticPipingOutput.ConstructionProperties()) }; var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculation); var strategy = new PipingStochasticSoilModelReplaceDataStrategy(failureMechanism); var targetCollection = new PipingStochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel }, sourceFilePath); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(new List <PipingStochasticSoilModel>(), sourceFilePath).ToArray(); // Assert Assert.IsFalse(calculation.HasOutput); Assert.IsNull(calculation.InputParameters.StochasticSoilModel); Assert.IsNull(calculation.InputParameters.StochasticSoilProfile); CollectionAssert.AreEquivalent(new IObservable[] { calculation, calculation.InputParameters, failureMechanism.StochasticSoilModels }, affectedObjects); }
public void UpdateModelWithImportedData_WithCurrentModelsAndImportedDataEmpty_ModelsRemoved() { // Setup var failureMechanism = new PipingFailureMechanism(); failureMechanism.StochasticSoilModels.AddRange(new[] { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"), PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B") }, sourceFilePath); var strategy = new PipingStochasticSoilModelReplaceDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(new List <PipingStochasticSoilModel>(), sourceFilePath); // Assert CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); CollectionAssert.AreEqual(new[] { failureMechanism.StochasticSoilModels }, affectedObjects); }
public void UpdateModelWithImportedData_WithoutCurrentModelAndModelsImported_NewModelsAdded() { // Setup PipingStochasticSoilModel[] importedStochasticSoilModels = { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A"), PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("B") }; var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.StochasticSoilModels.AddRange(importedStochasticSoilModels, sourceFilePath); var strategy = new PipingStochasticSoilModelReplaceDataStrategy(pipingFailureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(importedStochasticSoilModels, "path"); // Assert CollectionAssert.AreEqual(importedStochasticSoilModels, pipingFailureMechanism.StochasticSoilModels); CollectionAssert.AreEqual(new[] { pipingFailureMechanism.StochasticSoilModels }, affectedObjects); }