Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableFailureMechanismSection"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="failureMechanismSectionCollection">The failure mechanism sections object the section belong to.</param>
        /// <param name="startDistance">The distance over the reference line where this section starts in meters.</param>
        /// <param name="endDistance">The distance over the reference line where this section ends in meters.</param>
        /// <param name="geometry">The geometry of the section.</param>
        /// <param name="sectionType">The type of the section.</param>
        /// <param name="assemblyMethod">The assembly method used to create this section.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanismSectionCollection"/>,
        /// or <paramref name="geometry"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when:
        /// <list type="bullet">
        /// <item><paramref name="geometry"/> contains no elements.</item>
        /// <item><paramref name="id"/> is invalid.</item>
        /// </list>
        /// </exception>
        public SerializableFailureMechanismSection(string id,
                                                   SerializableFailureMechanismSectionCollection failureMechanismSectionCollection,
                                                   double startDistance,
                                                   double endDistance,
                                                   IEnumerable <Point2D> geometry,
                                                   SerializableFailureMechanismSectionType sectionType,
                                                   SerializableAssemblyMethod?assemblyMethod = null)
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

            Id            = id;
            StartDistance = new SerializableMeasure(startDistance);
            EndDistance   = new SerializableMeasure(endDistance);
            FailureMechanismSectionCollectionId = failureMechanismSectionCollection.Id;
            Geometry       = new SerializableLine(geometry);
            Length         = new SerializableMeasure(Math2D.Length(geometry));
            AssemblyMethod = assemblyMethod;
            FailureMechanismSectionType = sectionType;
        }
        /// <summary>
        /// Creates a new instance of <see cref="SerializableFailureMechanismSectionAssembly"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="failureMechanism">The failure mechanism this assembly belongs to.</param>
        /// <param name="section">The section this assembly belongs to.</param>
        /// <param name="sectionResult">The assembly result for this section assembly.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableFailureMechanismSectionAssembly(string id,
                                                           SerializableFailureMechanism failureMechanism,
                                                           SerializableFailureMechanismSection section,
                                                           SerializableFailureMechanismSectionAssemblyResult sectionResult)
            : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

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

            Id = id;
            FailureMechanismId        = failureMechanism.Id;
            FailureMechanismSectionId = section.Id;
            SectionResult             = sectionResult;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableCombinedFailureMechanismSectionAssembly"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="totalAssemblyResult">The total assembly result this assembly belongs to.</param>
        /// <param name="section">The section this assembly belongs to.</param>
        /// <param name="failureMechanismResults">The collection of assembly results for this assembly per failure mechanism.</param>
        /// <param name="combinedSectionResult">The combined assembly result for this assembly.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableCombinedFailureMechanismSectionAssembly(string id,
                                                                   SerializableTotalAssemblyResult totalAssemblyResult,
                                                                   SerializableFailureMechanismSection section,
                                                                   SerializableCombinedFailureMechanismSectionAssemblyResult[] failureMechanismResults,
                                                                   SerializableFailureMechanismSubSectionAssemblyResult combinedSectionResult)
            : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

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

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

            Id = id;
            TotalAssemblyResultId     = totalAssemblyResult.Id;
            FailureMechanismSectionId = section.Id;
            FailureMechanismResults   = failureMechanismResults;
            CombinedSectionResult     = combinedSectionResult;
        }
