Beispiel #1
0
        public void CurrentPath_StochasticSoilModelCollectionHasPathSet_ReturnsExpectedPath()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            const string expectedFilePath = "some/path";
            var          stochasticSoilModelCollection = new PipingStochasticSoilModelCollection();

            stochasticSoilModelCollection.AddRange(new[]
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
            }, expectedFilePath);

            var failureMechanism = new PipingFailureMechanism();

            var context = new PipingStochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection);

            // Call
            string currentPath = updateInfo.CurrentPath(context);

            // Assert
            Assert.AreEqual(expectedFilePath, currentPath);
            mocks.VerifyAll();
        }
Beispiel #2
0
        public void ContextMenuStrip_Always_CallsBuilder()
        {
            // Setup
            PipingStochasticSoilModel model = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();

            var mocks = new MockRepository();

            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.Build()).Return(null);
            }

            using (var treeViewControl = new TreeViewControl())
            {
                var gui = mocks.Stub <IGui>();
                gui.Stub(g => g.Get(model, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

                plugin.Gui = gui;

                // Call
                info.ContextMenuStrip(model, null, treeViewControl);
            }

            // Assert
            mocks.VerifyAll();
        }
        public void Read_EntityWithStochasticSoilModelEntityInCollector_CalculationHasAlreadyReadStochasticSoilModel()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();
            var stochasticSoilModelEntity = new StochasticSoilModelEntity();

            var stochasticSoilProfile       = new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            var stochasticSoilProfileEntity = new PipingStochasticSoilProfileEntity
            {
                StochasticSoilModelEntity = stochasticSoilModelEntity
            };

            var entity = new SemiProbabilisticPipingCalculationEntity
            {
                PipingStochasticSoilProfileEntity = stochasticSoilProfileEntity,
                EntryPointL           = 1,
                ExitPointL            = 2,
                DampingFactorExitMean = 1,
                ScenarioContribution  = 0
            };

            var collector = new ReadConversionCollector();

            collector.Read(stochasticSoilProfileEntity, stochasticSoilProfile);
            collector.Read(stochasticSoilModelEntity, stochasticSoilModel);

            // Call
            SemiProbabilisticPipingCalculationScenario calculation = entity.Read(collector);

            // Assert
            Assert.AreSame(stochasticSoilProfile, calculation.InputParameters.StochasticSoilProfile);
            Assert.AreSame(stochasticSoilModel, calculation.InputParameters.StochasticSoilModel);
        }
        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);
        }
Beispiel #5
0
        public void ParameteredConstructor_ParentNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var surfaceLines = new[]
            {
                new PipingSurfaceLine(string.Empty)
            };

            PipingStochasticSoilModel[] soilModels =
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
            };
            var calculation      = new SemiProbabilisticPipingCalculationScenario();
            var failureMechanism = new PipingFailureMechanism();

            // Call
            TestDelegate call = () => new SemiProbabilisticPipingCalculationScenarioContext(calculation,
                                                                                            null,
                                                                                            surfaceLines,
                                                                                            soilModels,
                                                                                            failureMechanism,
                                                                                            assessmentSection);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("parent", exception.ParamName);
            mocks.VerifyAll();
        }
