public void SynchronizeStructureInput_ChangedStructure_ExpectedValues() { // Setup var differentStructure = new StabilityPointStructure(new StabilityPointStructure.ConstructionProperties { Id = "Test id", Name = "Test name", Location = new Point2D(-1, -1) }); var input = new StabilityPointStructuresInput { Structure = new TestStabilityPointStructure() }; input.Structure.CopyProperties(differentStructure); // Precondition AssertStabilityPointStructureInput(new TestStabilityPointStructure(), input); // Call input.SynchronizeStructureInput(); // Assert AssertStabilityPointStructureInput(differentStructure, input); }
/// <summary> /// Removes the <paramref name="structure"/> and clears all dependent data, either directly or indirectly. /// </summary> /// <param name="structure">The structure to be removed.</param> /// <param name="failureMechanism">The failure mechanism containing <paramref name="structure"/>.</param> /// <returns>All objects affected by the removal.</returns> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public static IEnumerable <IObservable> RemoveStructure(StabilityPointStructure structure, StabilityPointStructuresFailureMechanism failureMechanism) { if (structure == null) { throw new ArgumentNullException(nameof(structure)); } if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } IEnumerable <StructuresCalculation <StabilityPointStructuresInput> > stabilityPointStructureCalculations = failureMechanism.Calculations .Cast <StructuresCalculation <StabilityPointStructuresInput> >(); IEnumerable <StructuresCalculation <StabilityPointStructuresInput> > calculationWithRemovedStabilityPointStructure = stabilityPointStructureCalculations .Where(c => ReferenceEquals(c.InputParameters.Structure, structure)) .ToArray(); List <IObservable> changedObservables = ClearStructureDependentData(calculationWithRemovedStabilityPointStructure); failureMechanism.StabilityPointStructures.Remove(structure); changedObservables.Add(failureMechanism.StabilityPointStructures); return(changedObservables); }
private static void AssertStabilityPointStructure(StabilityPointStructure expectedStabilityPointStructure, StabilityPointStructure actualStabilityPointStructure) { Assert.AreEqual(expectedStabilityPointStructure.Name, actualStabilityPointStructure.Name); Assert.AreEqual(expectedStabilityPointStructure.Id, actualStabilityPointStructure.Id); Assert.AreEqual(expectedStabilityPointStructure.Location, actualStabilityPointStructure.Location); Assert.AreEqual(expectedStabilityPointStructure.StructureNormalOrientation, actualStabilityPointStructure.StructureNormalOrientation); DistributionAssert.AreEqual(expectedStabilityPointStructure.StorageStructureArea, actualStabilityPointStructure.StorageStructureArea); DistributionAssert.AreEqual(expectedStabilityPointStructure.AllowedLevelIncreaseStorage, actualStabilityPointStructure.AllowedLevelIncreaseStorage); DistributionAssert.AreEqual(expectedStabilityPointStructure.WidthFlowApertures, actualStabilityPointStructure.WidthFlowApertures); DistributionAssert.AreEqual(expectedStabilityPointStructure.InsideWaterLevel, actualStabilityPointStructure.InsideWaterLevel); DistributionAssert.AreEqual(expectedStabilityPointStructure.ThresholdHeightOpenWeir, actualStabilityPointStructure.ThresholdHeightOpenWeir); DistributionAssert.AreEqual(expectedStabilityPointStructure.CriticalOvertoppingDischarge, actualStabilityPointStructure.CriticalOvertoppingDischarge); DistributionAssert.AreEqual(expectedStabilityPointStructure.FlowWidthAtBottomProtection, actualStabilityPointStructure.FlowWidthAtBottomProtection); DistributionAssert.AreEqual(expectedStabilityPointStructure.ConstructiveStrengthLinearLoadModel, actualStabilityPointStructure.ConstructiveStrengthLinearLoadModel); DistributionAssert.AreEqual(expectedStabilityPointStructure.ConstructiveStrengthQuadraticLoadModel, actualStabilityPointStructure.ConstructiveStrengthQuadraticLoadModel); DistributionAssert.AreEqual(expectedStabilityPointStructure.BankWidth, actualStabilityPointStructure.BankWidth); DistributionAssert.AreEqual(expectedStabilityPointStructure.InsideWaterLevelFailureConstruction, actualStabilityPointStructure.InsideWaterLevelFailureConstruction); Assert.AreEqual(expectedStabilityPointStructure.EvaluationLevel, actualStabilityPointStructure.EvaluationLevel); DistributionAssert.AreEqual(expectedStabilityPointStructure.LevelCrestStructure, actualStabilityPointStructure.LevelCrestStructure); Assert.AreEqual(expectedStabilityPointStructure.VerticalDistance, actualStabilityPointStructure.VerticalDistance); Assert.AreEqual(expectedStabilityPointStructure.FailureProbabilityRepairClosure, actualStabilityPointStructure.FailureProbabilityRepairClosure); DistributionAssert.AreEqual(expectedStabilityPointStructure.FailureCollisionEnergy, actualStabilityPointStructure.FailureCollisionEnergy); DistributionAssert.AreEqual(expectedStabilityPointStructure.ShipMass, actualStabilityPointStructure.ShipMass); DistributionAssert.AreEqual(expectedStabilityPointStructure.ShipVelocity, actualStabilityPointStructure.ShipVelocity); Assert.AreEqual(expectedStabilityPointStructure.LevellingCount, actualStabilityPointStructure.LevellingCount); Assert.AreEqual(expectedStabilityPointStructure.ProbabilityCollisionSecondaryStructure, actualStabilityPointStructure.ProbabilityCollisionSecondaryStructure); DistributionAssert.AreEqual(expectedStabilityPointStructure.FlowVelocityStructureClosable, actualStabilityPointStructure.FlowVelocityStructureClosable); DistributionAssert.AreEqual(expectedStabilityPointStructure.StabilityLinearLoadModel, actualStabilityPointStructure.StabilityLinearLoadModel); DistributionAssert.AreEqual(expectedStabilityPointStructure.StabilityQuadraticLoadModel, actualStabilityPointStructure.StabilityQuadraticLoadModel); DistributionAssert.AreEqual(expectedStabilityPointStructure.AreaFlowApertures, actualStabilityPointStructure.AreaFlowApertures); Assert.AreEqual(expectedStabilityPointStructure.InflowModelType, actualStabilityPointStructure.InflowModelType); }
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 RemoveStructure_FullyConfiguredFailureMechanism_RemovesStructureAndClearsDependentData() { // Setup StabilityPointStructuresFailureMechanism failureMechanism = CreateFullyConfiguredFailureMechanism(); StabilityPointStructure structure = failureMechanism.StabilityPointStructures[0]; StructuresCalculation <StabilityPointStructuresInput>[] calculationsWithStructure = failureMechanism.Calculations .Cast <StructuresCalculation <StabilityPointStructuresInput> >() .Where(c => ReferenceEquals(c.InputParameters.Structure, structure)) .ToArray(); StructuresCalculation <StabilityPointStructuresInput>[] calculationsWithOutput = calculationsWithStructure.Where(c => c.HasOutput) .ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithOutput); CollectionAssert.IsNotEmpty(calculationsWithStructure); // Call IEnumerable <IObservable> affectedObjects = StabilityPointStructuresDataSynchronizationService.RemoveStructure(structure, 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, structure); foreach (StructuresCalculation <StabilityPointStructuresInput> calculation in calculationsWithStructure) { Assert.IsNull(calculation.InputParameters.Structure); } foreach (StructuresCalculation <StabilityPointStructuresInput> calculation in calculationsWithOutput) { Assert.IsFalse(calculation.HasOutput); } IObservable[] array = affectedObjects.ToArray(); Assert.AreEqual(1 + calculationsWithOutput.Length + calculationsWithStructure.Length, array.Length); CollectionAssert.Contains(array, failureMechanism.StabilityPointStructures); foreach (StructuresCalculation <StabilityPointStructuresInput> calculation in calculationsWithStructure) { CollectionAssert.Contains(array, calculation.InputParameters); } foreach (StructuresCalculation <StabilityPointStructuresInput> calculation in calculationsWithOutput) { CollectionAssert.Contains(array, calculation); } }
public void Read_EntityNotReadBefore_RegisterEntity() { // Setup var entity = new StabilityPointStructureEntity { Name = "name", Id = "id" }; var collector = new ReadConversionCollector(); // Precondition Assert.IsFalse(collector.Contains(entity)); // Call StabilityPointStructure calculation = entity.Read(collector); // Assert Assert.IsTrue(collector.Contains(entity)); Assert.AreSame(calculation, collector.Get(entity)); }
/// <summary> /// Reads the <see cref="StabilityPointStructureEntity"/> and use the information to update a /// <see cref="StabilityPointStructure"/>. /// </summary> /// <param name="entity">The <see cref="StabilityPointStructureEntity"/> to create <see cref="StabilityPointStructure"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="StabilityPointStructure"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> internal static StabilityPointStructure Read(this StabilityPointStructureEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var structure = new StabilityPointStructure(new StabilityPointStructure.ConstructionProperties { Name = entity.Name, Id = entity.Id, Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), StructureNormalOrientation = (RoundedDouble)entity.StructureNormalOrientation.ToNullAsNaN(), StorageStructureArea = { Mean = (RoundedDouble)entity.StorageStructureAreaMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN() }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble)entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN() }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble)entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN() }, InsideWaterLevel = { Mean = (RoundedDouble)entity.InsideWaterLevelMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.InsideWaterLevelStandardDeviation.ToNullAsNaN() }, ThresholdHeightOpenWeir = { Mean = (RoundedDouble)entity.ThresholdHeightOpenWeirMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.ThresholdHeightOpenWeirStandardDeviation.ToNullAsNaN() }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble)entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN() }, WidthFlowApertures = { Mean = (RoundedDouble)entity.WidthFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN() }, ConstructiveStrengthLinearLoadModel = { Mean = (RoundedDouble)entity.ConstructiveStrengthLinearLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation.ToNullAsNaN() }, ConstructiveStrengthQuadraticLoadModel = { Mean = (RoundedDouble)entity.ConstructiveStrengthQuadraticLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation.ToNullAsNaN() }, BankWidth = { Mean = (RoundedDouble)entity.BankWidthMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.BankWidthStandardDeviation.ToNullAsNaN() }, InsideWaterLevelFailureConstruction = { Mean = (RoundedDouble)entity.InsideWaterLevelFailureConstructionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.InsideWaterLevelFailureConstructionStandardDeviation.ToNullAsNaN() }, EvaluationLevel = (RoundedDouble)entity.EvaluationLevel.ToNullAsNaN(), LevelCrestStructure = { Mean = (RoundedDouble)entity.LevelCrestStructureMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.LevelCrestStructureStandardDeviation.ToNullAsNaN() }, VerticalDistance = (RoundedDouble)entity.VerticalDistance.ToNullAsNaN(), FailureProbabilityRepairClosure = entity.FailureProbabilityRepairClosure.ToNullAsNaN(), FailureCollisionEnergy = { Mean = (RoundedDouble)entity.FailureCollisionEnergyMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.FailureCollisionEnergyCoefficientOfVariation.ToNullAsNaN() }, ShipMass = { Mean = (RoundedDouble)entity.ShipMassMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ShipMassCoefficientOfVariation.ToNullAsNaN() }, ShipVelocity = { Mean = (RoundedDouble)entity.ShipVelocityMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ShipVelocityCoefficientOfVariation.ToNullAsNaN() }, LevellingCount = entity.LevellingCount, ProbabilityCollisionSecondaryStructure = entity.ProbabilityCollisionSecondaryStructure.ToNullAsNaN(), FlowVelocityStructureClosable = { Mean = (RoundedDouble)entity.FlowVelocityStructureClosableMean.ToNullAsNaN() }, StabilityLinearLoadModel = { Mean = (RoundedDouble)entity.StabilityLinearLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StabilityLinearLoadModelCoefficientOfVariation.ToNullAsNaN() }, StabilityQuadraticLoadModel = { Mean = (RoundedDouble)entity.StabilityQuadraticLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StabilityQuadraticLoadModelCoefficientOfVariation.ToNullAsNaN() }, AreaFlowApertures = { Mean = (RoundedDouble)entity.AreaFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AreaFlowAperturesStandardDeviation.ToNullAsNaN() }, InflowModelType = (StabilityPointStructureInflowModelType)entity.InflowModelType }); collector.Read(entity, structure); return(structure); }
public void Import_MissingParametersAndDuplicateIrrelevantParameter_LogWarningAndContinueImportWithDefaultValues() { // Setup string filePath = Path.Combine(testDataPath, nameof(StabilityPointStructuresImporter), "MissingAndDuplicateIrrelevantParameters", "Kunstwerken.shp"); var importTarget = new StructureCollection <StabilityPointStructure>(); var messageProvider = mocks.Stub <IImporterMessageProvider>(); var updateStrategy = mocks.Stub <IStructureUpdateStrategy <StabilityPointStructure> >(); updateStrategy.Expect(u => u.UpdateStructuresWithImportedData(null, null)).IgnoreArguments().WhenCalled(i => { Assert.AreEqual(filePath, i.Arguments[1]); var readStructures = (IEnumerable <StabilityPointStructure>)i.Arguments[0]; Assert.AreEqual(1, readStructures.Count()); StabilityPointStructure importedStructure = readStructures.First(); var defaultStructure = new StabilityPointStructure(new StabilityPointStructure.ConstructionProperties { Name = "test", Location = new Point2D(0, 0), Id = "id" }); DistributionAssert.AreEqual(defaultStructure.StorageStructureArea, importedStructure.StorageStructureArea); DistributionAssert.AreEqual(defaultStructure.ThresholdHeightOpenWeir, importedStructure.ThresholdHeightOpenWeir); DistributionAssert.AreEqual(defaultStructure.InsideWaterLevelFailureConstruction, importedStructure.InsideWaterLevelFailureConstruction); Assert.AreEqual(defaultStructure.LevellingCount, importedStructure.LevellingCount); DistributionAssert.AreEqual(defaultStructure.AreaFlowApertures, importedStructure.AreaFlowApertures); }); mocks.ReplayAll(); ReferenceLine referenceLine = CreateReferenceLine(); var structuresImporter = new StabilityPointStructuresImporter(importTarget, referenceLine, filePath, messageProvider, updateStrategy); // Call var importResult = false; Action call = () => importResult = structuresImporter.Import(); // Assert TestHelper.AssertLogMessages(call, msgs => { string[] messages = msgs.ToArray(); Assert.AreEqual(12, messages.Length); const string structure = "'Coupure Den Oever (90k1)' (KUNST1)"; Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB2' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[0]); Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB6' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[4]); Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB12' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[7]); Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB20' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[9]); Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB25' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[10]); // Don't care about the other messages. }); Assert.IsTrue(importResult); }
public void Import_VarianceValuesNeedConversion_WarnUserAboutConversion() { // Setup string filePath = Path.Combine(testDataPath, "StructuresVarianceValueConversion", "Kunstwerken.shp"); var importTarget = new StructureCollection <StabilityPointStructure>(); var messageProvider = mocks.Stub <IImporterMessageProvider>(); var updateStrategy = mocks.StrictMock <IStructureUpdateStrategy <StabilityPointStructure> >(); updateStrategy.Expect(u => u.UpdateStructuresWithImportedData(null, null)).IgnoreArguments().WhenCalled(i => { Assert.AreEqual(filePath, i.Arguments[1]); var structures = (IEnumerable <StabilityPointStructure>)i.Arguments[0]; Assert.AreEqual(1, structures.Count()); StabilityPointStructure structure = structures.First(); Assert.AreEqual(0.5, structure.StorageStructureArea.CoefficientOfVariation.Value); Assert.AreEqual(2, structure.AllowedLevelIncreaseStorage.StandardDeviation.Value); Assert.AreEqual(4, structure.WidthFlowApertures.StandardDeviation.Value); Assert.AreEqual(4, structure.InsideWaterLevel.StandardDeviation.Value); Assert.AreEqual(6, structure.ThresholdHeightOpenWeir.StandardDeviation.Value); Assert.AreEqual(1.5, structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value); Assert.AreEqual(8, structure.FlowWidthAtBottomProtection.StandardDeviation.Value); Assert.AreEqual(2, structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(2.5, structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(10, structure.BankWidth.StandardDeviation.Value); Assert.AreEqual(12, structure.InsideWaterLevelFailureConstruction.StandardDeviation.Value); Assert.AreEqual(14, structure.LevelCrestStructure.StandardDeviation.Value); Assert.AreEqual(3.5, structure.FailureCollisionEnergy.CoefficientOfVariation.Value); Assert.AreEqual(4, structure.ShipMass.CoefficientOfVariation.Value); Assert.AreEqual(4.5, structure.ShipVelocity.CoefficientOfVariation.Value); Assert.AreEqual(5, structure.StabilityLinearLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(5.5, structure.StabilityQuadraticLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(22, structure.AreaFlowApertures.StandardDeviation.Value); }); mocks.ReplayAll(); ReferenceLine referenceLine = CreateReferenceLine(); var structuresImporter = new StabilityPointStructuresImporter(importTarget, referenceLine, filePath, messageProvider, updateStrategy); // Call var importResult = false; Action call = () => importResult = structuresImporter.Import(); // Assert string[] expectedMessages = { "De variatie voor parameter 'KW_STERSTAB2' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 26).", "De variatie voor parameter 'KW_STERSTAB3' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 27).", "De variatie voor parameter 'KW_STERSTAB4' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 28).", "De variatie voor parameter 'KW_STERSTAB5' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 29).", "De variatie voor parameter 'KW_STERSTAB6' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 30).", "De variatie voor parameter 'KW_STERSTAB7' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 31).", "De variatie voor parameter 'KW_STERSTAB8' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 32).", "De variatie voor parameter 'KW_STERSTAB9' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 33).", "De variatie voor parameter 'KW_STERSTAB10' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 34).", "De variatie voor parameter 'KW_STERSTAB11' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 35).", "De variatie voor parameter 'KW_STERSTAB12' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 36).", "De variatie voor parameter 'KW_STERSTAB14' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 38).", "De variatie voor parameter 'KW_STERSTAB17' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 41).", "De variatie voor parameter 'KW_STERSTAB18' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 42).", "De variatie voor parameter 'KW_STERSTAB19' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 43).", "De variatie voor parameter 'KW_STERSTAB23' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 47).", "De variatie voor parameter 'KW_STERSTAB24' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een variatiecoëfficiënt (regel 48).", "De variatie voor parameter 'KW_STERSTAB25' van kunstwerk 'Coupure Den Oever (90k1)' (KUNST1) wordt omgerekend in een standaardafwijking (regel 49)." }; TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages); Assert.IsTrue(importResult); }
/// <summary> /// Checks whether a create operations has been registered for the given <paramref name="model"/>. /// </summary> /// <param name="model">The <see cref="StabilityPointStructure"/> to check for.</param> /// <returns><c>true</c> if the <see cref="model"/> was registered before, <c>false</c> otherwise.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="model"/> is <c>null</c>.</exception> internal bool Contains(StabilityPointStructure model) { return(ContainsValue(stabilityPointStructures, model)); }
public void Create_NaNValue_ReturnEntityWithNullValue() { // Setup var structure = new StabilityPointStructure(new StabilityPointStructure.ConstructionProperties { Name = "A", Id = "B", Location = new Point2D(double.NaN, double.NaN), StructureNormalOrientation = RoundedDouble.NaN, StorageStructureArea = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, AllowedLevelIncreaseStorage = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, WidthFlowApertures = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, InsideWaterLevel = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, ThresholdHeightOpenWeir = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, CriticalOvertoppingDischarge = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, FlowWidthAtBottomProtection = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, ConstructiveStrengthLinearLoadModel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, ConstructiveStrengthQuadraticLoadModel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, BankWidth = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, InsideWaterLevelFailureConstruction = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, EvaluationLevel = RoundedDouble.NaN, LevelCrestStructure = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN }, VerticalDistance = RoundedDouble.NaN, FailureProbabilityRepairClosure = double.NaN, FailureCollisionEnergy = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, ShipMass = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, ShipVelocity = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, ProbabilityCollisionSecondaryStructure = double.NaN, FlowVelocityStructureClosable = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, StabilityLinearLoadModel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, StabilityQuadraticLoadModel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, AreaFlowApertures = { Mean = RoundedDouble.NaN, StandardDeviation = RoundedDouble.NaN } }); var registry = new PersistenceRegistry(); // Call StabilityPointStructureEntity entity = structure.Create(registry, 0); // Assert Assert.IsNull(entity.X); Assert.IsNull(entity.Y); Assert.IsNull(entity.StructureNormalOrientation); Assert.IsNull(entity.StorageStructureAreaMean); Assert.IsNull(entity.StorageStructureAreaCoefficientOfVariation); Assert.IsNull(entity.AllowedLevelIncreaseStorageMean); Assert.IsNull(entity.AllowedLevelIncreaseStorageStandardDeviation); Assert.IsNull(entity.WidthFlowAperturesMean); Assert.IsNull(entity.WidthFlowAperturesStandardDeviation); Assert.IsNull(entity.InsideWaterLevelMean); Assert.IsNull(entity.InsideWaterLevelStandardDeviation); Assert.IsNull(entity.ThresholdHeightOpenWeirMean); Assert.IsNull(entity.ThresholdHeightOpenWeirStandardDeviation); Assert.IsNull(entity.CriticalOvertoppingDischargeMean); Assert.IsNull(entity.CriticalOvertoppingDischargeCoefficientOfVariation); Assert.IsNull(entity.FlowWidthAtBottomProtectionMean); Assert.IsNull(entity.FlowWidthAtBottomProtectionStandardDeviation); Assert.IsNull(entity.ConstructiveStrengthLinearLoadModelMean); Assert.IsNull(entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation); Assert.IsNull(entity.ConstructiveStrengthQuadraticLoadModelMean); Assert.IsNull(entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation); Assert.IsNull(entity.BankWidthMean); Assert.IsNull(entity.BankWidthStandardDeviation); Assert.IsNull(entity.InsideWaterLevelFailureConstructionMean); Assert.IsNull(entity.InsideWaterLevelFailureConstructionStandardDeviation); Assert.IsNull(entity.EvaluationLevel); Assert.IsNull(entity.LevelCrestStructureMean); Assert.IsNull(entity.LevelCrestStructureStandardDeviation); Assert.IsNull(entity.VerticalDistance); Assert.IsNull(entity.FailureProbabilityRepairClosure); Assert.IsNull(entity.FailureCollisionEnergyMean); Assert.IsNull(entity.FailureCollisionEnergyCoefficientOfVariation); Assert.IsNull(entity.ShipMassMean); Assert.IsNull(entity.ShipMassCoefficientOfVariation); Assert.IsNull(entity.ShipVelocityMean); Assert.IsNull(entity.ShipVelocityCoefficientOfVariation); Assert.IsNull(entity.ProbabilityCollisionSecondaryStructure); Assert.IsNull(entity.FlowVelocityStructureClosableMean); Assert.IsNull(entity.StabilityLinearLoadModelMean); Assert.IsNull(entity.StabilityLinearLoadModelCoefficientOfVariation); Assert.IsNull(entity.StabilityQuadraticLoadModelMean); Assert.IsNull(entity.StabilityQuadraticLoadModelCoefficientOfVariation); Assert.IsNull(entity.AreaFlowAperturesMean); Assert.IsNull(entity.AreaFlowAperturesStandardDeviation); }
/// <summary> /// Creates a <see cref="StabilityPointStructureEntity"/> based on the information /// of the <see cref="StabilityPointStructure"/>. /// </summary> /// <param name="structure">The structure to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <param name="order">The index at which <paramref name="structure"/> resides within its parent.</param> /// <returns>A new <see cref="StabilityPointStructureEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static StabilityPointStructureEntity Create(this StabilityPointStructure structure, PersistenceRegistry registry, int order) { if (registry == null) { throw new ArgumentNullException(nameof(registry)); } if (registry.Contains(structure)) { return(registry.Get(structure)); } var entity = new StabilityPointStructureEntity { Name = structure.Name.DeepClone(), Id = structure.Id.DeepClone(), X = structure.Location.X.ToNaNAsNull(), Y = structure.Location.Y.ToNaNAsNull(), StructureNormalOrientation = structure.StructureNormalOrientation.ToNaNAsNull(), StorageStructureAreaMean = structure.StorageStructureArea.Mean.ToNaNAsNull(), StorageStructureAreaCoefficientOfVariation = structure.StorageStructureArea.CoefficientOfVariation.ToNaNAsNull(), AllowedLevelIncreaseStorageMean = structure.AllowedLevelIncreaseStorage.Mean.ToNaNAsNull(), AllowedLevelIncreaseStorageStandardDeviation = structure.AllowedLevelIncreaseStorage.StandardDeviation.ToNaNAsNull(), WidthFlowAperturesMean = structure.WidthFlowApertures.Mean.ToNaNAsNull(), WidthFlowAperturesStandardDeviation = structure.WidthFlowApertures.StandardDeviation.ToNaNAsNull(), InsideWaterLevelMean = structure.InsideWaterLevel.Mean.ToNaNAsNull(), InsideWaterLevelStandardDeviation = structure.InsideWaterLevel.StandardDeviation.ToNaNAsNull(), ThresholdHeightOpenWeirMean = structure.ThresholdHeightOpenWeir.Mean.ToNaNAsNull(), ThresholdHeightOpenWeirStandardDeviation = structure.ThresholdHeightOpenWeir.StandardDeviation.ToNaNAsNull(), CriticalOvertoppingDischargeMean = structure.CriticalOvertoppingDischarge.Mean.ToNaNAsNull(), CriticalOvertoppingDischargeCoefficientOfVariation = structure.CriticalOvertoppingDischarge.CoefficientOfVariation.ToNaNAsNull(), FlowWidthAtBottomProtectionMean = structure.FlowWidthAtBottomProtection.Mean.ToNaNAsNull(), FlowWidthAtBottomProtectionStandardDeviation = structure.FlowWidthAtBottomProtection.StandardDeviation.ToNaNAsNull(), ConstructiveStrengthLinearLoadModelMean = structure.ConstructiveStrengthLinearLoadModel.Mean.ToNaNAsNull(), ConstructiveStrengthLinearLoadModelCoefficientOfVariation = structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.ToNaNAsNull(), ConstructiveStrengthQuadraticLoadModelMean = structure.ConstructiveStrengthQuadraticLoadModel.Mean.ToNaNAsNull(), ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.ToNaNAsNull(), BankWidthMean = structure.BankWidth.Mean.ToNaNAsNull(), BankWidthStandardDeviation = structure.BankWidth.StandardDeviation.ToNaNAsNull(), InsideWaterLevelFailureConstructionMean = structure.InsideWaterLevelFailureConstruction.Mean.ToNaNAsNull(), InsideWaterLevelFailureConstructionStandardDeviation = structure.InsideWaterLevelFailureConstruction.StandardDeviation.ToNaNAsNull(), EvaluationLevel = structure.EvaluationLevel.ToNaNAsNull(), LevelCrestStructureMean = structure.LevelCrestStructure.Mean.ToNaNAsNull(), LevelCrestStructureStandardDeviation = structure.LevelCrestStructure.StandardDeviation.ToNaNAsNull(), VerticalDistance = structure.VerticalDistance.ToNaNAsNull(), FailureProbabilityRepairClosure = structure.FailureProbabilityRepairClosure.ToNaNAsNull(), FailureCollisionEnergyMean = structure.FailureCollisionEnergy.Mean.ToNaNAsNull(), FailureCollisionEnergyCoefficientOfVariation = structure.FailureCollisionEnergy.CoefficientOfVariation.ToNaNAsNull(), ShipMassMean = structure.ShipMass.Mean.ToNaNAsNull(), ShipMassCoefficientOfVariation = structure.ShipMass.CoefficientOfVariation.ToNaNAsNull(), ShipVelocityMean = structure.ShipVelocity.Mean.ToNaNAsNull(), ShipVelocityCoefficientOfVariation = structure.ShipVelocity.CoefficientOfVariation.ToNaNAsNull(), LevellingCount = structure.LevellingCount, ProbabilityCollisionSecondaryStructure = structure.ProbabilityCollisionSecondaryStructure.ToNaNAsNull(), FlowVelocityStructureClosableMean = structure.FlowVelocityStructureClosable.Mean.ToNaNAsNull(), StabilityLinearLoadModelMean = structure.StabilityLinearLoadModel.Mean.ToNaNAsNull(), StabilityLinearLoadModelCoefficientOfVariation = structure.StabilityLinearLoadModel.CoefficientOfVariation.ToNaNAsNull(), StabilityQuadraticLoadModelMean = structure.StabilityQuadraticLoadModel.Mean.ToNaNAsNull(), StabilityQuadraticLoadModelCoefficientOfVariation = structure.StabilityQuadraticLoadModel.CoefficientOfVariation.ToNaNAsNull(), AreaFlowAperturesMean = structure.AreaFlowApertures.Mean.ToNaNAsNull(), AreaFlowAperturesStandardDeviation = structure.AreaFlowApertures.StandardDeviation.ToNaNAsNull(), InflowModelType = Convert.ToByte(structure.InflowModelType), Order = order }; registry.Register(entity, structure); return(entity); }
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 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 Read_ValidEntity_ReturnStabilityPointStructure() { // Setup var entity = new StabilityPointStructureEntity { Name = "A", Id = "B", X = 1.1, Y = 2.2, StructureNormalOrientation = 3.3, StorageStructureAreaMean = 4.4, StorageStructureAreaCoefficientOfVariation = 5.5, AllowedLevelIncreaseStorageMean = 6.6, AllowedLevelIncreaseStorageStandardDeviation = 7.7, WidthFlowAperturesMean = 8.8, WidthFlowAperturesStandardDeviation = 9.9, InsideWaterLevelMean = 10.10, InsideWaterLevelStandardDeviation = 11.11, ThresholdHeightOpenWeirMean = 12.12, ThresholdHeightOpenWeirStandardDeviation = 13.13, CriticalOvertoppingDischargeMean = 14.14, CriticalOvertoppingDischargeCoefficientOfVariation = 15.15, FlowWidthAtBottomProtectionMean = 16.16, FlowWidthAtBottomProtectionStandardDeviation = 17.17, ConstructiveStrengthLinearLoadModelMean = 18.18, ConstructiveStrengthLinearLoadModelCoefficientOfVariation = 19.19, ConstructiveStrengthQuadraticLoadModelMean = 20.20, ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = 21.21, BankWidthMean = 22.22, BankWidthStandardDeviation = 23.23, InsideWaterLevelFailureConstructionMean = 24.24, InsideWaterLevelFailureConstructionStandardDeviation = 25.25, EvaluationLevel = 26.26, LevelCrestStructureMean = 27.27, LevelCrestStructureStandardDeviation = 28.28, VerticalDistance = 29.29, FailureProbabilityRepairClosure = 30.30, FailureCollisionEnergyMean = 31.31, FailureCollisionEnergyCoefficientOfVariation = 32.32, ShipMassMean = 33.33, ShipMassCoefficientOfVariation = 34.34, ShipVelocityMean = 35.35, ShipVelocityCoefficientOfVariation = 36.36, LevellingCount = 37, ProbabilityCollisionSecondaryStructure = 38.38, FlowVelocityStructureClosableMean = 39.39, StabilityLinearLoadModelMean = 41.41, StabilityLinearLoadModelCoefficientOfVariation = 42.42, StabilityQuadraticLoadModelMean = 43.43, StabilityQuadraticLoadModelCoefficientOfVariation = 44.44, AreaFlowAperturesMean = 45.45, AreaFlowAperturesStandardDeviation = 46.46, InflowModelType = Convert.ToByte(StabilityPointStructureInflowModelType.FloodedCulvert) }; var collector = new ReadConversionCollector(); // Call StabilityPointStructure structure = entity.Read(collector); // Assert Assert.AreEqual(entity.Name, structure.Name); Assert.AreEqual(entity.Id, structure.Id); Assert.AreEqual(entity.X, structure.Location.X); Assert.AreEqual(entity.Y, structure.Location.Y); Assert.AreEqual(entity.StructureNormalOrientation, structure.StructureNormalOrientation.Value); Assert.AreEqual(entity.StorageStructureAreaMean, structure.StorageStructureArea.Mean.Value); Assert.AreEqual(entity.StorageStructureAreaCoefficientOfVariation, structure.StorageStructureArea.CoefficientOfVariation.Value); Assert.AreEqual(entity.AllowedLevelIncreaseStorageMean, structure.AllowedLevelIncreaseStorage.Mean.Value); Assert.AreEqual(entity.AllowedLevelIncreaseStorageStandardDeviation, structure.AllowedLevelIncreaseStorage.StandardDeviation.Value); Assert.AreEqual(entity.WidthFlowAperturesMean, structure.WidthFlowApertures.Mean.Value); Assert.AreEqual(entity.WidthFlowAperturesStandardDeviation, structure.WidthFlowApertures.StandardDeviation.Value); Assert.AreEqual(entity.InsideWaterLevelMean, structure.InsideWaterLevel.Mean.Value); Assert.AreEqual(entity.InsideWaterLevelStandardDeviation, structure.InsideWaterLevel.StandardDeviation.Value); Assert.AreEqual(entity.ThresholdHeightOpenWeirMean, structure.ThresholdHeightOpenWeir.Mean.Value); Assert.AreEqual(entity.ThresholdHeightOpenWeirStandardDeviation, structure.ThresholdHeightOpenWeir.StandardDeviation.Value); Assert.AreEqual(entity.CriticalOvertoppingDischargeMean, structure.CriticalOvertoppingDischarge.Mean.Value); Assert.AreEqual(entity.CriticalOvertoppingDischargeCoefficientOfVariation, structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value); Assert.AreEqual(entity.FlowWidthAtBottomProtectionMean, structure.FlowWidthAtBottomProtection.Mean.Value); Assert.AreEqual(entity.FlowWidthAtBottomProtectionStandardDeviation, structure.FlowWidthAtBottomProtection.StandardDeviation.Value); Assert.AreEqual(entity.ConstructiveStrengthLinearLoadModelMean, structure.ConstructiveStrengthLinearLoadModel.Mean.Value); Assert.AreEqual(entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation, structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.ConstructiveStrengthQuadraticLoadModelMean, structure.ConstructiveStrengthQuadraticLoadModel.Mean.Value); Assert.AreEqual(entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation, structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.BankWidthMean, structure.BankWidth.Mean.Value); Assert.AreEqual(entity.BankWidthStandardDeviation, structure.BankWidth.StandardDeviation.Value); Assert.AreEqual(entity.InsideWaterLevelFailureConstructionMean, structure.InsideWaterLevelFailureConstruction.Mean.Value); Assert.AreEqual(entity.InsideWaterLevelFailureConstructionStandardDeviation, structure.InsideWaterLevelFailureConstruction.StandardDeviation.Value); Assert.AreEqual(entity.EvaluationLevel, structure.EvaluationLevel.Value); Assert.AreEqual(entity.LevelCrestStructureMean, structure.LevelCrestStructure.Mean.Value); Assert.AreEqual(entity.LevelCrestStructureStandardDeviation, structure.LevelCrestStructure.StandardDeviation.Value); Assert.AreEqual(entity.VerticalDistance, structure.VerticalDistance.Value); Assert.AreEqual(entity.FailureProbabilityRepairClosure, structure.FailureProbabilityRepairClosure); Assert.AreEqual(entity.FailureCollisionEnergyMean, structure.FailureCollisionEnergy.Mean.Value); Assert.AreEqual(entity.FailureCollisionEnergyCoefficientOfVariation, structure.FailureCollisionEnergy.CoefficientOfVariation.Value); Assert.AreEqual(entity.ShipMassMean, structure.ShipMass.Mean.Value); Assert.AreEqual(entity.ShipMassCoefficientOfVariation, structure.ShipMass.CoefficientOfVariation.Value); Assert.AreEqual(entity.ShipVelocityMean, structure.ShipVelocity.Mean.Value); Assert.AreEqual(entity.ShipVelocityCoefficientOfVariation, structure.ShipVelocity.CoefficientOfVariation.Value); Assert.AreEqual(entity.LevellingCount, structure.LevellingCount); Assert.AreEqual(entity.ProbabilityCollisionSecondaryStructure, structure.ProbabilityCollisionSecondaryStructure); Assert.AreEqual(entity.FlowVelocityStructureClosableMean, structure.FlowVelocityStructureClosable.Mean.Value); Assert.AreEqual(entity.StabilityLinearLoadModelMean, structure.StabilityLinearLoadModel.Mean.Value); Assert.AreEqual(entity.StabilityLinearLoadModelCoefficientOfVariation, structure.StabilityLinearLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.StabilityQuadraticLoadModelMean, structure.StabilityQuadraticLoadModel.Mean.Value); Assert.AreEqual(entity.StabilityQuadraticLoadModelCoefficientOfVariation, structure.StabilityQuadraticLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.AreaFlowAperturesMean, structure.AreaFlowApertures.Mean.Value); Assert.AreEqual(entity.AreaFlowAperturesStandardDeviation, structure.AreaFlowApertures.StandardDeviation.Value); Assert.AreEqual((StabilityPointStructureInflowModelType)entity.InflowModelType, structure.InflowModelType); }
private static void AssertStabilityPointStructureInput(StabilityPointStructure expectedStructure, StabilityPointStructuresInput input) { if (expectedStructure == null) { Assert.IsNull(input.Structure); var defaultInput = new StabilityPointStructuresInput(); AssertAreEqual(defaultInput.StructureNormalOrientation, input.StructureNormalOrientation); DistributionAssert.AreEqual(defaultInput.AllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage); DistributionAssert.AreEqual(defaultInput.AreaFlowApertures, input.AreaFlowApertures); DistributionAssert.AreEqual(defaultInput.BankWidth, input.BankWidth); DistributionAssert.AreEqual(defaultInput.ConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel); DistributionAssert.AreEqual(defaultInput.ConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel); DistributionAssert.AreEqual(defaultInput.CriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge); AssertAreEqual(defaultInput.EvaluationLevel, input.EvaluationLevel); DistributionAssert.AreEqual(defaultInput.FailureCollisionEnergy, input.FailureCollisionEnergy); Assert.AreEqual(defaultInput.FailureProbabilityRepairClosure, input.FailureProbabilityRepairClosure); DistributionAssert.AreEqual(defaultInput.FlowVelocityStructureClosable, input.FlowVelocityStructureClosable); DistributionAssert.AreEqual(defaultInput.FlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection); Assert.AreEqual(defaultInput.InflowModelType, input.InflowModelType); DistributionAssert.AreEqual(defaultInput.InsideWaterLevel, input.InsideWaterLevel); DistributionAssert.AreEqual(defaultInput.InsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction); DistributionAssert.AreEqual(defaultInput.LevelCrestStructure, input.LevelCrestStructure); Assert.AreEqual(defaultInput.LevellingCount, input.LevellingCount); Assert.AreEqual(defaultInput.ProbabilityCollisionSecondaryStructure, input.ProbabilityCollisionSecondaryStructure); DistributionAssert.AreEqual(defaultInput.ShipMass, input.ShipMass); DistributionAssert.AreEqual(defaultInput.ShipVelocity, input.ShipVelocity); DistributionAssert.AreEqual(defaultInput.StabilityLinearLoadModel, input.StabilityLinearLoadModel); DistributionAssert.AreEqual(defaultInput.StabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel); DistributionAssert.AreEqual(defaultInput.StorageStructureArea, input.StorageStructureArea); DistributionAssert.AreEqual(defaultInput.ThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir); AssertAreEqual(defaultInput.VerticalDistance, input.VerticalDistance); DistributionAssert.AreEqual(defaultInput.WidthFlowApertures, input.WidthFlowApertures); Assert.AreEqual(defaultInput.StructureNormalOrientation, input.StructureNormalOrientation); } else { DistributionAssert.AreEqual(expectedStructure.AllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage); DistributionAssert.AreEqual(expectedStructure.AreaFlowApertures, input.AreaFlowApertures); DistributionAssert.AreEqual(expectedStructure.BankWidth, input.BankWidth); DistributionAssert.AreEqual(expectedStructure.ConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel); DistributionAssert.AreEqual(expectedStructure.ConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel); DistributionAssert.AreEqual(expectedStructure.CriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge); AssertAreEqual(expectedStructure.EvaluationLevel, input.EvaluationLevel); DistributionAssert.AreEqual(expectedStructure.FailureCollisionEnergy, input.FailureCollisionEnergy); Assert.AreEqual(expectedStructure.FailureProbabilityRepairClosure, input.FailureProbabilityRepairClosure); DistributionAssert.AreEqual(expectedStructure.FlowVelocityStructureClosable, input.FlowVelocityStructureClosable); DistributionAssert.AreEqual(expectedStructure.FlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection); Assert.AreEqual(expectedStructure.InflowModelType, input.InflowModelType); DistributionAssert.AreEqual(expectedStructure.InsideWaterLevel, input.InsideWaterLevel); DistributionAssert.AreEqual(expectedStructure.InsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction); DistributionAssert.AreEqual(expectedStructure.LevelCrestStructure, input.LevelCrestStructure); Assert.AreEqual(expectedStructure.LevellingCount, input.LevellingCount); Assert.AreEqual(expectedStructure.ProbabilityCollisionSecondaryStructure, input.ProbabilityCollisionSecondaryStructure); DistributionAssert.AreEqual(expectedStructure.ShipMass, input.ShipMass); DistributionAssert.AreEqual(expectedStructure.ShipVelocity, input.ShipVelocity); DistributionAssert.AreEqual(expectedStructure.StabilityLinearLoadModel, input.StabilityLinearLoadModel); DistributionAssert.AreEqual(expectedStructure.StabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel); DistributionAssert.AreEqual(expectedStructure.StorageStructureArea, input.StorageStructureArea); DistributionAssert.AreEqual(expectedStructure.ThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir); AssertAreEqual(expectedStructure.VerticalDistance, input.VerticalDistance); DistributionAssert.AreEqual(expectedStructure.WidthFlowApertures, input.WidthFlowApertures); AssertAreEqual(expectedStructure.StructureNormalOrientation, input.StructureNormalOrientation); } }
/// <summary> /// Registers a create operation for <paramref name="model"/> and the <paramref name="entity"/> /// that was constructed with the information. /// </summary> /// <param name="entity">The <see cref="StabilityPointStructureEntity"/> to be registered.</param> /// <param name="model">The <see cref="StabilityPointStructure"/> to be registered.</param> /// <exception cref="ArgumentNullException">Thrown when any of the input parameters is <c>null</c>.</exception> internal void Register(StabilityPointStructureEntity entity, StabilityPointStructure model) { Register(stabilityPointStructures, entity, model); }
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); }
/// <summary> /// Obtains the <see cref="StabilityPointStructureEntity"/> which was registered for the /// given <paramref name="model"/>. /// </summary> /// <param name="model">The <see cref="StabilityPointStructure"/> for which a read operation has been registered.</param> /// <returns>The constructed <see cref="StabilityPointStructureEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="model"/> is <c>null</c>.</exception> /// <exception cref="InvalidOperationException">Thrown when no create operation /// has been registered for <paramref name="model"/>.</exception> /// <remarks>Use <see cref="Contains(StabilityPointStructure)"/> to find out whether a /// create operation has been registered for <paramref name="model"/>.</remarks> internal StabilityPointStructureEntity Get(StabilityPointStructure model) { return(Get(stabilityPointStructures, model)); }
public void Read_NullValues_ReturnStabilityPointStructureWithNaN() { // Setup var entity = new StabilityPointStructureEntity { Name = "A", Id = "B", X = null, Y = null, StructureNormalOrientation = null, StorageStructureAreaMean = null, StorageStructureAreaCoefficientOfVariation = null, AllowedLevelIncreaseStorageMean = null, AllowedLevelIncreaseStorageStandardDeviation = null, WidthFlowAperturesMean = null, WidthFlowAperturesStandardDeviation = null, InsideWaterLevelMean = null, InsideWaterLevelStandardDeviation = null, ThresholdHeightOpenWeirMean = null, ThresholdHeightOpenWeirStandardDeviation = null, CriticalOvertoppingDischargeMean = null, CriticalOvertoppingDischargeCoefficientOfVariation = null, FlowWidthAtBottomProtectionMean = null, FlowWidthAtBottomProtectionStandardDeviation = null, ConstructiveStrengthLinearLoadModelMean = null, ConstructiveStrengthLinearLoadModelCoefficientOfVariation = null, ConstructiveStrengthQuadraticLoadModelMean = null, ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = null, BankWidthMean = null, BankWidthStandardDeviation = null, InsideWaterLevelFailureConstructionMean = null, InsideWaterLevelFailureConstructionStandardDeviation = null, EvaluationLevel = null, LevelCrestStructureMean = null, LevelCrestStructureStandardDeviation = null, VerticalDistance = null, FailureProbabilityRepairClosure = null, FailureCollisionEnergyMean = null, FailureCollisionEnergyCoefficientOfVariation = null, ShipMassMean = null, ShipMassCoefficientOfVariation = null, ShipVelocityMean = null, ShipVelocityCoefficientOfVariation = null, ProbabilityCollisionSecondaryStructure = null, FlowVelocityStructureClosableMean = null, StabilityLinearLoadModelMean = null, StabilityLinearLoadModelCoefficientOfVariation = null, AreaFlowAperturesMean = null, AreaFlowAperturesStandardDeviation = null }; var collector = new ReadConversionCollector(); // Call StabilityPointStructure structure = entity.Read(collector); // Assert Assert.IsNaN(structure.Location.X); Assert.IsNaN(structure.Location.Y); Assert.IsNaN(structure.StructureNormalOrientation); Assert.IsNaN(structure.StorageStructureArea.Mean); Assert.IsNaN(structure.StorageStructureArea.CoefficientOfVariation); Assert.IsNaN(structure.AllowedLevelIncreaseStorage.Mean); Assert.IsNaN(structure.AllowedLevelIncreaseStorage.StandardDeviation); Assert.IsNaN(structure.WidthFlowApertures.Mean); Assert.IsNaN(structure.WidthFlowApertures.StandardDeviation); Assert.IsNaN(structure.InsideWaterLevel.Mean); Assert.IsNaN(structure.InsideWaterLevel.StandardDeviation); Assert.IsNaN(structure.ThresholdHeightOpenWeir.Mean); Assert.IsNaN(structure.ThresholdHeightOpenWeir.StandardDeviation); Assert.IsNaN(structure.CriticalOvertoppingDischarge.Mean); Assert.IsNaN(structure.CriticalOvertoppingDischarge.CoefficientOfVariation); Assert.IsNaN(structure.FlowWidthAtBottomProtection.Mean); Assert.IsNaN(structure.FlowWidthAtBottomProtection.StandardDeviation); Assert.IsNaN(structure.ConstructiveStrengthLinearLoadModel.Mean); Assert.IsNaN(structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation); Assert.IsNaN(structure.ConstructiveStrengthQuadraticLoadModel.Mean); Assert.IsNaN(structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation); Assert.IsNaN(structure.BankWidth.Mean); Assert.IsNaN(structure.BankWidth.StandardDeviation); Assert.IsNaN(structure.InsideWaterLevelFailureConstruction.Mean); Assert.IsNaN(structure.InsideWaterLevelFailureConstruction.StandardDeviation); Assert.IsNaN(structure.EvaluationLevel); Assert.IsNaN(structure.LevelCrestStructure.Mean); Assert.IsNaN(structure.LevelCrestStructure.StandardDeviation); Assert.IsNaN(structure.VerticalDistance); Assert.IsNaN(structure.FailureProbabilityRepairClosure); Assert.IsNaN(structure.FailureCollisionEnergy.Mean); Assert.IsNaN(structure.FailureCollisionEnergy.CoefficientOfVariation); Assert.IsNaN(structure.ShipMass.Mean); Assert.IsNaN(structure.ShipMass.CoefficientOfVariation); Assert.IsNaN(structure.ShipVelocity.Mean); Assert.IsNaN(structure.ShipVelocity.CoefficientOfVariation); Assert.IsNaN(structure.ProbabilityCollisionSecondaryStructure); Assert.IsNaN(structure.FlowVelocityStructureClosable.Mean); Assert.IsNaN(structure.StabilityLinearLoadModel.Mean); Assert.IsNaN(structure.StabilityLinearLoadModel.CoefficientOfVariation); Assert.IsNaN(structure.StabilityQuadraticLoadModel.Mean); Assert.IsNaN(structure.StabilityQuadraticLoadModel.CoefficientOfVariation); Assert.IsNaN(structure.AreaFlowApertures.Mean); Assert.IsNaN(structure.AreaFlowApertures.StandardDeviation); }