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);
        }
        public void Read_GeneralInputNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new WaveImpactAsphaltCoverFailureMechanismMetaEntity();

            // Call
            void Call() => entity.Read(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("generalInput", exception.ParamName);
        }
示例#3
0
        /// <summary>
        /// Read the <see cref="WaveImpactAsphaltCoverFailureMechanismMetaEntity"/> and use the information to
        /// construct a <see cref="GeneralWaveImpactAsphaltCoverInput"/>.
        /// </summary>
        /// <param name="entity">The <see cref="WaveImpactAsphaltCoverFailureMechanismMetaEntity"/> to update
        /// <see cref="GeneralWaveImpactAsphaltCoverInput"/> for.</param>
        /// <param name="generalInput">The <see cref="GeneralWaveImpactAsphaltCoverInput"/> to update.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static void Read(this WaveImpactAsphaltCoverFailureMechanismMetaEntity entity, GeneralWaveImpactAsphaltCoverInput generalInput)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            generalInput.DeltaL = (RoundedDouble)entity.DeltaL;
            generalInput.ApplyLengthEffectInSection = Convert.ToBoolean(entity.ApplyLengthEffectInSection);
        }
        public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool inAssembly)
        {
            // Setup
            var random           = new Random();
            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism
            {
                InAssembly = inAssembly,
                InAssemblyInputComments =
                {
                    Body = "Some input text"
                },
                InAssemblyOutputComments =
                {
                    Body = "Some output text"
                },
                NotInAssemblyComments =
                {
                    Body = "Really not in assembly"
                },
                CalculationsInputComments =
                {
                    Body = "Some calculation text"
                },
                GeneralWaveImpactAsphaltCoverInput =
                {
                    DeltaL                     = random.NextRoundedDouble(0.1, 2000.0),
                    ApplyLengthEffectInSection = random.NextBoolean()
                }
            };
            var registry = new PersistenceRegistry();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual((short)FailureMechanismType.WaveImpactOnAsphaltRevetment, 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);
            GeneralWaveImpactAsphaltCoverInput generalInput             = failureMechanism.GeneralWaveImpactAsphaltCoverInput;
            WaveImpactAsphaltCoverFailureMechanismMetaEntity metaEntity = entity.WaveImpactAsphaltCoverFailureMechanismMetaEntities.Single();

            Assert.AreEqual(generalInput.DeltaL, metaEntity.DeltaL);
            Assert.AreEqual(Convert.ToByte(generalInput.ApplyLengthEffectInSection), metaEntity.ApplyLengthEffectInSection);
        }
        public void Create_WithoutForeshoreProfiles_EmptyForeshoreProfilesEntities()
        {
            // Setup
            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(new PersistenceRegistry());

            // Assert
            CollectionAssert.IsEmpty(entity.ForeshoreProfileEntities);

            WaveImpactAsphaltCoverFailureMechanismMetaEntity metaEntity =
                entity.WaveImpactAsphaltCoverFailureMechanismMetaEntities.Single();

            Assert.IsNull(metaEntity.ForeshoreProfileCollectionSourcePath);
        }
        public void Read_WithAllData_SetsGeneralInputProperties()
        {
            // Setup
            var random = new Random();
            var entity = new WaveImpactAsphaltCoverFailureMechanismMetaEntity
            {
                DeltaL = random.NextDouble(1, 2000),
                ApplyLengthEffectInSection = Convert.ToByte(random.NextBoolean())
            };

            var generalInput = new GeneralWaveImpactAsphaltCoverInput();

            // Call
            entity.Read(generalInput);

            // Assert
            Assert.AreEqual(entity.DeltaL, generalInput.DeltaL, generalInput.DeltaL.GetAccuracy());
            Assert.AreEqual(Convert.ToBoolean(entity.ApplyLengthEffectInSection), generalInput.ApplyLengthEffectInSection);
        }
        public void Create_WithForeshoreProfiles_ForeshoreProfilesEntitiesCreated()
        {
            // Setup
            var          failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
            const string filePath         = "some/path/to/foreshoreProfiles";

            failureMechanism.ForeshoreProfiles.AddRange(new[]
            {
                new TestForeshoreProfile()
            }, filePath);

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(new PersistenceRegistry());

            // Assert
            Assert.AreEqual(1, entity.ForeshoreProfileEntities.Count);

            WaveImpactAsphaltCoverFailureMechanismMetaEntity metaEntity =
                entity.WaveImpactAsphaltCoverFailureMechanismMetaEntities.Single();
            string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath);
        }