Beispiel #1
0
        private static void AddEntitiesForFailureMechanismMeta(GrassCoverErosionOutwardsFailureMechanism failureMechanism,
                                                               FailureMechanismEntity entity)
        {
            var metaEntity = new GrassCoverErosionOutwardsFailureMechanismMetaEntity
            {
                ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone(),
                N = failureMechanism.GeneralInput.N,
                ApplyLengthEffectInSection = Convert.ToByte(failureMechanism.GeneralInput.ApplyLengthEffectInSection)
            };

            entity.GrassCoverErosionOutwardsFailureMechanismMetaEntities.Add(metaEntity);
        }
        public void Read_GeneralInputNull_ThrowArgumentNullException()
        {
            // Setup
            var entity = new GrassCoverErosionOutwardsFailureMechanismMetaEntity();

            // Call
            TestDelegate call = () => entity.Read(null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("input", paramName);
        }
        public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool inAssembly)
        {
            // Setup
            var random           = new Random();
            var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism
            {
                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.GrassRevetmentErosionOutwards, 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);

            Assert.AreEqual(1, entity.GrassCoverErosionOutwardsFailureMechanismMetaEntities.Count);
            GrassCoverErosionOutwardsFailureMechanismMetaEntity generalInputEntity = entity.GrassCoverErosionOutwardsFailureMechanismMetaEntities.Single();

            Assert.AreEqual(failureMechanism.GeneralInput.N, generalInputEntity.N);
            Assert.AreEqual(Convert.ToByte(failureMechanism.GeneralInput.ApplyLengthEffectInSection), generalInputEntity.ApplyLengthEffectInSection);
        }
Beispiel #4
0
        /// <summary>
        /// Read the <see cref="GrassCoverErosionOutwardsFailureMechanismMetaEntity"/> and use the information
        /// to update the <paramref name="input"/>.
        /// </summary>
        /// <param name="entity">The <see cref="GrassCoverErosionOutwardsFailureMechanismMetaEntity"/> to use
        /// to update the <paramref name="input"/>.</param>
        /// <param name="input">The <see cref="GeneralGrassCoverErosionOutwardsInput"/> to be updated.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static void Read(this GrassCoverErosionOutwardsFailureMechanismMetaEntity entity, GeneralGrassCoverErosionOutwardsInput input)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

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

            input.N = (RoundedDouble)entity.N;
            input.ApplyLengthEffectInSection = Convert.ToBoolean(entity.ApplyLengthEffectInSection);
        }
        public void Create_WithoutForeshoreProfiles_EmptyForeshoreProfilesEntities()
        {
            // Setup
            var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();

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

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

            GrassCoverErosionOutwardsFailureMechanismMetaEntity metaEntity =
                entity.GrassCoverErosionOutwardsFailureMechanismMetaEntities.Single();

            Assert.IsNull(metaEntity.ForeshoreProfileCollectionSourcePath);
        }
        public void Read_ValidEntity_ReturnGeneralGrassCoverErosionOutwardsInput()
        {
            // Setup
            var random        = new Random();
            var inputToUpdate = new GeneralGrassCoverErosionOutwardsInput();
            var entity        = new GrassCoverErosionOutwardsFailureMechanismMetaEntity
            {
                N = random.NextRoundedDouble(1.0, 20.0),
                ApplyLengthEffectInSection = Convert.ToByte(random.NextBoolean())
            };

            // Call
            entity.Read(inputToUpdate);

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

            GrassCoverErosionOutwardsFailureMechanismMetaEntity metaEntity =
                entity.GrassCoverErosionOutwardsFailureMechanismMetaEntities.Single();
            string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath);
        }