public void Create_WithCalculationGroup_ReturnFailureMechanismEntityWithCalculationGroupEntities(bool inAssembly) { // Setup var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new CalculationGroup { Name = "A" }); failureMechanism.CalculationsGroup.Children.Add(new CalculationGroup { Name = "B" }); var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual(failureMechanism.CalculationsGroup.Name, entity.CalculationGroupEntity.Name); Assert.AreEqual(0, entity.CalculationGroupEntity.Order); CalculationGroupEntity[] childGroupEntities = entity.CalculationGroupEntity.CalculationGroupEntity1 .OrderBy(cge => cge.Order) .ToArray(); Assert.AreEqual(2, childGroupEntities.Length); Assert.AreEqual("A", childGroupEntities[0].Name); Assert.AreEqual(0, childGroupEntities[0].Order); Assert.AreEqual("B", childGroupEntities[1].Name); Assert.AreEqual(1, childGroupEntities[1].Order); }
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 Create_WithForeshoreProfiles_ForeshoreProfileEntitiesCreated() { // Setup var profile = new TestForeshoreProfile(); var failureMechanism = new HeightStructuresFailureMechanism(); const string filePath = "some/path/to/foreshoreProfiles"; failureMechanism.ForeshoreProfiles.AddRange(new[] { profile }, filePath); var persistenceRegistry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry); // Assert Assert.AreEqual(1, entity.ForeshoreProfileEntities.Count); Assert.IsTrue(persistenceRegistry.Contains(profile)); HeightStructuresFailureMechanismMetaEntity metaEntity = entity.HeightStructuresFailureMechanismMetaEntities.Single(); string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath; TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath); }
public void Create_WithStochasticSoilModels_ReturnsFailureMechanismEntityWithStochasticSoilModelEntities() { // Setup var failureMechanism = new PipingFailureMechanism(); PipingStochasticSoilModelCollection stochasticSoilModels = failureMechanism.StochasticSoilModels; stochasticSoilModels.AddRange(new[] { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("name"), PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("name2") }, "some/path/to/file"); var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual(stochasticSoilModels.Count, entity.StochasticSoilModelEntities.Count); for (var i = 0; i < stochasticSoilModels.Count; i++) { AssertStochasticSoilModel(stochasticSoilModels[i], entity.StochasticSoilModelEntities.ElementAt(i)); } string stochasticSoilModelCollectionSourcePath = entity.PipingFailureMechanismMetaEntities .Single() .StochasticSoilModelCollectionSourcePath; TestHelper.AssertAreEqualButNotSame(stochasticSoilModels.SourcePath, stochasticSoilModelCollectionSourcePath); }
public void Create_WithDuneLocations_ReturnsEntityWithDuneLocations() { // Setup var duneLocation = new TestDuneLocation(); var failureMechanism = new DuneErosionFailureMechanism { DuneLocationCalculationsForUserDefinedTargetProbabilities = { new DuneLocationCalculationsForTargetProbability(0.1), new DuneLocationCalculationsForTargetProbability(0.01) } }; failureMechanism.SetDuneLocations(new[] { duneLocation }); var duneLocationEntity = new DuneLocationEntity(); var registry = new PersistenceRegistry(); registry.Register(duneLocationEntity, duneLocation); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert DuneLocationEntity actualDuneLocationEntity = entity.DuneLocationEntities.Single(); Assert.AreSame(duneLocationEntity, actualDuneLocationEntity); DuneErosionFailureMechanismMetaEntity metaEntity = entity.DuneErosionFailureMechanismMetaEntities.Single(); AssertDuneLocationCalculationCollectionEntities(failureMechanism, metaEntity); }
public void Create_WithSurfaceLines_ReturnFailureMechanismEntityWithSurfaceLineEntities() { // Setup var failureMechanism = new PipingFailureMechanism(); PipingSurfaceLineCollection surfaceLines = failureMechanism.SurfaceLines; surfaceLines.AddRange(new[] { CreateSurfaceLine(new Random(31)) }, "path"); var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual(surfaceLines.Count, entity.SurfaceLineEntities.Count); for (var i = 0; i < surfaceLines.Count; i++) { AssertSurfaceLine(surfaceLines[i], entity.SurfaceLineEntities.ElementAt(i)); } string surfaceLineCollectionSourcePath = entity.PipingFailureMechanismMetaEntities .Single() .SurfaceLineCollectionSourcePath; TestHelper.AssertAreEqualButNotSame(surfaceLines.SourcePath, surfaceLineCollectionSourcePath); }
public void Create_WithSections_ReturnsWithFailureMechanismSectionEntitiesAndPipingResultEntities() { // Setup const string filePath = "failureMechanismSections/File/Path"; var failureMechanism = new PipingFailureMechanism(); failureMechanism.SetSections(new[] { FailureMechanismSectionTestFactory.CreateFailureMechanismSection() }, filePath); var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); ICollection <FailureMechanismSectionEntity> failureMechanismSectionEntities = entity.FailureMechanismSectionEntities; Assert.AreEqual(1, failureMechanismSectionEntities.Count); Assert.AreEqual(1, failureMechanismSectionEntities.SelectMany(fms => fms.AdoptableWithProfileProbabilityFailureMechanismSectionResultEntities) .Count()); Assert.AreEqual(1, failureMechanismSectionEntities.SelectMany(fms => fms.PipingScenarioConfigurationPerFailureMechanismSectionEntities) .Count()); TestHelper.AssertAreEqualButNotSame(filePath, entity.FailureMechanismSectionCollectionSourcePath); }
public void Create_StringPropertiesDoNotShareReference() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism { InAssemblyInputComments = { Body = "Some input text" }, InAssemblyOutputComments = { Body = "Some output text" }, NotInAssemblyComments = { Body = "Really not in assembly" }, CalculationsInputComments = { Body = "Some calculation text" } }; var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert TestHelper.AssertAreEqualButNotSame(failureMechanism.InAssemblyInputComments.Body, entity.InAssemblyInputComments); TestHelper.AssertAreEqualButNotSame(failureMechanism.InAssemblyOutputComments.Body, entity.InAssemblyOutputComments); TestHelper.AssertAreEqualButNotSame(failureMechanism.NotInAssemblyComments.Body, entity.NotInAssemblyComments); TestHelper.AssertAreEqualButNotSame(failureMechanism.CalculationsInputComments.Body, entity.CalculationsInputComments); }
public void Create_WithClosingStructures_ClosingStructureEntitiesCreated() { // Setup ClosingStructure structure = new TestClosingStructure(); var failureMechanism = new ClosingStructuresFailureMechanism(); const string filePath = "some path"; failureMechanism.ClosingStructures.AddRange(new[] { structure }, filePath); var persistenceRegistry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry); // Assert Assert.AreEqual(1, entity.ClosingStructureEntities.Count); Assert.IsTrue(persistenceRegistry.Contains(structure)); ClosingStructuresFailureMechanismMetaEntity metaEntity = entity.ClosingStructuresFailureMechanismMetaEntities.Single(); string entitySourcePath = metaEntity.ClosingStructureCollectionSourcePath; TestHelper.AssertAreEqualButNotSame(filePath, entitySourcePath); }
public void Create_WithDikeProfiles_AddDikeProfileEntities() { // Setup const string filePath = "some/path/to/my/dikeprofiles"; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.DikeProfiles.AddRange(new[] { DikeProfileTestFactory.CreateDikeProfile(string.Empty, "id1"), DikeProfileTestFactory.CreateDikeProfile(string.Empty, "id2") }, filePath); var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.AreEqual(2, entity.DikeProfileEntities.Count); GrassCoverErosionInwardsFailureMechanismMetaEntity generalInputEntity = entity.GrassCoverErosionInwardsFailureMechanismMetaEntities.Single(); TestHelper.AssertAreEqualButNotSame(filePath, generalInputEntity.DikeProfileCollectionSourcePath); }
public void Create_WithoutAllPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet() { // Setup var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual((short)FailureMechanismType.MacroStabilityInwards, entity.FailureMechanismType); Assert.AreEqual(Convert.ToByte(failureMechanism.InAssembly), entity.InAssembly); Assert.AreEqual(failureMechanism.InAssemblyInputComments.Body, entity.InAssemblyInputComments); Assert.AreEqual(failureMechanism.InAssemblyOutputComments.Body, entity.InAssemblyOutputComments); Assert.AreEqual(failureMechanism.NotInAssemblyComments.Body, entity.NotInAssemblyComments); Assert.AreEqual(failureMechanism.CalculationsInputComments.Body, entity.CalculationsInputComments); Assert.AreEqual(failureMechanism.FailureMechanismSectionSourcePath, entity.FailureMechanismSectionCollectionSourcePath); CollectionAssert.IsEmpty(entity.StochasticSoilModelEntities); MacroStabilityInwardsFailureMechanismMetaEntity failureMechanismMetaEntity = entity.MacroStabilityInwardsFailureMechanismMetaEntities.Single(); Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.A, failureMechanismMetaEntity.A); Assert.AreEqual(failureMechanism.SurfaceLines.SourcePath, failureMechanismMetaEntity.SurfaceLineCollectionSourcePath); Assert.AreEqual(failureMechanism.StochasticSoilModels.SourcePath, failureMechanismMetaEntity.StochasticSoilModelCollectionSourcePath); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="PipingStructureFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this PipingStructureFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.PipingAtStructure, registry); AddEntitiesForSectionResults(mechanism.SectionResults, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); return(entity); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="MicrostabilityFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this MicrostabilityFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.Microstability, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); AddEntitiesForSectionResults(mechanism.SectionResults, registry); return(entity); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="WaterPressureAsphaltCoverFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this WaterPressureAsphaltCoverFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.WaterOverpressureAsphaltRevetment, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); AddEntitiesForSectionResults(mechanism.SectionResults, registry); return(entity); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="GrassCoverSlipOffInwardsFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this GrassCoverSlipOffInwardsFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.GrassRevetmentSlidingInwards, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); AddEntitiesForSectionResults(mechanism.SectionResults, registry); return(entity); }
public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet() { // Setup var random = new Random(31); var failureMechanism = new PipingFailureMechanism { InAssembly = random.NextBoolean(), InAssemblyInputComments = { Body = "Some input text" }, InAssemblyOutputComments = { Body = "Some output text" }, NotInAssemblyComments = { Body = "Really not in assembly" }, CalculationsInputComments = { Body = "Some calculation text" }, PipingProbabilityAssessmentInput = { A = random.NextDouble() }, GeneralInput = { WaterVolumetricWeight = random.NextRoundedDouble(0, 20) }, ScenarioConfigurationType = random.NextEnumValue <PipingScenarioConfigurationType>() }; var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual((short)FailureMechanismType.Piping, entity.FailureMechanismType); Assert.AreEqual(Convert.ToByte(failureMechanism.InAssembly), entity.InAssembly); Assert.AreEqual(failureMechanism.InAssemblyInputComments.Body, entity.InAssemblyInputComments); Assert.AreEqual(failureMechanism.InAssemblyOutputComments.Body, entity.InAssemblyOutputComments); Assert.AreEqual(failureMechanism.NotInAssemblyComments.Body, entity.NotInAssemblyComments); Assert.AreEqual(failureMechanism.CalculationsInputComments.Body, entity.CalculationsInputComments); CollectionAssert.IsEmpty(entity.StochasticSoilModelEntities); CollectionAssert.IsEmpty(entity.SurfaceLineEntities); PipingFailureMechanismMetaEntity failureMechanismMetaEntity = entity.PipingFailureMechanismMetaEntities.ToArray()[0]; Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.A, failureMechanismMetaEntity.A); Assert.AreEqual(failureMechanism.GeneralInput.WaterVolumetricWeight.Value, failureMechanismMetaEntity.WaterVolumetricWeight); Assert.AreEqual(failureMechanism.SurfaceLines.SourcePath, failureMechanismMetaEntity.SurfaceLineCollectionSourcePath); Assert.AreEqual(failureMechanism.StochasticSoilModels.SourcePath, failureMechanismMetaEntity.StochasticSoilModelCollectionSourcePath); Assert.AreEqual(Convert.ToByte(failureMechanism.ScenarioConfigurationType), failureMechanismMetaEntity.PipingScenarioConfigurationType); }
private static void AddEntitiesForFailureMechanismMeta(PipingStructureFailureMechanism failureMechanism, FailureMechanismEntity entity) { var metaEntity = new PipingStructureFailureMechanismMetaEntity { N = failureMechanism.GeneralInput.N }; entity.PipingStructureFailureMechanismMetaEntities.Add(metaEntity); }
private static void AddEntitiesForSurfaceLines(MacroStabilityInwardsFailureMechanism mechanism, PersistenceRegistry registry, FailureMechanismEntity entity) { var index = 0; foreach (MacroStabilityInwardsSurfaceLine surfaceLine in mechanism.SurfaceLines) { entity.SurfaceLineEntities.Add(surfaceLine.Create(registry, index++)); } }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="GrassCoverErosionOutwardsFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this GrassCoverErosionOutwardsFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.GrassRevetmentErosionOutwards, registry); AddEntitiesForSectionResults(mechanism.SectionResults, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); AddEntitiesForForeshoreProfiles(mechanism.ForeshoreProfiles, entity, registry); entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); return(entity); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="DuneErosionFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this DuneErosionFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.DuneErosion, registry); entity.CalculationsInputComments = mechanism.CalculationsInputComments.Body.DeepClone(); AddEntitiesForSectionResults(mechanism.SectionResults, registry); AddEntitiesForDuneLocations(mechanism.DuneLocations, entity, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity, registry); return(entity); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="GrassCoverErosionInwardsFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this GrassCoverErosionInwardsFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.GrassRevetmentTopErosionAndInwards, registry); AddEntitiesForGeneralInput(mechanism, entity); AddEntitiesForDikeProfiles(mechanism, registry, entity); entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); AddEntitiesForSectionResults(mechanism.SectionResults, registry); return(entity); }
private static void AddEntitiesForForeshoreProfiles( ForeshoreProfileCollection foreshoreProfiles, FailureMechanismEntity entity, PersistenceRegistry registry) { for (var i = 0; i < foreshoreProfiles.Count; i++) { ForeshoreProfileEntity foreshoreProfileEntity = foreshoreProfiles[i].Create(registry, i); entity.ForeshoreProfileEntities.Add(foreshoreProfileEntity); } }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="WaveImpactAsphaltCoverFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this WaveImpactAsphaltCoverFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.WaveImpactOnAsphaltRevetment, registry); AddEntitiesForSectionResults(mechanism.SectionResults, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); AddEntitiesForForeshoreProfiles(mechanism.ForeshoreProfiles, entity, registry); entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); return(entity); }
private static void AddEntitiesForHeightStructures( StructureCollection <HeightStructure> structures, FailureMechanismEntity entity, PersistenceRegistry registry) { for (var i = 0; i < structures.Count; i++) { HeightStructureEntity structureEntity = structures[i].Create(registry, i); entity.HeightStructureEntities.Add(structureEntity); } }
private static void AddEntitiesForStochasticSoilModels(MacroStabilityInwardsFailureMechanism mechanism, PersistenceRegistry registry, FailureMechanismEntity entity) { var index = 0; foreach (MacroStabilityInwardsStochasticSoilModel stochasticSoilModel in mechanism.StochasticSoilModels) { entity.StochasticSoilModelEntities.Add(stochasticSoilModel.Create(registry, index++)); } }
public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); // Call FailureMechanismEntity entity = failureMechanism.Create(new PersistenceRegistry()); // Assert CollectionAssert.IsEmpty(entity.FailureMechanismSectionEntities); Assert.IsNull(entity.FailureMechanismSectionCollectionSourcePath); }
private static void AddEntitiesForFailureMechanismMeta(StabilityStoneCoverFailureMechanism failureMechanism, FailureMechanismEntity entity) { var metaEntity = new StabilityStoneCoverFailureMechanismMetaEntity { ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone(), N = failureMechanism.GeneralInput.N, ApplyLengthEffectInSection = Convert.ToByte(failureMechanism.GeneralInput.ApplyLengthEffectInSection) }; entity.StabilityStoneCoverFailureMechanismMetaEntities.Add(metaEntity); }
/// <summary> /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="HeightStructuresFailureMechanism"/>. /// </summary> /// <param name="mechanism">The failure mechanism to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> internal static FailureMechanismEntity Create(this HeightStructuresFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.StructureHeight, registry); AddEntitiesForForeshoreProfiles(mechanism.ForeshoreProfiles, entity, registry); AddEntitiesForHeightStructures(mechanism.HeightStructures, entity, registry); AddEntitiesForFailureMechanismMeta(mechanism, entity); entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); AddEntitiesForSectionResults(mechanism.SectionResults, registry); return(entity); }
public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() { // Setup var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); // Call FailureMechanismEntity entity = failureMechanism.Create(new PersistenceRegistry()); // Assert CollectionAssert.IsEmpty(entity.FailureMechanismSectionEntities); Assert.IsNull(failureMechanism.FailureMechanismSectionSourcePath); }
private static void AddEntitiesForFailureMechanismMeta(WaveImpactAsphaltCoverFailureMechanism failureMechanism, FailureMechanismEntity entity) { var metaEntity = new WaveImpactAsphaltCoverFailureMechanismMetaEntity { ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone(), DeltaL = failureMechanism.GeneralWaveImpactAsphaltCoverInput.DeltaL, ApplyLengthEffectInSection = Convert.ToByte(failureMechanism.GeneralWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection) }; entity.WaveImpactAsphaltCoverFailureMechanismMetaEntities.Add(metaEntity); }