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

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

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

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

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

            generalInput.N = (RoundedDouble)entity.N;
            generalInput.ApplyLengthEffectInSection = Convert.ToBoolean(entity.ApplyLengthEffectInSection);
        }
        public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool inAssembly)
        {
            // Setup
            var random           = new Random();
            var failureMechanism = new StabilityStoneCoverFailureMechanism
            {
                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                          = random.NextRoundedDouble(1, 20),
                    ApplyLengthEffectInSection = random.NextBoolean()
                }
            };
            var registry = new PersistenceRegistry();

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

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual((short)FailureMechanismType.StabilityStoneRevetment, 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);
            StabilityStoneCoverFailureMechanismMetaEntity failureMechanismMetaEntity = entity.StabilityStoneCoverFailureMechanismMetaEntities.Single();

            Assert.AreEqual(failureMechanism.GeneralInput.N, failureMechanismMetaEntity.N);
            Assert.AreEqual(Convert.ToByte(failureMechanism.GeneralInput.ApplyLengthEffectInSection)
                            , failureMechanismMetaEntity.ApplyLengthEffectInSection);
        }
        public void Create_WithoutForeshoreProfiles_EmptyForeshoreProfilesEntities()
        {
            // Setup
            var failureMechanism = new StabilityStoneCoverFailureMechanism();

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

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

            StabilityStoneCoverFailureMechanismMetaEntity metaEntity =
                entity.StabilityStoneCoverFailureMechanismMetaEntities.Single();

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

            var generalInput = new GeneralStabilityStoneCoverWaveConditionsInput();

            // Call
            entity.Read(generalInput);

            // Assert
            Assert.AreEqual(entity.N, generalInput.N, generalInput.N.GetAccuracy());
            Assert.AreEqual(Convert.ToBoolean(entity.ApplyLengthEffectInSection), generalInput.ApplyLengthEffectInSection);
        }
        public void Create_WithForeshoreProfiles_ForeshoreProfilesEntitiesCreated()
        {
            // Setup
            var          failureMechanism = new StabilityStoneCoverFailureMechanism();
            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);

            StabilityStoneCoverFailureMechanismMetaEntity metaEntity =
                entity.StabilityStoneCoverFailureMechanismMetaEntities.Single();
            string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath);
        }