Beispiel #6
0
        public void GivenViewWithStochasticSoilModels_WhenStochasticSoilModelsUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            PipingFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("", new[]
            {
                new Point2D(1, 2),
                new Point2D(1, 2)
            });

            var stochasticSoilModelMapData = (MapLineData)map.Data.Collection.ElementAt(stochasticSoilModelsIndex);

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel
            }, "path");
            failureMechanism.StochasticSoilModels.NotifyObservers();

            // Then
            AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, stochasticSoilModelMapData);
            mocks.VerifyAll();
        }
        public void CreateStochasticSoilModelFeatures_GivenStochasticSoilModels_ReturnsStochasticSoilModelFeaturesCollection()
        {
            // Setup
            var pointsOne = new[]
            {
                new Point2D(1.2, 2.3),
                new Point2D(2.7, 2.0)
            };
            var pointsTwo = new[]
            {
                new Point2D(3.2, 23.3),
                new Point2D(7.7, 12.6)
            };

            PipingStochasticSoilModel[] stochasticSoilModels =
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName1", pointsOne),
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName2", pointsTwo)
            };

            // Call
            IEnumerable <MapFeature> features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(stochasticSoilModels);

            // Assert
            Assert.AreEqual(stochasticSoilModels.Length, features.Count());

            for (var i = 0; i < features.Count(); i++)
            {
                Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count());
                AssertEqualPointCollections(stochasticSoilModels[i].Geometry, features.ElementAt(i).MapGeometries.First());
                Assert.AreEqual(1, features.ElementAt(i).MetaData.Keys.Count);
                Assert.AreEqual(stochasticSoilModels[i].Name, features.ElementAt(i).MetaData["Naam"]);
            }
        }
        public void ParameteredConstructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculation  = new ProbabilisticPipingCalculationScenario();
            var surfaceLines = new[]
            {
                new PipingSurfaceLine(string.Empty)
            };

            PipingStochasticSoilModel[] stochasticSoilModels =
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
            };

            var failureMechanism = new PipingFailureMechanism();

            // Call
            var context = new ProbabilisticPipingInputContext(calculation.InputParameters, calculation, surfaceLines, stochasticSoilModels, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <PipingContext <ProbabilisticPipingInput> >(context);
            Assert.AreSame(calculation.InputParameters, context.WrappedData);
            Assert.AreSame(calculation, context.PipingCalculation);
            Assert.AreSame(failureMechanism, context.FailureMechanism);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            CollectionAssert.AreEqual(surfaceLines, context.AvailablePipingSurfaceLines);
            CollectionAssert.AreEqual(stochasticSoilModels, context.AvailableStochasticSoilModels);
            mocks.VerifyAll();
        }
Beispiel #9
0
        public void ForeColor_CollectionWithSoilModels_ReturnsControlText()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
            }, "path");

            var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext(
                failureMechanism.StochasticSoilModels,
                failureMechanism,
                assessmentSection);

            // Call
            Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor);
        }
Beispiel #10
0
        public void Create_WithStochasticSoilModels_ReturnsFailureMechanismEntityWithStochasticSoilModelEntities()
        {
            // Setup
            var failureMechanism = new PipingFailureMechanism();
            PipingStochasticSoilModelCollection stochasticSoilModels = failureMechanism.StochasticSoilModels;

            stochasticSoilModels.AddRange(new[]
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("name"),
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("name2")
            }, "some/path/to/file");

            var registry = new PersistenceRegistry();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(stochasticSoilModels.Count, entity.StochasticSoilModelEntities.Count);
            for (var i = 0; i < stochasticSoilModels.Count; i++)
            {
                AssertStochasticSoilModel(stochasticSoilModels[i],
                                          entity.StochasticSoilModelEntities.ElementAt(i));
            }

            string stochasticSoilModelCollectionSourcePath = entity.PipingFailureMechanismMetaEntities
                                                             .Single()
                                                             .StochasticSoilModelCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(stochasticSoilModels.SourcePath, stochasticSoilModelCollectionSourcePath);
        }
Beispiel #11
0
        public void UpdateModelWithImportedData_WithCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsUpdateDataException()
        {
            // Setup
            const string nonUniqueName = "non-unique name";

            var targetCollection = new PipingStochasticSoilModelCollection();

            targetCollection.AddRange(new[]
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName)
            }, sourceFilePath);

            var strategy = new PipingStochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism());

            PipingStochasticSoilModel[] importedStochasticSoilModels =
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName),
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(nonUniqueName)
            };

            // Call
            TestDelegate test = () => strategy.UpdateModelWithImportedData(importedStochasticSoilModels, sourceFilePath);

            // Assert
            var          exception       = Assert.Throws <UpdateDataException>(test);
            const string expectedMessage = "Geïmporteerde data moet unieke elementen bevatten.";

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Beispiel #12
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Name", new[]
            {
                new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()),
                new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile())
            });

            var failureMechanism = new PipingFailureMechanism();
            var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext(
                failureMechanism.StochasticSoilModels,
                failureMechanism,
                assessmentSection);

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel
            }, "path");

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                stochasticSoilModel
            }, objects);
        }
Beispiel #13
0
        public void UpdateModelWithImportedData_UpdateCurrentModelWithImportedModelWithOtherProfiles_ProfilesAdded()
        {
            // Setup
            const string modelsName = "same model";
            PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName);

            var failureMechanism = new PipingFailureMechanism();
            PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels;

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

            var strategy = new PipingStochasticSoilModelUpdateDataStrategy(failureMechanism);
            PipingStochasticSoilModel readModel = CreateSimpleModel(modelsName, "new profile A", "new profile B");

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

            // Assert
            Assert.AreEqual(1, targetCollection.Count);
            Assert.AreSame(existingModel, targetCollection[0]);
            Assert.AreEqual(2, targetCollection[0].StochasticSoilProfiles.Count());
            CollectionAssert.AreEquivalent(new IObservable[]
            {
                targetCollection,
                existingModel
            }, affectedObjects);
        }
