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); }
/// <summary> /// Read the <see cref="ClosingStructuresFailureMechanismMetaEntity"/> and use the information to /// construct a <see cref="GeneralClosingStructuresInput"/>. /// </summary> /// <param name="entity">The <see cref="ClosingStructuresFailureMechanismMetaEntity"/> to create /// <see cref="GeneralClosingStructuresInput"/> for.</param> /// <returns>A new <see cref="GeneralClosingStructuresInput"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/> is <c>null</c>.</exception> internal static GeneralClosingStructuresInput Read(this ClosingStructuresFailureMechanismMetaEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(new GeneralClosingStructuresInput { N2A = entity.N2A }); }
private static void AddEntitiesForFailureMechanismMeta(ClosingStructuresFailureMechanism failureMechanism, FailureMechanismEntity entity) { var metaEntity = new ClosingStructuresFailureMechanismMetaEntity { N2A = failureMechanism.GeneralInput.N2A, ClosingStructureCollectionSourcePath = failureMechanism.ClosingStructures.SourcePath.DeepClone(), ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone() }; entity.ClosingStructuresFailureMechanismMetaEntities.Add(metaEntity); }
public void Read_Always_ReturnGeneralClosingStructuresInput() { // Setup var entity = new ClosingStructuresFailureMechanismMetaEntity { N2A = new Random(39).Next(1, 40) }; // Call GeneralClosingStructuresInput generalInput = entity.Read(); // Assert Assert.AreEqual(entity.N2A, generalInput.N2A); }
public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool inAssembly) { // Setup var failureMechanism = new ClosingStructuresFailureMechanism { InAssembly = inAssembly, InAssemblyInputComments = { Body = "Some input text" }, InAssemblyOutputComments = { Body = "Some output text" }, NotInAssemblyComments = { Body = "Really not in assembly" }, CalculationsInputComments = { Body = "Some calculation text" }, GeneralInput = { N2A = new Random().Next(0, 40) } }; var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual((short)FailureMechanismType.ReliabilityClosingOfStructure, 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); ClosingStructuresFailureMechanismMetaEntity metaEntity = entity.ClosingStructuresFailureMechanismMetaEntities.Single(); Assert.AreEqual(failureMechanism.GeneralInput.N2A, metaEntity.N2A); Assert.IsNull(metaEntity.ForeshoreProfileCollectionSourcePath); Assert.IsNull(metaEntity.ClosingStructureCollectionSourcePath); }