Esempio n. 4
0
        public void Validate_WithInvalidIds_ThrowsArgumentException(string invalidId)
        {
            // Call
            void Call() => SerializableIdValidator.ThrowIfInvalid(invalidId);

            // Assert
            const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(Call, expectedMessage);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableAssessmentProcess"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="assessmentSection">The assessment section this process belongs to.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableAssessmentProcess(string id,
                                             SerializableAssessmentSection assessmentSection) : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

            Id = id;
            AssessmentSectionId = assessmentSection.Id;
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableAssessmentSection"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="name">The name of the assessment section.</param>
        /// <param name="geometry">The geometry of the reference line.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when:
        /// <list type="bullet">
        /// <item><paramref name="geometry"/> contains no elements.</item>
        /// <item><paramref name="id"/> is invalid.</item>
        /// </list>
        /// </exception>
        public SerializableAssessmentSection(string id,
                                             string name,
                                             IEnumerable <Point2D> geometry) : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

            Id   = id;
            Name = name;
            ReferenceLineLength   = new SerializableMeasure(Math2D.Length(geometry));
            ReferenceLineGeometry = new SerializableLine(geometry);
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableTotalAssemblyResult"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="assessmentProcess">The assessment process this result belongs to.</param>
        /// <param name="probabilityAssemblyMethod">The method used to assemble the probability of this result.</param>
        /// <param name="assemblyGroupAssemblyMethod">The method used to assemble the assembly group of this result.</param>
        /// <param name="assemblyGroup">The group of this assembly result.</param>
        /// <param name="probability">The probability of this assembly result.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentProcess"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableTotalAssemblyResult(string id,
                                               SerializableAssessmentProcess assessmentProcess,
                                               SerializableAssemblyMethod probabilityAssemblyMethod,
                                               SerializableAssemblyMethod assemblyGroupAssemblyMethod,
                                               SerializableAssessmentSectionAssemblyGroup assemblyGroup,
                                               double probability) : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

            Id = id;
            AssessmentProcessId         = assessmentProcess.Id;
            ProbabilityAssemblyMethod   = probabilityAssemblyMethod;
            AssemblyGroupAssemblyMethod = assemblyGroupAssemblyMethod;
            AssemblyGroup = assemblyGroup;
            Probability   = probability;
        }
        /// <summary>
        /// Creates a new instance of <see cref="SerializableFailureMechanism"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="failureMechanismType">The type of the failure mechanism.</param>
        /// <param name="code">The code of the failure mechanism.</param>
        /// <param name="name">The name of the failure mechanism.</param>
        /// <param name="totalAssemblyResult">The total assembly result the failure mechanism belongs to.</param>
        /// <param name="failureMechanismAssemblyResult">The total failure mechanism assembly result.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableFailureMechanism(string id, SerializableFailureMechanismType failureMechanismType, string code,
                                            string name, SerializableTotalAssemblyResult totalAssemblyResult,
                                            SerializableFailureMechanismAssemblyResult failureMechanismAssemblyResult)
            : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

            Id = id;
            FailureMechanismType           = failureMechanismType;
            TotalAssemblyResultId          = totalAssemblyResult.Id;
            GenericFailureMechanismCode    = code;
            SpecificFailureMechanismName   = name;
            FailureMechanismAssemblyResult = failureMechanismAssemblyResult;
        }
Esempio n. 9
0
 public void ThrowIfInvalid_WithValidIds_DoesNotThrow(string validId)
 {
     // Call & Assert
     SerializableIdValidator.ThrowIfInvalid(validId);
 }
Esempio n. 10
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableAssembly"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="lowerCorner">The lower corner of the assembly map boundary.</param>
        /// <param name="upperCorner">The upper corner of the assembly map boundary.</param>
        /// <param name="assessmentSection">The <see cref="SerializableAssessmentSection"/> that belongs to the assembly.</param>
        /// <param name="assessmentProcess">The <see cref="SerializableAssessmentProcess"/> that belongs to the assembly.</param>
        /// <param name="totalAssemblyResult">The <see cref="SerializableTotalAssemblyResult"/> that belongs to the assembly.</param>
        /// <param name="failureMechanisms">The collection of <see cref="SerializableFailureMechanism"/> that
        /// belong to the assembly.</param>
        /// <param name="failureMechanismSectionAssemblies">The collection of <see cref="SerializableFailureMechanismSectionAssembly"/> that
        /// belong to the assembly.</param>
        /// <param name="combinedFailureMechanismSectionAssemblies">The collection of <see cref="SerializableCombinedFailureMechanismSectionAssembly"/> that
        /// belong to the assembly.</param>
        /// <param name="failureMechanismSectionCollections">The collection of <see cref="SerializableFailureMechanismSectionCollection"/> that
        /// belong to the assembly.</param>
        /// <param name="failureMechanismSections">The collection of <see cref="SerializableFailureMechanismSection"/> that
        /// belong to the assembly.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableAssembly(string id,
                                    Point2D lowerCorner,
                                    Point2D upperCorner,
                                    SerializableAssessmentSection assessmentSection,
                                    SerializableAssessmentProcess assessmentProcess,
                                    SerializableTotalAssemblyResult totalAssemblyResult,
                                    IEnumerable <SerializableFailureMechanism> failureMechanisms,
                                    IEnumerable <SerializableFailureMechanismSectionAssembly> failureMechanismSectionAssemblies,
                                    IEnumerable <SerializableCombinedFailureMechanismSectionAssembly> combinedFailureMechanismSectionAssemblies,
                                    IEnumerable <SerializableFailureMechanismSectionCollection> failureMechanismSectionCollections,
                                    IEnumerable <SerializableFailureMechanismSection> failureMechanismSections)
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

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

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

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

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

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

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

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

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

            Id       = id;
            Boundary = new SerializableBoundary(lowerCorner, upperCorner);

            var featureMembers = new List <SerializableFeatureMember>
            {
                assessmentSection,
                assessmentProcess,
                totalAssemblyResult
            };

            featureMembers.AddRange(failureMechanisms);
            featureMembers.AddRange(failureMechanismSectionAssemblies);
            featureMembers.AddRange(combinedFailureMechanismSectionAssemblies);
            featureMembers.AddRange(failureMechanismSectionCollections);
            featureMembers.AddRange(failureMechanismSections);
            FeatureMembers = featureMembers.ToArray();
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableFailureMechanismSectionCollection"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableFailureMechanismSectionCollection(string id)
        {
            SerializableIdValidator.ThrowIfInvalid(id);

            Id = id;
        }