Beispiel #14
0
        public void Create_StochasticSoilProfileSet_EntityHasStochasticSoilProfileEntity()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();
            var stochasticSoilProfile     = new PipingStochasticSoilProfile(0.6, soilProfile);

            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A", new[]
            {
                stochasticSoilProfile
            });

            var registry = new PersistenceRegistry();
            StochasticSoilModelEntity soilModelEntity = soilModel.Create(registry, 0);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilModel   = soilModel,
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            // Call
            ProbabilisticPipingCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            PipingStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = soilModelEntity.PipingStochasticSoilProfileEntities.First();

            Assert.AreSame(expectedStochasticSoilProfileEntity, entity.PipingStochasticSoilProfileEntity);
            Assert.IsTrue(registry.Contains(soilModel));
        }
Beispiel #15
0
        public void EditValue_WithCurrentItemNotInAvailableItems_ReturnsOriginalValue()
        {
            // Setup
            var mockRepository         = new MockRepository();
            var provider               = mockRepository.DynamicMock <IServiceProvider>();
            var service                = mockRepository.DynamicMock <IWindowsFormsEditorService>();
            var context                = mockRepository.DynamicMock <ITypeDescriptorContext>();
            var hasStochasticSoilModel = mockRepository.Stub <IHasStochasticSoilModel>();

            hasStochasticSoilModel.Stub(hssm => hssm.StochasticSoilModel).Return(
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName"));
            hasStochasticSoilModel.Stub(hssm => hssm.GetAvailableStochasticSoilModels()).Return(
                new[]
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("NewStochasticSoilModelName")
            });

            var editor      = new PipingInputContextStochasticSoilModelSelectionEditor <IHasStochasticSoilModel>();
            var someValue   = new object();
            var propertyBag = new DynamicPropertyBag(hasStochasticSoilModel);

            provider.Expect(p => p.GetService(null)).IgnoreArguments().Return(service);
            service.Expect(s => s.DropDownControl(null)).IgnoreArguments();
            context.Expect(c => c.Instance).Return(propertyBag);

            mockRepository.ReplayAll();

            // Call
            object result = editor.EditValue(context, provider, someValue);

            // Assert
            Assert.AreSame(someValue, result);

            mockRepository.VerifyAll();
        }
Beispiel #16
0
        protected override IEnumerable <PipingStochasticSoilModel> SingleNonUniqueElements()
        {
            const string someName = "Soil model";

            yield return(PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(someName));

            yield return(PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(someName));
        }
            public void Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport()
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSoilProfile.xml"), filePath);

                var calculationGroup = new CalculationGroup();
                var surfaceLine      = new PipingSurfaceLine("Profielschematisatie");

                surfaceLine.SetGeometry(new[]
                {
                    new Point3D(3.0, 5.0, 0.0),
                    new Point3D(3.0, 0.0, 1.0),
                    new Point3D(3.0, -5.0, 0.0)
                });
                PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(
                    "Ondergrondmodel",
                    new[]
                {
                    new Point2D(1.0, 0.0),
                    new Point2D(5.0, 0.0)
                });

                var pipingFailureMechanism = new PipingFailureMechanism();

                pipingFailureMechanism.SurfaceLines.AddRange(new[]
                {
                    surfaceLine
                }, "readerPath");
                pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
                {
                    stochasticSoilModel
                }, "readerPath");

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism);

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    const string expectedMessage = "De ondergrondschematisatie 'Ondergrondschematisatie' bestaat niet binnen het stochastische ondergrondmodel 'Ondergrondmodel'. " +
                                                   "Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
Beispiel #18
0
        public void StochasticSoilModel_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            PipingStochasticSoilModel newModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();
            var newValue = new DataGridViewComboBoxItemWrapper <PipingStochasticSoilModel>(newModel);

            var calculation = new TestPipingCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.StochasticSoilModel = newValue, calculation);
        }
        public void CreateInstance_WithStochasticSoilModel_NewPropertiesWithInputAsData()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();

            // Call
            IObjectProperties objectProperties = info.CreateInstance(stochasticSoilModel);

            // Assert
            Assert.IsInstanceOf <PipingStochasticSoilModelProperties>(objectProperties);
            Assert.AreSame(stochasticSoilModel, objectProperties.Data);
        }
