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 StabilityPointStructuresFailureMechanism(); 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)); StabilityPointStructuresFailureMechanismMetaEntity metaEntity = entity.StabilityPointStructuresFailureMechanismMetaEntities.Single(); string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath; TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath); }
/// <summary> /// Read the <see cref="StabilityPointStructuresFailureMechanismMetaEntity"/> and use the information /// to construct a <see cref="GeneralStabilityPointStructuresInput"/>. /// </summary> /// <param name="entity">The <see cref="StabilityPointStructuresFailureMechanismMetaEntity"/> to /// create <see cref="GeneralStabilityPointStructuresInput"/> for.</param> /// <returns>A new <see cref="GeneralStabilityPointStructuresInput"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/> is <c>null</c>.</exception> internal static GeneralStabilityPointStructuresInput Read(this StabilityPointStructuresFailureMechanismMetaEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(new GeneralStabilityPointStructuresInput { N = (RoundedDouble)entity.N }); }
private static void AddEntitiesForFailureMechanismMeta( StabilityPointStructuresFailureMechanism failureMechanism, FailureMechanismEntity entity) { var metaEntity = new StabilityPointStructuresFailureMechanismMetaEntity { ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone(), StabilityPointStructureCollectionSourcePath = failureMechanism.StabilityPointStructures.SourcePath.DeepClone(), N = failureMechanism.GeneralInput.N }; entity.StabilityPointStructuresFailureMechanismMetaEntities.Add(metaEntity); }
public void Read_Always_ReturnGeneralStabilityPointStructuresInput() { // Setup var entity = new StabilityPointStructuresFailureMechanismMetaEntity { N = new Random(39).NextRoundedDouble(1.0, 20.0) }; // Call GeneralStabilityPointStructuresInput generalInput = entity.Read(); // Assert Assert.AreEqual(entity.N, generalInput.N, generalInput.N.GetAccuracy()); }
public void Create_WithoutStabilityPointStructures_EmptyStabilityPointStructuresEntities() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); // Call FailureMechanismEntity entity = failureMechanism.Create(new PersistenceRegistry()); // Assert CollectionAssert.IsEmpty(entity.StabilityPointStructureEntities); StabilityPointStructuresFailureMechanismMetaEntity metaEntity = entity.StabilityPointStructuresFailureMechanismMetaEntities.Single(); Assert.IsNull(metaEntity.StabilityPointStructureCollectionSourcePath); }
public void Create_WithCollectorAndPropertiesSet_ReturnsExpectedEntity(bool inAssembly) { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism { InAssembly = inAssembly, InAssemblyInputComments = { Body = "Some input text" }, InAssemblyOutputComments = { Body = "Some output text" }, NotInAssemblyComments = { Body = "Really not in assembly" }, CalculationsInputComments = { Body = "Some calculation text" }, GeneralInput = { N = new Random().NextRoundedDouble(1, 20) } }; var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual((short)FailureMechanismType.StabilityPointStructures, entity.FailureMechanismType); Assert.AreEqual(Convert.ToByte(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); StabilityPointStructuresFailureMechanismMetaEntity metaEntity = entity.StabilityPointStructuresFailureMechanismMetaEntities.Single(); Assert.AreEqual(failureMechanism.GeneralInput.N, metaEntity.N); }