示例#1
0
        public void UpdateModelWithImportedData_WithCurrentModelAndImportedModel_ModelReplaced()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel existingModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("existing");

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                existingModel
            }, sourceFilePath);
            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(failureMechanism);
            MacroStabilityInwardsStochasticSoilModel readModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("read");

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(new[]
            {
                readModel
            }, sourceFilePath);

            // Assert
            Assert.AreSame(readModel, failureMechanism.StochasticSoilModels[0]);
            CollectionAssert.AreEqual(new[]
            {
                failureMechanism.StochasticSoilModels
            }, affectedObjects);
        }
示例#2
0
        public void Constructor_WithFailureMechanism_CreatesNewInstance()
        {
            // Call
            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(new MacroStabilityInwardsFailureMechanism());

            // Assert
            Assert.IsInstanceOf <IStochasticSoilModelUpdateModelStrategy <MacroStabilityInwardsStochasticSoilModel> >(strategy);
            Assert.IsInstanceOf <ReplaceDataStrategyBase <MacroStabilityInwardsStochasticSoilModel, MacroStabilityInwardsFailureMechanism> >(strategy);
        }
示例#3
0
        public void UpdateModelWithImportedData_SourceFilePathNull_ThrowsArgumentNullException()
        {
            // Setup
            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(new MacroStabilityInwardsFailureMechanism());

            // Call
            TestDelegate test = () => strategy.UpdateModelWithImportedData(new List <MacroStabilityInwardsStochasticSoilModel>(), null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(test).ParamName;

            Assert.AreEqual("sourceFilePath", paramName);
        }
示例#4
0
        public void UpdateModelWithImportedData_ReadStochasticSoilModelsNull_ThrowsArgumentNullException()
        {
            // Setup
            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(new MacroStabilityInwardsFailureMechanism());

            // Call
            TestDelegate test = () => strategy.UpdateModelWithImportedData(null, string.Empty);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(test).ParamName;

            Assert.AreEqual("importedDataCollection", paramName);
        }
示例#5
0
        public void UpdateModelWithImportedData_ImportedModelsContainDuplicateNames_ThrowsUpdateDataException()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel[] importedStochasticSoilModels =
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("B"),
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("B")
            };
            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(new MacroStabilityInwardsFailureMechanism());

            // 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);
        }
示例#6
0
        public void UpdateModelWithImportedData_WithCurrentModelsAndImportedDataEmpty_ModelsRemoved()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("A"),
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("B")
            }, sourceFilePath);

            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(new List <MacroStabilityInwardsStochasticSoilModel>(), sourceFilePath);

            // Assert
            CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels);
            CollectionAssert.AreEqual(new[]
            {
                failureMechanism.StochasticSoilModels
            }, affectedObjects);
        }
示例#7
0
        public void UpdateModelWithImportedData_CalculationWithOutputAssignedRemovedSoilModelAndProfile_CalculationUpdatedAndCalculationAndInputReturned()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel existingModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel();
            var calculation = new MacroStabilityInwardsCalculationScenario();

            calculation.InputParameters.StochasticSoilModel   = existingModel;
            calculation.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(0);
            calculation.Output = MacroStabilityInwardsOutputTestFactory.CreateOutput();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(calculation);

            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(failureMechanism);

            var targetCollection = new MacroStabilityInwardsStochasticSoilModelCollection();

            targetCollection.AddRange(new[]
            {
                existingModel
            }, sourceFilePath);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(new List <MacroStabilityInwardsStochasticSoilModel>(), 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);
        }
示例#8
0
        public void UpdateModelWithImportedData_WithoutCurrentModelAndModelsImported_NewModelsAdded()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel[] importedStochasticSoilModels =
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("A"),
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("B")
            };
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.StochasticSoilModels.AddRange(importedStochasticSoilModels, sourceFilePath);
            var strategy = new MacroStabilityInwardsStochasticSoilModelReplaceDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateModelWithImportedData(importedStochasticSoilModels,
                                                                                             "path");

            // Assert
            CollectionAssert.AreEqual(importedStochasticSoilModels, failureMechanism.StochasticSoilModels);
            CollectionAssert.AreEqual(new[]
            {
                failureMechanism.StochasticSoilModels
            }, affectedObjects);
        }