Beispiel #20
0
        public void Text_Always_ReturnsTextFromStochasticSoilModel()
        {
            // Setup
            const string name = "test test 123";
            PipingStochasticSoilModel model = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(name);

            // Call
            string text = info.Text(model);

            // Assert
            Assert.AreEqual(name, text);
        }
        public void Create_PersistenceRegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();

            // Call
            TestDelegate test = () => stochasticSoilModel.Create(null, 0);

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

            Assert.AreEqual("registry", parameterName);
        }
Beispiel #22
0
        /// <summary>
        /// Creates a simple model with names for the model and profiles in the model set as specified.
        /// </summary>
        /// <param name="modelName">Name of the created model.</param>
        /// <param name="profileNames">List of names for the profiles to be added to the model.</param>
        /// <returns>A new <see cref="PipingStochasticSoilModel"/>.</returns>
        private static PipingStochasticSoilModel CreateSimpleModel(string modelName, params string[] profileNames)
        {
            var stochasticProfiles = new List <PipingStochasticSoilProfile>();

            foreach (string profileName in profileNames)
            {
                stochasticProfiles.Add(new PipingStochasticSoilProfile(
                                           1.0 / profileNames.Length,
                                           PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName)));
            }

            return(PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelName, stochasticProfiles));
        }
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string name = "testName";
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(name);
            var registry = new PersistenceRegistry();

            // Call
            StochasticSoilModelEntity entity = stochasticSoilModel.Create(registry, 0);

            // Assert
            TestHelper.AssertAreEqualButNotSame(name, entity.Name);
        }
        public void RemoveStochasticSoilModel_PipingFailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();

            // Call
            void Call() => PipingDataSynchronizationService.RemoveStochasticSoilModel(null, soilModel);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
        public void Create_SameModelCreatedMultipleTimes_ReturnSameEntity()
        {
            // Setup
            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A");

            var registry = new PersistenceRegistry();

            // Call
            StochasticSoilModelEntity entity1 = soilModel.Create(registry, 0);
            StochasticSoilModelEntity entity2 = soilModel.Create(registry, 0);

            // Assert
            Assert.AreSame(entity1, entity2);
        }
Beispiel #26
0
        public void Constructor_ValidStochasticSoilModel_ExpectedValues()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();

            // Call
            var properties = new PipingStochasticSoilModelProperties(stochasticSoilModel);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <PipingStochasticSoilModel> >(properties);
            TestHelper.AssertTypeConverter <PipingStochasticSoilModelProperties, ExpandableArrayConverter>(nameof(PipingStochasticSoilModelProperties.Geometry));
            TestHelper.AssertTypeConverter <PipingStochasticSoilModelProperties, ExpandableArrayConverter>(nameof(PipingStochasticSoilModelProperties.StochasticSoilProfiles));
            Assert.AreSame(stochasticSoilModel, properties.Data);
        }
        public void SetMatchingStochasticSoilModel_SurfaceLineOverlappingSingleSoilModel_SetsSoilModel()
        {
            // Setup
            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();
            var pipingInput = new TestPipingInput();

            // Call
            PipingInputService.SetMatchingStochasticSoilModel(pipingInput, new[]
            {
                soilModel
            });

            // Assert
            Assert.AreSame(soilModel, pipingInput.StochasticSoilModel);
        }
Beispiel #28
0
        public void IntersectsWithSurfaceLineGeometry_SurfaceLineNull_ThrowArgumentNullException()
        {
            // Setup
            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            });

            // Call
            TestDelegate test = () => soilModel.IntersectsWithSurfaceLineGeometry(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("surfaceLine", exception.ParamName);
        }
        public void SetMatchingStochasticSoilModel_SurfaceLineOverlappingMultipleSoilModels_DoesNotSetModel()
        {
            // Setup
            var pipingInput = new TestPipingInput();
            PipingStochasticSoilModel soilModel1 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A");
            PipingStochasticSoilModel soilModel2 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("C");

            // Call
            PipingInputService.SetMatchingStochasticSoilModel(pipingInput, new[]
            {
                soilModel1,
                soilModel2
            });

            // Assert
            Assert.IsNull(pipingInput.StochasticSoilModel);
        }
        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);
        }