コード例 #1
0
        public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet()
        {
            // Setup
            var random           = new Random(31);
            var failureMechanism = new PipingFailureMechanism
            {
                InAssembly = random.NextBoolean(),
                InAssemblyInputComments =
                {
                    Body = "Some input text"
                },
                InAssemblyOutputComments =
                {
                    Body = "Some output text"
                },
                NotInAssemblyComments =
                {
                    Body = "Really not in assembly"
                },
                CalculationsInputComments =
                {
                    Body = "Some calculation text"
                },
                PipingProbabilityAssessmentInput =
                {
                    A = random.NextDouble()
                },
                GeneralInput =
                {
                    WaterVolumetricWeight = random.NextRoundedDouble(0, 20)
                },
                ScenarioConfigurationType = random.NextEnumValue <PipingScenarioConfigurationType>()
            };
            var registry = new PersistenceRegistry();

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

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual((short)FailureMechanismType.Piping, entity.FailureMechanismType);
            Assert.AreEqual(Convert.ToByte(failureMechanism.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);
            CollectionAssert.IsEmpty(entity.StochasticSoilModelEntities);
            CollectionAssert.IsEmpty(entity.SurfaceLineEntities);

            PipingFailureMechanismMetaEntity failureMechanismMetaEntity = entity.PipingFailureMechanismMetaEntities.ToArray()[0];

            Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.A, failureMechanismMetaEntity.A);
            Assert.AreEqual(failureMechanism.GeneralInput.WaterVolumetricWeight.Value, failureMechanismMetaEntity.WaterVolumetricWeight);
            Assert.AreEqual(failureMechanism.SurfaceLines.SourcePath, failureMechanismMetaEntity.SurfaceLineCollectionSourcePath);
            Assert.AreEqual(failureMechanism.StochasticSoilModels.SourcePath, failureMechanismMetaEntity.StochasticSoilModelCollectionSourcePath);
            Assert.AreEqual(Convert.ToByte(failureMechanism.ScenarioConfigurationType), failureMechanismMetaEntity.PipingScenarioConfigurationType);
        }
コード例 #2
0
        private static void AddEntitiesForFailureMechanismMeta(PipingFailureMechanism mechanism, FailureMechanismEntity entity)
        {
            var metaEntity = new PipingFailureMechanismMetaEntity
            {
                A = mechanism.PipingProbabilityAssessmentInput.A,
                WaterVolumetricWeight = mechanism.GeneralInput.WaterVolumetricWeight,
                StochasticSoilModelCollectionSourcePath = mechanism.StochasticSoilModels.SourcePath.DeepClone(),
                SurfaceLineCollectionSourcePath         = mechanism.SurfaceLines.SourcePath.DeepClone(),
                PipingScenarioConfigurationType         = Convert.ToByte(mechanism.ScenarioConfigurationType)
            };

            entity.PipingFailureMechanismMetaEntities.Add(metaEntity);
        }
        public void ReadGeneralPipingInput_GeneralPipingInputNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new PipingFailureMechanismMetaEntity();

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

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

            Assert.AreEqual("generalPipingInput", exception.ParamName);
        }
        public void ReadFailureMechanismValues_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new PipingFailureMechanismMetaEntity();

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

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
        public void ReadProbabilityAssessmentInput_ValidParameters_SetPipingProbabilityAssessmentInputProperties()
        {
            // Setup
            var inputToUpdate = new PipingProbabilityAssessmentInput();
            var entity        = new PipingFailureMechanismMetaEntity
            {
                A = new Random(31).NextDouble()
            };

            // Call
            entity.ReadProbabilityAssessmentInput(inputToUpdate);

            // Assert
            Assert.AreEqual(entity.A, inputToUpdate.A);
        }
        public void ReadGeneralPipingInput_ValidParameters_SetGeneralPipingInputWithProperties()
        {
            // Setup
            var inputToUpdate = new GeneralPipingInput();
            var entity        = new PipingFailureMechanismMetaEntity
            {
                WaterVolumetricWeight = new Random(31).NextDouble()
            };

            // Call
            entity.ReadGeneralPipingInput(inputToUpdate);

            // Assert
            Assert.AreEqual(entity.WaterVolumetricWeight, inputToUpdate.WaterVolumetricWeight, inputToUpdate.WaterVolumetricWeight.GetAccuracy());
        }
        /// <summary>
        /// Read the <see cref="PipingFailureMechanismMetaEntity"/> and use the information to update the
        /// <paramref name="failureMechanism"/>.
        /// </summary>
        /// <param name="entity">The <see cref="PipingFailureMechanismMetaEntity"/> to use to update the
        /// <paramref name="failureMechanism"/>.</param>
        /// <param name="failureMechanism">The <see cref="PipingFailureMechanism"/> to be updated.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static void ReadFailureMechanismValues(this PipingFailureMechanismMetaEntity entity,
                                                        PipingFailureMechanism failureMechanism)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

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

            failureMechanism.ScenarioConfigurationType = (PipingScenarioConfigurationType)entity.PipingScenarioConfigurationType;
        }
        /// <summary>
        /// Read the <see cref="PipingFailureMechanismMetaEntity"/> and use the information to update the
        /// <paramref name="generalPipingInput"/>.
        /// </summary>
        /// <param name="entity">The <see cref="PipingFailureMechanismMetaEntity"/> to use to update the
        /// <paramref name="generalPipingInput"/>.</param>
        /// <param name="generalPipingInput">The <see cref="GeneralPipingInput"/> to be updated.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static void ReadGeneralPipingInput(this PipingFailureMechanismMetaEntity entity,
                                                    GeneralPipingInput generalPipingInput)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

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

            generalPipingInput.WaterVolumetricWeight = (RoundedDouble)entity.WaterVolumetricWeight;
        }
        /// <summary>
        /// Read the <see cref="PipingFailureMechanismMetaEntity"/> and use the information to update the
        /// <paramref name="probabilityAssessmentInput"/>.
        /// </summary>
        /// <param name="entity">The <see cref="PipingFailureMechanismMetaEntity"/> to use to update the
        /// <paramref name="probabilityAssessmentInput"/>.</param>
        /// <param name="probabilityAssessmentInput">The <see cref="PipingProbabilityAssessmentInput"/> to be
        /// updated.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static void ReadProbabilityAssessmentInput(this PipingFailureMechanismMetaEntity entity,
                                                            PipingProbabilityAssessmentInput probabilityAssessmentInput)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

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

            probabilityAssessmentInput.A = entity.A;
        }
        public void ReadFailureMechanismValues_ValidParameters_SetPipingProbabilityAssessmentInputProperties()
        {
            // Setup
            var random            = new Random(31);
            var configurationType = random.NextEnumValue <PipingScenarioConfigurationType>();

            var failureMechanismToUpdate = new PipingFailureMechanism();
            var entity = new PipingFailureMechanismMetaEntity
            {
                PipingScenarioConfigurationType = Convert.ToByte(configurationType)
            };

            // Call
            entity.ReadFailureMechanismValues(failureMechanismToUpdate);

            // Assert
            Assert.AreEqual(configurationType, failureMechanismToUpdate.ScenarioConfigurationType);
        }