public void UpdateStructuresWithImportedData_SingleChange_UpdatesOnlySingleChange(StabilityPointStructure readStructure) { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); StructureCollection <StabilityPointStructure> targetCollection = failureMechanism.StabilityPointStructures; targetCollection.AddRange(new[] { structure }, sourceFilePath); var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(new[] { readStructure }, sourceFilePath); // Assert AssertStabilityPointStructure(readStructure, structure); CollectionAssert.AreEqual(new IObservable[] { targetCollection, structure }, affectedObjects); }
public void Create_WithStabilityPointStructures_StabilityPointStructureEntitiesCreated() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); const string filePath = "path/to/structures"; var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.StabilityPointStructures.AddRange(new[] { structure }, filePath); var persistenceRegistry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry); // Assert Assert.AreEqual(1, entity.StabilityPointStructureEntities.Count); Assert.IsTrue(persistenceRegistry.Contains(structure)); StabilityPointStructuresFailureMechanismMetaEntity metaEntity = entity.StabilityPointStructuresFailureMechanismMetaEntities.Single(); TestHelper.AssertAreEqualButNotSame(filePath, metaEntity.StabilityPointStructureCollectionSourcePath); }
public void UpdateStructuresWithImportedData_WithCurrentStructuresAndImportedHasNoOverlap_UpdatesTargetCollection() { // Setup var targetStructure = new TestStabilityPointStructure("target id"); var failureMechanism = new StabilityPointStructuresFailureMechanism(); StructureCollection <StabilityPointStructure> structures = failureMechanism.StabilityPointStructures; structures.AddRange(new[] { targetStructure }, sourceFilePath); var readStructure = new TestStabilityPointStructure("read id"); TestStabilityPointStructure[] importedStructures = { readStructure }; var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(importedStructures, sourceFilePath); // Assert CollectionAssert.AreEqual(importedStructures, structures); Assert.AreSame(readStructure, structures[0]); CollectionAssert.AreEquivalent(new IObservable[] { structures }, affectedObjects); }
public void UpdateStructuresWithImportedData_WithCurrentAndImportedDataAreDifferent_ReplacesCurrentWithImportedData() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); StructureCollection <StabilityPointStructure> targetCollection = failureMechanism.StabilityPointStructures; targetCollection.AddRange(new[] { new TestStabilityPointStructure() }, sourcePath); var importedStructure = new TestStabilityPointStructure("a different id"); var strategy = new StabilityPointStructureReplaceDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(new[] { importedStructure }, sourcePath); // Assert CollectionAssert.AreEqual(new[] { targetCollection }, affectedObjects); TestStabilityPointStructure[] expectedCollection = { importedStructure }; CollectionAssert.AreEqual(expectedCollection, targetCollection); }
public void UpdateStructuresWithImportedData_CalculationWithStructureImportedStructureWithSameId_UpdatesCalculationInput() { // Setup const string sameId = "sameId"; StabilityPointStructure readStructure = new TestStabilityPointStructure(sameId, "new structure"); StabilityPointStructure structure = new TestStabilityPointStructure(sameId, "original structure"); var calculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = structure }, Output = new TestStructuresOutput() }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { calculation } } }; StructureCollection <StabilityPointStructure> targetDataCollection = failureMechanism.StabilityPointStructures; targetDataCollection.AddRange(new[] { structure }, sourceFilePath); var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(new[] { readStructure }, sourceFilePath); // Assert Assert.IsTrue(calculation.HasOutput); AssertStabilityPointStructure(readStructure, structure); CollectionAssert.AreEqual(new IObservable[] { targetDataCollection, structure, calculation.InputParameters }, affectedObjects); }
public void Structure_NotNull_ExpectedValues() { // Setup var input = new StabilityPointStructuresInput(); var structure = new TestStabilityPointStructure(); // Call input.Structure = structure; // Assert AssertStabilityPointStructureInput(structure, input); }
public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameIdRemoved_UpdatesCalculationInput() { // Setup const string sameId = "id"; var originalMatchingPoint = new Point2D(0, 0); StabilityPointStructure removedStructure = new TestStabilityPointStructure(originalMatchingPoint, sameId); var calculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = removedStructure } }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { calculation } } }; failureMechanism.StabilityPointStructures.AddRange(new[] { removedStructure }, sourceFilePath); FailureMechanismTestHelper.SetSections(failureMechanism, new[] { FailureMechanismSectionTestFactory.CreateFailureMechanismSection(new[] { originalMatchingPoint, new Point2D(10, 10) }) }); var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(Enumerable.Empty <StabilityPointStructure>(), sourceFilePath); // Assert CollectionAssert.AreEqual(new IObservable[] { failureMechanism.StabilityPointStructures, calculation.InputParameters }, affectedObjects); }
public void Create_PersistenceRegistryNull_ThrowArgumentNullException() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); // Call TestDelegate call = () => structure.Create(null, 0); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("registry", paramName); }
public void UpdateStructuresWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculationInput() { // Setup const string affectedId = "affectedId"; var affectedStructure = new TestStabilityPointStructure(affectedId, "Old name"); var affectedCalculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = affectedStructure }, Output = new TestStructuresOutput() }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { affectedCalculation, affectedCalculation } } }; StructureCollection <StabilityPointStructure> structures = failureMechanism.StabilityPointStructures; structures.AddRange(new[] { affectedStructure }, sourceFilePath); var structureToUpdateFrom = new TestStabilityPointStructure(affectedId, "New name"); var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(new[] { structureToUpdateFrom }, sourceFilePath); // Assert CollectionAssert.AreEquivalent(new IObservable[] { structures, affectedStructure, affectedCalculation.InputParameters }, affectedObjects); }
public void IsStructureInputSynchronized_StructureAndInputInSync_ReturnTrue() { // Setup var structure = new TestStabilityPointStructure(); var input = new StabilityPointStructuresInput { Structure = structure }; // Call bool isStructureInputSynchronized = input.IsStructureInputSynchronized; // Assert Assert.IsTrue(isStructureInputSynchronized); }
public void Read_EntityRegistered_ReturnRegisteredStructure() { // Setup var entity = new StabilityPointStructureEntity(); StabilityPointStructure registeredStructure = new TestStabilityPointStructure(); var collector = new ReadConversionCollector(); collector.Read(entity, registeredStructure); // Call StabilityPointStructure readStructure = entity.Read(collector); // Assert Assert.AreSame(registeredStructure, readStructure); }
public void Create_StructureAlreadyRegistered_ReturnRegisteredEntity() { // Setup var structure = new TestStabilityPointStructure(); var registeredEntity = new StabilityPointStructureEntity(); var registry = new PersistenceRegistry(); registry.Register(registeredEntity, structure); // Call StabilityPointStructureEntity entity = structure.Create(registry, 0); // Assert Assert.AreSame(registeredEntity, entity); }
public void IsStructureInputSynchronized_StructureAndInputNotInSync_ReturnFalse(StabilityPointStructure modifiedStructure) { // Setup var structure = new TestStabilityPointStructure(); var input = new StabilityPointStructuresInput { Structure = structure }; structure.CopyProperties(modifiedStructure); // Call bool isStructureInputSynchronized = input.IsStructureInputSynchronized; // Assert Assert.IsFalse(isStructureInputSynchronized); }
public void Text_Always_ReturnNameOfStructure() { // Setup const string name = "a nice name"; StabilityPointStructure structure = new TestStabilityPointStructure("id", name); using (var plugin = new StabilityPointStructuresPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call string text = info.Text(structure); // Assert Assert.AreEqual(name, text); } }
private void ShowFullyConfiguredStabilityPointStructuresScenariosView() { var structure1 = new TestStabilityPointStructure(new Point2D(0.0, 0.0)); var structure2 = new TestStabilityPointStructure(new Point2D(5.0, 0.0)); var failureMechanism = new StabilityPointStructuresFailureMechanism(); FailureMechanismTestHelper.SetSections(failureMechanism, new[] { new FailureMechanismSection("Section 1", new[] { new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) }), new FailureMechanismSection("Section 2", new[] { new Point2D(5.0, 0.0), new Point2D(10.0, 0.0) }) }); failureMechanism.CalculationsGroup.Children.AddRange(new[] { new StructuresCalculationScenario <StabilityPointStructuresInput> { Name = "Calculation 1", InputParameters = { Structure = structure1 } }, new StructuresCalculationScenario <StabilityPointStructuresInput> { Name = "Calculation 2", InputParameters = { Structure = structure2 }, Output = new TestStructuresOutput(0.2) } }); ShowStabilityPointStructuresScenariosView(failureMechanism); }
public void UpdateStructuresWithImportedData_WithCurrentStructuresAndImportedHasPartialOverlap_UpdatesTargetCollection() { // Setup const string commonId = "common id"; var updatedStructure = new TestStabilityPointStructure(commonId, "old name"); var removedStructure = new TestStabilityPointStructure("removed id"); var failureMechanism = new StabilityPointStructuresFailureMechanism(); StructureCollection <StabilityPointStructure> structures = failureMechanism.StabilityPointStructures; structures.AddRange(new[] { removedStructure, updatedStructure }, sourceFilePath); var structureToUpdateFrom = new TestStabilityPointStructure(commonId, "new name"); var addedStructure = new TestStabilityPointStructure("added id"); TestStabilityPointStructure[] importedStructures = { structureToUpdateFrom, addedStructure }; var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(importedStructures, sourceFilePath); // Assert Assert.AreEqual(2, structures.Count); Assert.AreSame(updatedStructure, structures[0]); AssertStabilityPointStructure(structureToUpdateFrom, updatedStructure); Assert.AreSame(addedStructure, structures[1]); CollectionAssert.AreEquivalent(new IObservable[] { updatedStructure, structures }, affectedObjects); }
public void UpdateStructuresWithImportedData_CalculationWithOutputAndStructure_CalculationUpdatedAndReturnsAffectedObject() { // Setup var structure = new TestStabilityPointStructure(); var calculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = structure }, Output = new TestStructuresOutput() }; var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculation); StructureCollection <StabilityPointStructure> targetCollection = failureMechanism.StabilityPointStructures; targetCollection.AddRange(new[] { structure }, sourcePath); var strategy = new StabilityPointStructureReplaceDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(Enumerable.Empty <StabilityPointStructure>(), sourcePath); // Assert Assert.IsNull(calculation.InputParameters.Structure); Assert.IsFalse(calculation.HasOutput); CollectionAssert.IsEmpty(targetCollection); CollectionAssert.AreEquivalent(new IObservable[] { calculation, calculation.InputParameters, targetCollection }, affectedObjects); }
public void Read_EntityWithStructureEntity_ReturnCalculationWithStructure() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); var structureEntity = new StabilityPointStructureEntity(); var entity = new StabilityPointStructuresCalculationEntity { StabilityPointStructureEntity = structureEntity, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(structureEntity, structure); // Call StructuresCalculationScenario <StabilityPointStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreSame(structure, calculation.InputParameters.Structure); }
public void ChildNodeObjects_Always_ReturnStabilityPointStructures() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); StabilityPointStructure structure1 = new TestStabilityPointStructure("id structure1"); StabilityPointStructure structure2 = new TestStabilityPointStructure("id structure2"); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.StabilityPointStructures.AddRange(new[] { structure1, structure2 }, "path"); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call object[] children = info.ChildNodeObjects(context); // Assert Assert.AreEqual(2, children.Length); Assert.AreSame(structure1, children.ElementAt(0)); Assert.AreSame(structure2, children.ElementAt(1)); } mocks.VerifyAll(); }
public void GivenViewWithStructureData_WhenStructureUpdatedAndNotified_ThenMapDataUpdated() { // Given var structure = new TestStabilityPointStructure(new Point2D(0, 0), "Id"); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.StabilityPointStructures.AddRange(new[] { structure }, "path"); StabilityPointStructuresFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub()); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[structuresObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, structuresData); // When structure.CopyProperties(new TestStabilityPointStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, structuresData); mocks.VerifyAll(); }
public void Create_ValidStructure_ReturnEntity() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); var registry = new PersistenceRegistry(); const int order = 4; // Call StabilityPointStructureEntity entity = structure.Create(registry, order); // Assert Assert.AreEqual(structure.Name, entity.Name); Assert.AreNotSame(structure.Name, entity.Name); Assert.AreEqual(structure.Id, entity.Id); Assert.AreNotSame(structure.Id, entity.Id); Assert.AreEqual(structure.Location.X, entity.X); Assert.AreEqual(structure.Location.Y, entity.Y); Assert.AreEqual(structure.StructureNormalOrientation.Value, entity.StructureNormalOrientation); Assert.AreEqual(structure.StorageStructureArea.Mean.Value, entity.StorageStructureAreaMean); Assert.AreEqual(structure.StorageStructureArea.CoefficientOfVariation.Value, entity.StorageStructureAreaCoefficientOfVariation); Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Mean.Value, entity.AllowedLevelIncreaseStorageMean); Assert.AreEqual(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value, entity.AllowedLevelIncreaseStorageStandardDeviation); Assert.AreEqual(structure.WidthFlowApertures.Mean.Value, entity.WidthFlowAperturesMean); Assert.AreEqual(structure.WidthFlowApertures.StandardDeviation.Value, entity.WidthFlowAperturesStandardDeviation); Assert.AreEqual(structure.InsideWaterLevel.Mean.Value, entity.InsideWaterLevelMean); Assert.AreEqual(structure.InsideWaterLevel.StandardDeviation.Value, entity.InsideWaterLevelStandardDeviation); Assert.AreEqual(structure.ThresholdHeightOpenWeir.Mean.Value, entity.ThresholdHeightOpenWeirMean); Assert.AreEqual(structure.ThresholdHeightOpenWeir.StandardDeviation.Value, entity.ThresholdHeightOpenWeirStandardDeviation); Assert.AreEqual(structure.CriticalOvertoppingDischarge.Mean.Value, entity.CriticalOvertoppingDischargeMean); Assert.AreEqual(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value, entity.CriticalOvertoppingDischargeCoefficientOfVariation); Assert.AreEqual(structure.FlowWidthAtBottomProtection.Mean.Value, entity.FlowWidthAtBottomProtectionMean); Assert.AreEqual(structure.FlowWidthAtBottomProtection.StandardDeviation.Value, entity.FlowWidthAtBottomProtectionStandardDeviation); Assert.AreEqual(structure.ConstructiveStrengthLinearLoadModel.Mean.Value, entity.ConstructiveStrengthLinearLoadModelMean); Assert.AreEqual(structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.Value, entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation); Assert.AreEqual(structure.ConstructiveStrengthQuadraticLoadModel.Mean.Value, entity.ConstructiveStrengthQuadraticLoadModelMean); Assert.AreEqual(structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.Value, entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation); Assert.AreEqual(structure.BankWidth.Mean.Value, entity.BankWidthMean); Assert.AreEqual(structure.BankWidth.StandardDeviation.Value, entity.BankWidthStandardDeviation); Assert.AreEqual(structure.InsideWaterLevelFailureConstruction.Mean.Value, entity.InsideWaterLevelFailureConstructionMean); Assert.AreEqual(structure.InsideWaterLevelFailureConstruction.StandardDeviation.Value, entity.InsideWaterLevelFailureConstructionStandardDeviation); Assert.AreEqual(structure.EvaluationLevel.Value, entity.EvaluationLevel); Assert.AreEqual(structure.LevelCrestStructure.Mean.Value, entity.LevelCrestStructureMean); Assert.AreEqual(structure.LevelCrestStructure.StandardDeviation.Value, entity.LevelCrestStructureStandardDeviation); Assert.AreEqual(structure.VerticalDistance.Value, entity.VerticalDistance); Assert.AreEqual(structure.FailureProbabilityRepairClosure, entity.FailureProbabilityRepairClosure); Assert.AreEqual(structure.FailureCollisionEnergy.Mean.Value, entity.FailureCollisionEnergyMean); Assert.AreEqual(structure.FailureCollisionEnergy.CoefficientOfVariation.Value, entity.FailureCollisionEnergyCoefficientOfVariation); Assert.AreEqual(structure.ShipMass.Mean.Value, entity.ShipMassMean); Assert.AreEqual(structure.ShipMass.CoefficientOfVariation.Value, entity.ShipMassCoefficientOfVariation); Assert.AreEqual(structure.ShipVelocity.Mean.Value, entity.ShipVelocityMean); Assert.AreEqual(structure.ShipVelocity.CoefficientOfVariation.Value, entity.ShipVelocityCoefficientOfVariation); Assert.AreEqual(structure.LevellingCount, entity.LevellingCount); Assert.AreEqual(structure.ProbabilityCollisionSecondaryStructure, entity.ProbabilityCollisionSecondaryStructure); Assert.AreEqual(structure.FlowVelocityStructureClosable.Mean.Value, entity.FlowVelocityStructureClosableMean); Assert.AreEqual(structure.StabilityLinearLoadModel.Mean.Value, entity.StabilityLinearLoadModelMean); Assert.AreEqual(structure.StabilityLinearLoadModel.CoefficientOfVariation.Value, entity.StabilityLinearLoadModelCoefficientOfVariation); Assert.AreEqual(structure.StabilityQuadraticLoadModel.Mean.Value, entity.StabilityQuadraticLoadModelMean); Assert.AreEqual(structure.StabilityQuadraticLoadModel.CoefficientOfVariation.Value, entity.StabilityQuadraticLoadModelCoefficientOfVariation); Assert.AreEqual(structure.AreaFlowApertures.Mean.Value, entity.AreaFlowAperturesMean); Assert.AreEqual(structure.AreaFlowApertures.StandardDeviation.Value, entity.AreaFlowAperturesStandardDeviation); Assert.AreEqual(Convert.ToByte(structure.InflowModelType), entity.InflowModelType); Assert.AreEqual(order, entity.Order); Assert.IsTrue(registry.Contains(structure)); }
public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); // Call var properties = new StabilityPointStructureProperties { Data = structure }; // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(29, dynamicProperties.Count); const string schematizationCategory = "Schematisatie"; const string generalCategory = "Algemeen"; PropertyDescriptor idProperty = dynamicProperties[idPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(idProperty, generalCategory, "ID", "ID van het kunstwerk.", true); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van het kunstwerk.", true); PropertyDescriptor locationProperty = dynamicProperties[locationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationProperty, generalCategory, "Locatie (RD) [m]", "De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.", true); PropertyDescriptor insideWaterLevelFailureConstructionProperty = dynamicProperties[insideWaterLevelFailureConstructionPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(insideWaterLevelFailureConstructionProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(insideWaterLevelFailureConstructionProperty, schematizationCategory, "Binnenwaterstand bij constructief falen [m+NAP]", "Binnenwaterstand bij constructief falen.", true); PropertyDescriptor bankWidthProperty = dynamicProperties[bankWidthPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(bankWidthProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bankWidthProperty, schematizationCategory, "Bermbreedte [m]", "Bermbreedte.", true); PropertyDescriptor verticalDistanceProperty = dynamicProperties[verticalDistancePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(verticalDistanceProperty, schematizationCategory, "Afstand onderkant wand en teen van de dijk/berm [m]", "Verticale afstand tussen de onderkant van de wand en de teen van de dijk/berm.", true); PropertyDescriptor constructiveStrengthQuadraticLoadModelProperty = dynamicProperties[constructiveStrengthQuadraticLoadModelPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(constructiveStrengthQuadraticLoadModelProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(constructiveStrengthQuadraticLoadModelProperty, schematizationCategory, "Kwadratische belastingschematisering constructieve sterkte [kN/m]", "Kritieke sterkte constructie volgens de kwadratische belastingschematisatie.", true); PropertyDescriptor constructiveStrengthLinearLoadModelProperty = dynamicProperties[constructiveStrengthLinearLoadModelPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(constructiveStrengthLinearLoadModelProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(constructiveStrengthLinearLoadModelProperty, schematizationCategory, "Lineaire belastingschematisering constructieve sterkte [kN/m²]", "Kritieke sterkte constructie volgens de lineaire belastingschematisatie.", true); PropertyDescriptor evaluationLevelProperty = dynamicProperties[evaluationLevelPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(evaluationLevelProperty, schematizationCategory, "Analysehoogte [m+NAP]", "Hoogte waarop de constructieve sterkte wordt beoordeeld.", true); PropertyDescriptor failureProbabilityRepairClosureProperty = dynamicProperties[failureProbabilityRepairClosurePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureProbabilityRepairClosureProperty, schematizationCategory, "Faalkans herstel van gefaalde situatie [-]", "Faalkans herstel van gefaalde situatie.", true); PropertyDescriptor stabilityPointStructureTypeProperty = dynamicProperties[stabilityPointStructureInflowModelTypePropertyIndex]; Assert.IsInstanceOf<EnumConverter>(stabilityPointStructureTypeProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(stabilityPointStructureTypeProperty, schematizationCategory, "Instroommodel", "Instroommodel van het kunstwerk.", true); PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[structureNormalOrientationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(structureNormalOrientationProperty, schematizationCategory, "Oriëntatie [°]", "Oriëntatie van de normaal van het kunstwerk ten opzichte van het noorden.", true); PropertyDescriptor levelCrestStructureProperty = dynamicProperties[levelCrestStructurePropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(levelCrestStructureProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(levelCrestStructureProperty, schematizationCategory, "Kerende hoogte [m+NAP]", "Kerende hoogte van het kunstwerk.", true); PropertyDescriptor insideWaterLevelProperty = dynamicProperties[insideWaterLevelPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(insideWaterLevelProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(insideWaterLevelProperty, schematizationCategory, "Binnenwaterstand [m+NAP]", "Binnenwaterstand.", true); PropertyDescriptor thresholdHeightOpenWeirProperty = dynamicProperties[thresholdHeightOpenWeirPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(thresholdHeightOpenWeirProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(thresholdHeightOpenWeirProperty, schematizationCategory, "Drempelhoogte [m+NAP]", "Drempelhoogte niet gesloten kering of hoogte van de onderkant van de wand/drempel.", true); PropertyDescriptor widthFlowAperturesProperty = dynamicProperties[widthFlowAperturesPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(widthFlowAperturesProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(widthFlowAperturesProperty, schematizationCategory, "Breedte van doorstroomopening [m]", "Breedte van de doorstroomopening.", true); PropertyDescriptor areaFlowAperturesProperty = dynamicProperties[areaFlowAperturesPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(areaFlowAperturesProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(areaFlowAperturesProperty, schematizationCategory, "Doorstroomoppervlak [m²]", "Doorstroomoppervlak van doorstroomopeningen.", true); PropertyDescriptor criticalOvertoppingDischargeProperty = dynamicProperties[criticalOvertoppingDischargePropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(criticalOvertoppingDischargeProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(criticalOvertoppingDischargeProperty, schematizationCategory, "Kritiek instromend debiet [m³/s/m]", "Kritiek instromend debiet directe invoer per strekkende meter.", true); PropertyDescriptor flowWidthAtBottomProtectionProperty = dynamicProperties[flowWidthAtBottomProtectionPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(flowWidthAtBottomProtectionProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(flowWidthAtBottomProtectionProperty, schematizationCategory, "Stroomvoerende breedte bodembescherming [m]", "Stroomvoerende breedte bodembescherming.", true); PropertyDescriptor storageStructureAreaProperty = dynamicProperties[storageStructureAreaPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(storageStructureAreaProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(storageStructureAreaProperty, schematizationCategory, "Kombergend oppervlak [m²]", "Kombergend oppervlak.", true); PropertyDescriptor allowedLevelIncreaseStorageProperty = dynamicProperties[allowedLevelIncreaseStoragePropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(allowedLevelIncreaseStorageProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(allowedLevelIncreaseStorageProperty, schematizationCategory, "Toegestane peilverhoging komberging [m]", "Toegestane peilverhoging komberging.", true); PropertyDescriptor stabilityQuadraticLoadModelProperty = dynamicProperties[stabilityQuadraticLoadModelPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(stabilityQuadraticLoadModelProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(stabilityQuadraticLoadModelProperty, schematizationCategory, "Kwadratische belastingschematisering stabiliteit [kN/m]", "Kritieke stabiliteit constructie volgens de kwadratische belastingschematisatie.", true); PropertyDescriptor stabilityLinearLoadModelProperty = dynamicProperties[stabilityLinearLoadModelPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(stabilityLinearLoadModelProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(stabilityLinearLoadModelProperty, schematizationCategory, "Lineaire belastingschematisering stabiliteit [kN/m²]", "Kritieke stabiliteit constructie volgens de lineaire belastingschematisatie.", true); PropertyDescriptor failureCollisionEnergyProperty = dynamicProperties[failureCollisionEnergyPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(failureCollisionEnergyProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureCollisionEnergyProperty, schematizationCategory, "Bezwijkwaarde aanvaarenergie [kN m]", "Bezwijkwaarde aanvaarenergie.", true); PropertyDescriptor shipMassProperty = dynamicProperties[shipMassPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(shipMassProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(shipMassProperty, schematizationCategory, "Massa van het schip [ton]", "Massa van het schip.", true); PropertyDescriptor shipVelocityProperty = dynamicProperties[shipVelocityPropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(shipVelocityProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(shipVelocityProperty, schematizationCategory, "Aanvaarsnelheid [m/s]", "Aanvaarsnelheid.", true); PropertyDescriptor levellingCountProperty = dynamicProperties[levellingCountPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(levellingCountProperty, schematizationCategory, "Aantal nivelleringen per jaar [1/jaar]", "Aantal nivelleringen per jaar.", true); PropertyDescriptor probabilityCollisionSecondaryStructureProperty = dynamicProperties[probabilityCollisionSecondaryStructurePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityCollisionSecondaryStructureProperty, schematizationCategory, "Kans op aanvaring tweede keermiddel per nivellering [1/nivellering]", "Kans op aanvaring tweede keermiddel per nivellering.", true); PropertyDescriptor flowVelocityStructureClosableProperty = dynamicProperties[flowVelocityStructureClosablePropertyIndex]; Assert.IsInstanceOf<ExpandableObjectConverter>(flowVelocityStructureClosableProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(flowVelocityStructureClosableProperty, schematizationCategory, "Kritieke stroomsnelheid sluiting eerste keermiddel [m/s]", "Stroomsnelheid waarbij na aanvaring het eerste keermiddel nog net kan worden gesloten.", true); }
public void Data_SetNewStabilityPointStructureInstance_ReturnCorrectPropertyValues() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); var properties = new StabilityPointStructureProperties(); // Call properties.Data = structure; // Assert Assert.AreEqual(structure.Id, properties.Id); Assert.AreEqual(structure.Name, properties.Name); var expectedLocation = new Point2D(new RoundedDouble(0, structure.Location.X), new RoundedDouble(0, structure.Location.Y)); Assert.AreEqual(expectedLocation, properties.Location); Assert.AreEqual("Normaal", properties.InsideWaterLevel.DistributionType); Assert.AreEqual(structure.InsideWaterLevel, properties.InsideWaterLevel.Data); Assert.IsTrue(properties.InsideWaterLevel.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.InsideWaterLevel.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Normaal", properties.InsideWaterLevelFailureConstruction.DistributionType); Assert.AreEqual(structure.InsideWaterLevelFailureConstruction, properties.InsideWaterLevelFailureConstruction.Data); Assert.IsTrue(properties.InsideWaterLevelFailureConstruction.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.InsideWaterLevelFailureConstruction.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual(structure.StructureNormalOrientation, properties.StructureNormalOrientation); Assert.AreEqual(structure.InflowModelType, properties.InflowModelType); Assert.AreEqual("Normaal", properties.WidthFlowApertures.DistributionType); Assert.AreEqual(structure.WidthFlowApertures, properties.WidthFlowApertures.Data); Assert.IsTrue(properties.WidthFlowApertures.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.WidthFlowApertures.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Lognormaal", properties.AreaFlowApertures.DistributionType); Assert.AreEqual(structure.AreaFlowApertures, properties.AreaFlowApertures.Data); Assert.IsTrue(properties.AreaFlowApertures.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.AreaFlowApertures.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Lognormaal", properties.FlowWidthAtBottomProtection.DistributionType); Assert.AreEqual(structure.FlowWidthAtBottomProtection, properties.FlowWidthAtBottomProtection.Data); Assert.IsTrue(properties.FlowWidthAtBottomProtection.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.FlowWidthAtBottomProtection.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Lognormaal", properties.StorageStructureArea.DistributionType); Assert.AreEqual(structure.StorageStructureArea, properties.StorageStructureArea.Data); Assert.IsTrue(properties.StorageStructureArea.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.StorageStructureArea.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Lognormaal", properties.AllowedLevelIncreaseStorage.DistributionType); Assert.AreEqual(structure.AllowedLevelIncreaseStorage, properties.AllowedLevelIncreaseStorage.Data); Assert.IsTrue(properties.AllowedLevelIncreaseStorage.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.AllowedLevelIncreaseStorage.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Normaal", properties.LevelCrestStructure.DistributionType); Assert.AreEqual(structure.LevelCrestStructure, properties.LevelCrestStructure.Data); Assert.IsTrue(properties.LevelCrestStructure.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.LevelCrestStructure.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Normaal", properties.ThresholdHeightOpenWeir.DistributionType); Assert.AreEqual(structure.ThresholdHeightOpenWeir, properties.ThresholdHeightOpenWeir.Data); Assert.IsTrue(properties.ThresholdHeightOpenWeir.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.ThresholdHeightOpenWeir.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual("Lognormaal", properties.CriticalOvertoppingDischarge.DistributionType); Assert.AreEqual(structure.CriticalOvertoppingDischarge, properties.CriticalOvertoppingDischarge.Data); Assert.IsTrue(properties.CriticalOvertoppingDischarge.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.CriticalOvertoppingDischarge.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Lognormaal", properties.ConstructiveStrengthLinearLoadModel.DistributionType); Assert.AreEqual(structure.ConstructiveStrengthLinearLoadModel, properties.ConstructiveStrengthLinearLoadModel.Data); Assert.IsTrue(properties.ConstructiveStrengthLinearLoadModel.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.ConstructiveStrengthLinearLoadModel.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Lognormaal", properties.ConstructiveStrengthQuadraticLoadModel.DistributionType); Assert.AreEqual(structure.ConstructiveStrengthQuadraticLoadModel, properties.ConstructiveStrengthQuadraticLoadModel.Data); Assert.IsTrue(properties.ConstructiveStrengthQuadraticLoadModel.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.ConstructiveStrengthQuadraticLoadModel.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Normaal", properties.BankWidth.DistributionType); Assert.AreEqual(structure.BankWidth, properties.BankWidth.Data); Assert.IsTrue(properties.BankWidth.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.BankWidth.DynamicReadOnlyValidationMethod("StandardDeviation")); Assert.AreEqual(structure.EvaluationLevel, properties.EvaluationLevel); Assert.AreEqual(structure.VerticalDistance, properties.VerticalDistance); Assert.AreEqual(ProbabilityFormattingHelper.Format(structure.FailureProbabilityRepairClosure), properties.FailureProbabilityRepairClosure); Assert.AreEqual("Lognormaal", properties.FailureCollisionEnergy.DistributionType); Assert.AreEqual(structure.FailureCollisionEnergy, properties.FailureCollisionEnergy.Data); Assert.IsTrue(properties.FailureCollisionEnergy.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.FailureCollisionEnergy.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Normaal", properties.ShipMass.DistributionType); Assert.AreEqual(structure.ShipMass, properties.ShipMass.Data); Assert.IsTrue(properties.ShipMass.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.ShipMass.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Normaal", properties.ShipVelocity.DistributionType); Assert.AreEqual(structure.ShipVelocity, properties.ShipVelocity.Data); Assert.IsTrue(properties.ShipVelocity.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.ShipVelocity.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual(structure.LevellingCount, properties.LevellingCount); Assert.AreEqual(ProbabilityFormattingHelper.Format(structure.ProbabilityCollisionSecondaryStructure), properties.ProbabilityCollisionSecondaryStructure); Assert.AreEqual("Normaal", properties.FlowVelocityStructureClosable.DistributionType); Assert.AreEqual(structure.FlowVelocityStructureClosable, properties.FlowVelocityStructureClosable.Data); Assert.IsTrue(properties.FlowVelocityStructureClosable.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.FlowVelocityStructureClosable.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Lognormaal", properties.StabilityLinearLoadModel.DistributionType); Assert.AreEqual(structure.StabilityLinearLoadModel, properties.StabilityLinearLoadModel.Data); Assert.IsTrue(properties.StabilityLinearLoadModel.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.StabilityLinearLoadModel.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); Assert.AreEqual("Lognormaal", properties.StabilityQuadraticLoadModel.DistributionType); Assert.AreEqual(structure.StabilityQuadraticLoadModel, properties.StabilityQuadraticLoadModel.Data); Assert.IsTrue(properties.StabilityQuadraticLoadModel.DynamicReadOnlyValidationMethod("Mean")); Assert.IsTrue(properties.StabilityQuadraticLoadModel.DynamicReadOnlyValidationMethod("CoefficientOfVariation")); }
public void UpdateStructuresWithImportedData_MultipleCalculationWithStructuresOneWithRemovedStructure_OnlyUpdatesCalculationWithRemovedStructure() { // Setup const string removedId = "removedId"; const string unaffectedId = "unaffectedId"; const string unaffectedStructureName = "unaffectedStructure"; var removedStructure = new TestStabilityPointStructure(removedId, "Old name"); var unaffectedStructure = new TestStabilityPointStructure(unaffectedId, unaffectedStructureName); var affectedCalculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = removedStructure }, Output = new TestStructuresOutput() }; var unaffectedCalculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = unaffectedStructure }, Output = new TestStructuresOutput() }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { affectedCalculation, unaffectedCalculation } } }; StructureCollection <StabilityPointStructure> targetDataCollection = failureMechanism.StabilityPointStructures; targetDataCollection.AddRange(new[] { removedStructure, unaffectedStructure }, sourceFilePath); var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); StabilityPointStructure readUnaffectedStructure = new TestStabilityPointStructure(unaffectedId, unaffectedStructureName); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(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); }
public void RemoveAllStructures_FullyConfiguredFailureMechanism_RemoveAllStructuresAndClearDependentData() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); var structureA = new TestStabilityPointStructure(new Point2D(0, 0), "A"); var structureB = new TestStabilityPointStructure(new Point2D(2, 2), "B"); failureMechanism.StabilityPointStructures.AddRange(new[] { structureA, structureB }, "path/to/structures"); var calculationWithOutput = new StructuresCalculation <StabilityPointStructuresInput> { Output = new TestStructuresOutput() }; var calculationWithStructureA = new StructuresCalculation <StabilityPointStructuresInput> { InputParameters = { Structure = structureA } }; var calculationWithStructureBAndOutput = new StructuresCalculation <StabilityPointStructuresInput> { InputParameters = { Structure = structureB }, Output = new TestStructuresOutput() }; var calculationWithStructureAAndOutput = new StructuresCalculation <StabilityPointStructuresInput> { InputParameters = { Structure = structureA }, Output = new TestStructuresOutput() }; failureMechanism.CalculationsGroup.Children.AddRange(new[] { calculationWithOutput, calculationWithStructureA, calculationWithStructureBAndOutput, calculationWithStructureAAndOutput }); // Call IEnumerable <IObservable> affectedObjects = StabilityPointStructuresDataSynchronizationService.RemoveAllStructures(failureMechanism); // Assert // Note: To make sure the clear is performed regardless of what is done with // the return result, no ToArray() should be called before these assertions: CollectionAssert.DoesNotContain(failureMechanism.StabilityPointStructures, structureA); Assert.IsNull(calculationWithStructureA.InputParameters.Structure); Assert.IsNull(calculationWithStructureAAndOutput.InputParameters.Structure); Assert.IsNull(calculationWithStructureBAndOutput.InputParameters.Structure); Assert.IsNull(calculationWithStructureAAndOutput.Output); Assert.IsNull(calculationWithStructureBAndOutput.Output); Assert.IsNotNull(calculationWithOutput.Output); IObservable[] expectedAffectedObjects = { calculationWithStructureA.InputParameters, calculationWithStructureAAndOutput, calculationWithStructureAAndOutput.InputParameters, calculationWithStructureBAndOutput, calculationWithStructureBAndOutput.InputParameters, failureMechanism.StabilityPointStructures }; CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }
private StabilityPointStructuresFailureMechanism CreateFullyConfiguredFailureMechanism() { var section1 = new FailureMechanismSection("A", new[] { new Point2D(-1, 0), new Point2D(2, 0) }); var section2 = new FailureMechanismSection("B", new[] { new Point2D(2, 0), new Point2D(4, 0) }); var structure1 = new TestStabilityPointStructure(new Point2D(1, 0), "id structure1"); var structure2 = new TestStabilityPointStructure(new Point2D(3, 0), "id structure2"); var profile = new TestForeshoreProfile(); StructuresCalculation <StabilityPointStructuresInput> calculation1 = new TestStabilityPointStructuresCalculationScenario { InputParameters = { ForeshoreProfile = profile, Structure = structure1 }, Output = new TestStructuresOutput() }; StructuresCalculation <StabilityPointStructuresInput> calculation2 = new TestStabilityPointStructuresCalculationScenario { InputParameters = { ForeshoreProfile = profile, Structure = structure2 } }; StructuresCalculation <StabilityPointStructuresInput> calculation3 = new TestStabilityPointStructuresCalculationScenario { InputParameters = { ForeshoreProfile = profile, Structure = structure1 } }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { calculation1, new CalculationGroup { Children = { calculation2 } }, calculation3 } } }; failureMechanism.StabilityPointStructures.AddRange(new[] { structure1, structure2 }, "path"); failureMechanism.ForeshoreProfiles.AddRange(new[] { profile }, "path"); FailureMechanismTestHelper.SetSections(failureMechanism, new[] { section1, section2 }); return(failureMechanism); }
public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameId_UpdatesCalculationInput() { // Setup const string sameId = "sameId"; var originalMatchingPoint = new Point2D(0, 0); var updatedMatchingPoint = new Point2D(20, 20); StabilityPointStructure readStructure = new TestStabilityPointStructure(updatedMatchingPoint, sameId); StabilityPointStructure structure = new TestStabilityPointStructure(originalMatchingPoint, sameId); var calculation = new TestStabilityPointStructuresCalculationScenario { InputParameters = { Structure = structure } }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { calculation } } }; failureMechanism.StabilityPointStructures.AddRange(new[] { structure }, sourceFilePath); var intersectionPoint = new Point2D(10, 10); FailureMechanismTestHelper.SetSections(failureMechanism, new[] { new FailureMechanismSection("OldSection", new[] { originalMatchingPoint, intersectionPoint }), new FailureMechanismSection("NewSection", new[] { intersectionPoint, updatedMatchingPoint }) }); var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateStructuresWithImportedData(new[] { readStructure }, sourceFilePath); // Assert AssertStabilityPointStructure(readStructure, structure); CollectionAssert.AreEqual(new IObservable[] { failureMechanism.StabilityPointStructures, structure, calculation.InputParameters }, affectedObjects); }
public void GivenInputWithStructure_WhenStructureNull_ThenSchematizationPropertiesSynedToDefaults() { // Given var structure = new TestStabilityPointStructure(); var input = new StabilityPointStructuresInput { Structure = structure }; RoundedDouble expectedVolumicWeightWater = input.VolumicWeightWater; LogNormalDistribution expectedDrainCoefficient = input.DrainCoefficient; RoundedDouble expectedFactorStormDurationOpenStructure = input.FactorStormDurationOpenStructure; double expectedFailureProbabilityStructureWithErosion = input.FailureProbabilityStructureWithErosion; // Precondition AssertStabilityPointStructureInput(structure, input); // When input.Structure = null; // Then AssertAreEqual(expectedVolumicWeightWater, input.VolumicWeightWater); Assert.AreEqual(2, input.FactorStormDurationOpenStructure.NumberOfDecimalPlaces); Assert.AreEqual(expectedFactorStormDurationOpenStructure, input.FactorStormDurationOpenStructure, input.FactorStormDurationOpenStructure.GetAccuracy()); DistributionAssert.AreEqual(expectedDrainCoefficient, input.DrainCoefficient); Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, input.FailureProbabilityStructureWithErosion); var expectedLevelCrestStructure = new NormalDistribution(2) { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }; var expectedThresholdHeightOpenWeir = new NormalDistribution(2) { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }; var expectedAreaFlowApertures = new LogNormalDistribution(2) { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }; var expectedConstructiveStrengthLinearLoadModel = new VariationCoefficientLogNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedConstructiveStrengthQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedStabilityLinearLoadModel = new VariationCoefficientLogNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedStabilityQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedFailureCollisionEnergy = new VariationCoefficientLogNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedShipMass = new VariationCoefficientNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedShipVelocity = new VariationCoefficientNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }; var expectedBankWidth = new NormalDistribution(2) { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }; var expectedInsideWaterLevelFailureConstruction = new NormalDistribution(2) { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }; var expectedInsideWaterLevel = new NormalDistribution(2) { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }; var expectedFlowVelocityStructureClosable = new VariationCoefficientNormalDistribution(2) { Mean = RoundedDouble.NaN, CoefficientOfVariation = (RoundedDouble)0.2 }; DistributionAssert.AreEqual(expectedLevelCrestStructure, input.LevelCrestStructure); DistributionAssert.AreEqual(expectedThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir); DistributionAssert.AreEqual(expectedAreaFlowApertures, input.AreaFlowApertures); DistributionAssert.AreEqual(expectedConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel); DistributionAssert.AreEqual(expectedConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel); DistributionAssert.AreEqual(expectedStabilityLinearLoadModel, input.StabilityLinearLoadModel); DistributionAssert.AreEqual(expectedStabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel); Assert.AreEqual(0, input.FailureProbabilityRepairClosure); DistributionAssert.AreEqual(expectedFailureCollisionEnergy, input.FailureCollisionEnergy); DistributionAssert.AreEqual(expectedShipMass, input.ShipMass); DistributionAssert.AreEqual(expectedShipVelocity, input.ShipVelocity); Assert.AreEqual(0, input.LevellingCount); Assert.AreEqual(0, input.ProbabilityCollisionSecondaryStructure); DistributionAssert.AreEqual(expectedBankWidth, input.BankWidth); DistributionAssert.AreEqual(expectedInsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction); DistributionAssert.AreEqual(expectedInsideWaterLevel, input.InsideWaterLevel); DistributionAssert.AreEqual(expectedFlowVelocityStructureClosable, input.FlowVelocityStructureClosable); Assert.AreEqual(2, input.EvaluationLevel.NumberOfDecimalPlaces); AssertAreEqual(double.NaN, input.EvaluationLevel); Assert.AreEqual(2, input.VerticalDistance.NumberOfDecimalPlaces); AssertAreEqual(double.NaN, input.VerticalDistance); Assert.AreEqual(0, (int)input.InflowModelType); Assert.AreEqual(LoadSchematizationType.Linear, input.LoadSchematizationType); }