Beispiel #1
0
        public void Create_WithValidArguments_ReturnsAggregatedSerializableCombinedFailureMechanismSectionAssemblies()
        {
            // Setup
            ExportableCombinedSectionAssembly[] combinedSectionAssemblies =
            {
                CreateCombinedSectionAssembly(CreateSection(1), 1),
                CreateCombinedSectionAssembly(CreateSection(2), 2)
            };

            var idGenerator = new IdentifierGenerator();
            SerializableTotalAssemblyResult totalAssemblyResult = CreateSerializableTotalAssembly("totalAssemblyResultId");

            // Call
            AggregatedSerializableCombinedFailureMechanismSectionAssemblies aggregate =
                AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.Create(idGenerator,
                                                                                              totalAssemblyResult,
                                                                                              combinedSectionAssemblies);

            // Assert
            SerializableFailureMechanismSectionCollection serializableFailureMechanismSectionCollection = aggregate.FailureMechanismSectionCollection;

            Assert.AreEqual("Vi.0", serializableFailureMechanismSectionCollection.Id);

            AssertCombinedFailureMechanismSectionAssemblies(combinedSectionAssemblies,
                                                            serializableFailureMechanismSectionCollection,
                                                            totalAssemblyResult,
                                                            aggregate.FailureMechanismSections,
                                                            aggregate.CombinedFailureMechanismSectionAssemblies);
        }
Beispiel #2
0
 private static IEnumerable <SerializableFailureMechanismSectionCollection> GetAllSerializableFailureMechanismSectionCollections(
     IEnumerable <AggregatedSerializableFailureMechanism> aggregatedFailureMechanisms,
     AggregatedSerializableCombinedFailureMechanismSectionAssemblies aggregatedSerializableCombinedFailureMechanismSectionAssemblies)
 {
     return(new List <SerializableFailureMechanismSectionCollection>(aggregatedFailureMechanisms.Select(afm => afm.FailureMechanismSectionCollection))
     {
         aggregatedSerializableCombinedFailureMechanismSectionAssemblies.FailureMechanismSectionCollection
     });
 }
Beispiel #3
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableAssembly"/> based
        /// on <paramref name="assessmentSection"/>.
        /// </summary>
        /// <param name="assessmentSection">The <see cref="ExportableAssessmentSection"/>
        /// to create a <see cref="SerializableAssembly"/> for.</param>
        /// <returns>A <see cref="SerializableAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when the <paramref name="assessmentSection"/> is invalid
        /// to create a serializable counterpart for.</exception>
        public static SerializableAssembly Create(ExportableAssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            var    idGenerator            = new IdentifierGenerator();
            string serializableAssemblyId = idGenerator.GetNewId(Resources.SerializableAssembly_IdPrefix);

            SerializableAssessmentSection   serializableAssessmentSection   = SerializableAssessmentSectionCreator.Create(assessmentSection);
            SerializableAssessmentProcess   serializableAssessmentProcess   = SerializableAssessmentProcessCreator.Create(idGenerator, serializableAssessmentSection);
            SerializableTotalAssemblyResult serializableTotalAssemblyResult =
                SerializableTotalAssemblyResultCreator.Create(
                    idGenerator,
                    serializableAssessmentProcess,
                    SerializableAssemblyMethodCreator.Create(assessmentSection.AssessmentSectionAssembly.ProbabilityAssemblyMethod),
                    SerializableAssemblyMethodCreator.Create(assessmentSection.AssessmentSectionAssembly.AssemblyGroupAssemblyMethod),
                    SerializableAssessmentSectionAssemblyGroupCreator.Create(assessmentSection.AssessmentSectionAssembly.AssemblyGroup),
                    assessmentSection.AssessmentSectionAssembly.Probability);

            AggregatedSerializableFailureMechanism[] aggregatedFailureMechanisms = assessmentSection.FailureMechanisms
                                                                                   .Select(fm => AggregatedSerializableFailureMechanismCreator.Create(
                                                                                               idGenerator, serializableTotalAssemblyResult, fm))
                                                                                   .ToArray();

            AggregatedSerializableCombinedFailureMechanismSectionAssemblies aggregatedSerializableCombinedFailureMechanismSectionAssemblies =
                AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.Create(
                    idGenerator, serializableTotalAssemblyResult, assessmentSection.CombinedSectionAssemblies);

            return(new SerializableAssembly(
                       serializableAssemblyId,
                       GetLowerCorner(assessmentSection.Geometry),
                       GetUpperCorner(assessmentSection.Geometry),
                       serializableAssessmentSection,
                       serializableAssessmentProcess,
                       serializableTotalAssemblyResult,
                       aggregatedFailureMechanisms.Select(afm => afm.FailureMechanism),
                       aggregatedFailureMechanisms.SelectMany(afm => afm.FailureMechanismSectionAssemblyResults),
                       aggregatedSerializableCombinedFailureMechanismSectionAssemblies.CombinedFailureMechanismSectionAssemblies,
                       GetAllSerializableFailureMechanismSectionCollections(
                           aggregatedFailureMechanisms, aggregatedSerializableCombinedFailureMechanismSectionAssemblies),
                       aggregatedFailureMechanisms.SelectMany(afm => afm.FailureMechanismSections)
                       .Concat(aggregatedSerializableCombinedFailureMechanismSectionAssemblies.FailureMechanismSections)));
        }
        public void Constructor_WithValidArguments_ExpectedValues()
        {
            // Setup
            var failureMechanismSectionCollection = new SerializableFailureMechanismSectionCollection();
            IEnumerable <SerializableFailureMechanismSection> failureMechanismSections =
                Enumerable.Empty <SerializableFailureMechanismSection>();
            IEnumerable <SerializableCombinedFailureMechanismSectionAssembly> failureMechanismSectionAssemblies =
                Enumerable.Empty <SerializableCombinedFailureMechanismSectionAssembly>();

            // Call
            var aggregate = new AggregatedSerializableCombinedFailureMechanismSectionAssemblies(failureMechanismSectionCollection,
                                                                                                failureMechanismSections,
                                                                                                failureMechanismSectionAssemblies);

            // Assert
            Assert.AreSame(failureMechanismSectionCollection, aggregate.FailureMechanismSectionCollection);
            Assert.AreSame(failureMechanismSections, aggregate.FailureMechanismSections);
            Assert.AreSame(failureMechanismSectionAssemblies, aggregate.CombinedFailureMechanismSectionAssemblies);
        }