Пример #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);
        }
        public void Create_WithValidArguments_ReturnsSerializableTotalAssemblyResult()
        {
            // Setup
            var idGenerator = new IdentifierGenerator();

            const string assessmentProcessId           = "assessmentProcessId";
            var          serializableAssessmentProcess = new SerializableAssessmentProcess(assessmentProcessId, new SerializableAssessmentSection());

            var    random = new Random();
            var    probabilityAssemblyMethod   = random.NextEnumValue <SerializableAssemblyMethod>();
            var    assemblyGroupAssemblyMethod = random.NextEnumValue <SerializableAssemblyMethod>();
            var    assemblyGroup = random.NextEnumValue <SerializableAssessmentSectionAssemblyGroup>();
            double probability   = random.NextDouble();

            // Call
            SerializableTotalAssemblyResult serializableTotalAssembly =
                SerializableTotalAssemblyResultCreator.Create(idGenerator,
                                                              serializableAssessmentProcess,
                                                              probabilityAssemblyMethod,
                                                              assemblyGroupAssemblyMethod,
                                                              assemblyGroup,
                                                              probability);

            // Assert
            Assert.AreEqual("Vo.0", serializableTotalAssembly.Id);
            Assert.AreEqual(serializableAssessmentProcess.Id, serializableTotalAssembly.AssessmentProcessId);
            Assert.AreEqual(probabilityAssemblyMethod, serializableTotalAssembly.ProbabilityAssemblyMethod);
            Assert.AreEqual(assemblyGroupAssemblyMethod, serializableTotalAssembly.AssemblyGroupAssemblyMethod);
            Assert.AreEqual(assemblyGroup, serializableTotalAssembly.AssemblyGroup);
            Assert.AreEqual(probability, serializableTotalAssembly.Probability);
        }
 private static void AssertSerializableFailureMechanism(string expectedId,
                                                        SerializableTotalAssemblyResult expectedSerializableTotalAssembly,
                                                        SerializableFailureMechanism serializableFailureMechanism)
 {
     Assert.AreEqual(expectedSerializableTotalAssembly.Id, serializableFailureMechanism.TotalAssemblyResultId);
     Assert.AreEqual(expectedId, serializableFailureMechanism.Id);
 }
Пример #4
0
        public void DefaultConstructor_ReturnsDefaultValues()
        {
            // Call
            var totalAssemblyResult = new SerializableTotalAssemblyResult();

            // Assert
            Assert.IsInstanceOf <SerializableFeatureMember>(totalAssemblyResult);
            Assert.IsNull(totalAssemblyResult.Id);
            Assert.IsNull(totalAssemblyResult.AssessmentProcessId);
            Assert.AreEqual((SerializableAssemblyMethod)0, totalAssemblyResult.AssemblyGroupAssemblyMethod);
            Assert.AreEqual((SerializableAssemblyMethod)0, totalAssemblyResult.ProbabilityAssemblyMethod);
            Assert.AreEqual((SerializableAssessmentSectionAssemblyGroup)0, totalAssemblyResult.AssemblyGroup);
            Assert.AreEqual(0, totalAssemblyResult.Probability);
            Assert.AreEqual("VOLLDG", totalAssemblyResult.Status);

            SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableTotalAssemblyResult), "Veiligheidsoordeel");

            SerializableAttributeTestHelper.AssertXmlAttributeAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.Id), "VeiligheidsoordeelID");
            SerializableAttributeTestHelper.AssertXmlAttributeAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.AssessmentProcessId), "BeoordelingsprocesIDRef");

            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.AssemblyGroupAssemblyMethod), "assemblagemethodeVeiligheidsoordeel");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.ProbabilityAssemblyMethod), "assemblagemethodeFaalkans");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.AssemblyGroup), "categorie");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.Probability), "faalkans");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableTotalAssemblyResult>(
                nameof(SerializableTotalAssemblyResult.Status), "status");
        }
Пример #5
0
        private static void AssertCombinedFailureMechanismSectionAssemblies(IEnumerable <ExportableCombinedSectionAssembly> expectedCombinedSectionAssemblies,
                                                                            SerializableFailureMechanismSectionCollection expectedSerializableFailureMechanismSectionCollection,
                                                                            SerializableTotalAssemblyResult expectedSerializableTotalAssemblyResult,
                                                                            IEnumerable <SerializableFailureMechanismSection> serializableFailureMechanismSections,
                                                                            IEnumerable <SerializableCombinedFailureMechanismSectionAssembly> serializableFailureMechanismSectionAssemblies)
        {
            IEnumerable <ExportableCombinedFailureMechanismSection> expectedSections = expectedCombinedSectionAssemblies.Select(csar => csar.Section);
            int expectedNrOfSections = expectedSections.Count();

            Assert.AreEqual(expectedNrOfSections, serializableFailureMechanismSections.Count());

            Assert.AreEqual(expectedCombinedSectionAssemblies.Count(), serializableFailureMechanismSectionAssemblies.Count());

            var sectionId         = 0;
            var combinedSectionId = 0;

            for (var i = 0; i < expectedNrOfSections; i++)
            {
                ExportableCombinedFailureMechanismSection expectedSection = expectedSections.ElementAt(i);
                SerializableFailureMechanismSection       actualSection   = serializableFailureMechanismSections.ElementAt(i);

                SerializableFailureMechanismSectionTestHelper.AssertFailureMechanismSection(expectedSection,
                                                                                            expectedSerializableFailureMechanismSectionCollection,
                                                                                            actualSection,
                                                                                            sectionId++);

                SerializableCombinedFailureMechanismSectionAssembly actualSectionAssemblyResult = serializableFailureMechanismSectionAssemblies.ElementAt(i);
                Assert.AreEqual($"Gf.{combinedSectionId++}", actualSectionAssemblyResult.Id);
                Assert.AreEqual(actualSection.Id, actualSectionAssemblyResult.FailureMechanismSectionId);
                Assert.AreEqual(expectedSerializableTotalAssemblyResult.Id, actualSectionAssemblyResult.TotalAssemblyResultId);

                AssertCombinedFailureMechanismSectionResults(expectedCombinedSectionAssemblies.ElementAt(i).FailureMechanismResults,
                                                             actualSectionAssemblyResult.FailureMechanismResults);
            }
        }
Пример #6
0
        public void Constructor_WithValidData_ReturnsExpectedValues()
        {
            // Setup
            const string id = "id";

            var assessmentProcess = new SerializableAssessmentProcess("processId", new SerializableAssessmentSection());

            var    random = new Random(39);
            var    probabilityAssemblyMethod   = random.NextEnumValue <SerializableAssemblyMethod>();
            var    assemblyGroupAssemblyMethod = random.NextEnumValue <SerializableAssemblyMethod>();
            var    assemblyGroup = random.NextEnumValue <SerializableAssessmentSectionAssemblyGroup>();
            double probability   = random.NextDouble();

            // Call
            var totalAssemblyResult = new SerializableTotalAssemblyResult(id,
                                                                          assessmentProcess,
                                                                          probabilityAssemblyMethod,
                                                                          assemblyGroupAssemblyMethod,
                                                                          assemblyGroup,
                                                                          probability);

            // Assert
            Assert.AreEqual(id, totalAssemblyResult.Id);
            Assert.AreEqual(assessmentProcess.Id, totalAssemblyResult.AssessmentProcessId);
            Assert.AreEqual(probabilityAssemblyMethod, totalAssemblyResult.ProbabilityAssemblyMethod);
            Assert.AreEqual(assemblyGroupAssemblyMethod, totalAssemblyResult.AssemblyGroupAssemblyMethod);
            Assert.AreEqual(assemblyGroup, totalAssemblyResult.AssemblyGroup);
            Assert.AreEqual(probability, totalAssemblyResult.Probability);
            Assert.AreEqual("VOLLDG", totalAssemblyResult.Status);
        }
Пример #7
0
        /// <summary>
        /// Creates an instance of <see cref="AggregatedSerializableFailureMechanism"/> based on its input parameters.
        /// </summary>
        /// <param name="idGenerator">The generator to generate ids for the serializable components.</param>
        /// <param name="serializableTotalAssemblyResult">The <see cref="SerializableTotalAssemblyResult"/>
        /// the serializable components belong to.</param>
        /// <param name="failureMechanism">The <see cref="ExportableFailureMechanism"/>
        /// to create an <see cref="AggregatedSerializableFailureMechanism"/> for.</param>
        /// <returns>An <see cref="AggregatedSerializableFailureMechanism"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="failureMechanism"/>
        /// is invalid to create a serializable counterpart for.</exception>
        /// <exception cref="NotSupportedException">Thrown when the <see cref="ExportableFailureMechanism"/>
        /// contains unsupported items in the failure mechanism section assembly results.</exception>
        public static AggregatedSerializableFailureMechanism Create(IdentifierGenerator idGenerator,
                                                                    SerializableTotalAssemblyResult serializableTotalAssemblyResult,
                                                                    ExportableFailureMechanism failureMechanism)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

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

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

            SerializableFailureMechanism serializableFailureMechanism = SerializableFailureMechanismCreator.Create(idGenerator, serializableTotalAssemblyResult, failureMechanism);
            var serializableCollection = new SerializableFailureMechanismSectionCollection(idGenerator.GetNewId(Resources.SerializableFailureMechanismSectionCollection_IdPrefix));

            AggregatedSerializableFailureMechanismSectionAssembly[] serializableFailureMechanismSectionAssemblyResults =
                failureMechanism.SectionAssemblyResults
                .Select(sectionAssemblyResult => CreateFailureMechanismSectionAssembly(
                            idGenerator, serializableFailureMechanism, serializableCollection, sectionAssemblyResult))
                .ToArray();

            return(new AggregatedSerializableFailureMechanism(serializableFailureMechanism,
                                                              serializableCollection,
                                                              serializableFailureMechanismSectionAssemblyResults.Select(fmr => fmr.FailureMechanismSection),
                                                              serializableFailureMechanismSectionAssemblyResults.Select(fmr => fmr.FailureMechanismSectionAssembly)));
        }
        public void Create_WithValidArguments_ReturnsAggregatedSerializableFailureMechanism()
        {
            // Setup
            var random           = new Random(21);
            var failureMechanism = new ExportableFailureMechanism(
                ExportableFailureMechanismAssemblyResultTestFactory.CreateResult(),
                new[]
            {
                ExportableFailureMechanismSectionAssemblyResultTestFactory.CreateWithProbability(
                    ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(random.Next()), random.Next()),
                ExportableFailureMechanismSectionAssemblyResultTestFactory.CreateWithProbability(
                    ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(random.Next()), random.Next())
            },
                random.NextEnumValue <ExportableFailureMechanismType>(),
                "code",
                "name");

            var idGenerator = new IdentifierGenerator();

            const string totalAssemblyId           = "totalAssemblyId";
            var          serializableTotalAssembly = new SerializableTotalAssemblyResult(totalAssemblyId,
                                                                                         new SerializableAssessmentProcess(),
                                                                                         random.NextEnumValue <SerializableAssemblyMethod>(),
                                                                                         random.NextEnumValue <SerializableAssemblyMethod>(),
                                                                                         random.NextEnumValue <SerializableAssessmentSectionAssemblyGroup>(),
                                                                                         random.NextDouble());

            // Call
            AggregatedSerializableFailureMechanism aggregatedFailureMechanism =
                AggregatedSerializableFailureMechanismCreator.Create(idGenerator, serializableTotalAssembly, failureMechanism);

            // Assert
            SerializableFailureMechanism serializableFailureMechanism = aggregatedFailureMechanism.FailureMechanism;

            Assert.AreEqual("Fm.0", serializableFailureMechanism.Id);
            Assert.AreEqual(serializableTotalAssembly.Id, serializableFailureMechanism.TotalAssemblyResultId);
            Assert.AreEqual(SerializableFailureMechanismTypeCreator.Create(failureMechanism.FailureMechanismType),
                            serializableFailureMechanism.FailureMechanismType);
            Assert.AreEqual(failureMechanism.Code, serializableFailureMechanism.GenericFailureMechanismCode);

            SerializableFailureMechanismAssemblyResultTestHelper.AssertSerializableFailureMechanismAssemblyResult(failureMechanism.FailureMechanismAssembly,
                                                                                                                  serializableFailureMechanism.FailureMechanismAssemblyResult);

            SerializableFailureMechanismSectionCollection serializableFailureMechanismSectionCollection = aggregatedFailureMechanism.FailureMechanismSectionCollection;

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

            AssertFailureMechanismSectionAssemblies(failureMechanism,
                                                    serializableFailureMechanismSectionCollection,
                                                    serializableFailureMechanism,
                                                    aggregatedFailureMechanism.FailureMechanismSections,
                                                    aggregatedFailureMechanism.FailureMechanismSectionAssemblyResults);
        }
 private static void AssertSerializableTotalAssemblyResult(string expectedId,
                                                           ExportableAssessmentSectionAssemblyResult expectedAssessmentSectionAssemblyResult,
                                                           SerializableAssessmentProcess expectedAssessmentProcess,
                                                           SerializableTotalAssemblyResult serializableTotalAssembly)
 {
     Assert.AreEqual(expectedId, serializableTotalAssembly.Id);
     Assert.AreEqual(expectedAssessmentProcess.Id, serializableTotalAssembly.AssessmentProcessId);
     Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedAssessmentSectionAssemblyResult.ProbabilityAssemblyMethod),
                     serializableTotalAssembly.ProbabilityAssemblyMethod);
     Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedAssessmentSectionAssemblyResult.AssemblyGroupAssemblyMethod),
                     serializableTotalAssembly.AssemblyGroupAssemblyMethod);
     Assert.AreEqual(SerializableAssessmentSectionAssemblyGroupCreator.Create(expectedAssessmentSectionAssemblyResult.AssemblyGroup),
                     serializableTotalAssembly.AssemblyGroup);
     Assert.AreEqual(expectedAssessmentSectionAssemblyResult.Probability, serializableTotalAssembly.Probability);
 }
        private static void AssertCombinedFailureMechanismSectionAssemblyConnections(int indexSerializableCombinedSectionAssembly,
                                                                                     int expectedSectionId,
                                                                                     int expectedCombinedSectionAssemblyId,
                                                                                     SerializableFailureMechanismSectionCollection expectedCombinedFailureMechanismSectionCollection,
                                                                                     SerializableTotalAssemblyResult expectedSerializableTotalAssemblyResult,
                                                                                     SerializableFeatureMember[] serializableAssemblyFeatureMembers)
        {
            var combinedFailureMechanismSection = (SerializableFailureMechanismSection)serializableAssemblyFeatureMembers[indexSerializableCombinedSectionAssembly + 11];

            AssertSerializableFailureMechanismSection($"Bv.{expectedSectionId}",
                                                      expectedCombinedFailureMechanismSectionCollection,
                                                      combinedFailureMechanismSection);
            AssertSerializableCombinedFailureMechanismSectionAssembly($"Gf.{expectedCombinedSectionAssemblyId}",
                                                                      expectedSerializableTotalAssemblyResult,
                                                                      combinedFailureMechanismSection,
                                                                      (SerializableCombinedFailureMechanismSectionAssembly)serializableAssemblyFeatureMembers[indexSerializableCombinedSectionAssembly]);
        }
Пример #11
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_WithValidData_ReturnsExpectedValues()
        {
            // Setup
            const string id = "id";

            var random        = new Random(39);
            var totalAssembly = new SerializableTotalAssemblyResult("totalAssemblyID",
                                                                    new SerializableAssessmentProcess(),
                                                                    random.NextEnumValue <SerializableAssemblyMethod>(),
                                                                    random.NextEnumValue <SerializableAssemblyMethod>(),
                                                                    random.NextEnumValue <SerializableAssessmentSectionAssemblyGroup>(),
                                                                    random.NextDouble());
            var section = new SerializableFailureMechanismSection("sectionID",
                                                                  new SerializableFailureMechanismSectionCollection(),
                                                                  random.NextDouble(),
                                                                  random.NextDouble(),
                                                                  new[]
            {
                new Point2D(random.NextDouble(), random.NextDouble())
            },
                                                                  SerializableFailureMechanismSectionType.Combined);

            SerializableCombinedFailureMechanismSectionAssemblyResult[] sectionResults = Array.Empty <SerializableCombinedFailureMechanismSectionAssemblyResult>();
            var combinedSectionResult = new SerializableFailureMechanismSubSectionAssemblyResult();

            // Call
            var combinedSectionAssembly = new SerializableCombinedFailureMechanismSectionAssembly(id,
                                                                                                  totalAssembly,
                                                                                                  section,
                                                                                                  sectionResults,
                                                                                                  combinedSectionResult);

            // Assert
            Assert.AreEqual(id, combinedSectionAssembly.Id);
            Assert.AreEqual(totalAssembly.Id, combinedSectionAssembly.TotalAssemblyResultId);
            Assert.AreEqual(section.Id, combinedSectionAssembly.FailureMechanismSectionId);
            Assert.AreSame(sectionResults, combinedSectionAssembly.FailureMechanismResults);
            Assert.AreSame(combinedSectionResult, combinedSectionAssembly.CombinedSectionResult);
        }
        public void Create_WithFailureMechanismAssemblyResult_ReturnsSerializableFailureMechanism()
        {
            // Setup
            var idGenerator = new IdentifierGenerator();
            ExportableFailureMechanism failureMechanism = CreateExportableFailureMechanism();

            const string totalAssemblyId = "totalAssemblyId";
            SerializableTotalAssemblyResult serializableTotalAssembly = CreateSerializableTotalAssembly(totalAssemblyId);

            // Call
            SerializableFailureMechanism serializableFailureMechanism = SerializableFailureMechanismCreator.Create(idGenerator,
                                                                                                                   serializableTotalAssembly,
                                                                                                                   failureMechanism);

            // Assert
            Assert.AreEqual("Fm.0", serializableFailureMechanism.Id);
            Assert.AreEqual(serializableTotalAssembly.Id, serializableFailureMechanism.TotalAssemblyResultId);
            Assert.AreEqual(SerializableFailureMechanismTypeCreator.Create(failureMechanism.FailureMechanismType),
                            serializableFailureMechanism.FailureMechanismType);
            Assert.AreEqual(failureMechanism.Code, serializableFailureMechanism.GenericFailureMechanismCode);

            SerializableFailureMechanismAssemblyResultTestHelper.AssertSerializableFailureMechanismAssemblyResult(failureMechanism.FailureMechanismAssembly,
                                                                                                                  serializableFailureMechanism.FailureMechanismAssemblyResult);
        }
        private static void AssertFailureMechanismConnections(int indexSerializableFailureMechanism,
                                                              int expectedId,
                                                              SerializableTotalAssemblyResult expectedSerializableTotalAssemblyResult,
                                                              SerializableFeatureMember[] serializableAssemblyFeatureMembers)
        {
            var failureMechanism = (SerializableFailureMechanism)serializableAssemblyFeatureMembers[indexSerializableFailureMechanism];

            AssertSerializableFailureMechanism($"Fm.{expectedId}",
                                               expectedSerializableTotalAssemblyResult,
                                               failureMechanism);
            var failureMechanismSectionCollection = (SerializableFailureMechanismSectionCollection)serializableAssemblyFeatureMembers[indexSerializableFailureMechanism + 10];

            AssertSerializableFailureMechanismSectionCollection($"Vi.{expectedId}",
                                                                failureMechanismSectionCollection);
            var serializableFailureMechanismSection = (SerializableFailureMechanismSection)serializableAssemblyFeatureMembers[indexSerializableFailureMechanism + 15];

            AssertSerializableFailureMechanismSection($"Bv.{expectedId}",
                                                      failureMechanismSectionCollection,
                                                      serializableFailureMechanismSection);
            AssertSerializableFailureMechanismSectionAssembly($"Fa.{expectedId}",
                                                              failureMechanism,
                                                              serializableFailureMechanismSection,
                                                              (SerializableFailureMechanismSectionAssembly)serializableAssemblyFeatureMembers[indexSerializableFailureMechanism + 4]);
        }
Пример #15
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableFailureMechanism"/> based on its input parameters.
        /// </summary>
        /// <param name="idGenerator">The generator to generate an id for the <see cref="SerializableFailureMechanism"/>.</param>
        /// <param name="serializableTotalAssembly">The <see cref="SerializableTotalAssemblyResult"/>
        /// the <see cref="SerializableFailureMechanism"/> belongs to.</param>
        /// <param name="failureMechanism">The <see cref="ExportableFailureMechanism"/>
        /// to create a <see cref="SerializableFailureMechanism"/> for.</param>
        /// <returns>A <see cref="SerializableFailureMechanism"/></returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="failureMechanism"/> is invalid to
        /// create a serializable counterpart for.</exception>
        public static SerializableFailureMechanism Create(IdentifierGenerator idGenerator,
                                                          SerializableTotalAssemblyResult serializableTotalAssembly,
                                                          ExportableFailureMechanism failureMechanism)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

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

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

            return(new SerializableFailureMechanism(idGenerator.GetNewId(Resources.SerializableFailureMechanismCreator_IdPrefix),
                                                    SerializableFailureMechanismTypeCreator.Create(failureMechanism.FailureMechanismType),
                                                    failureMechanism.Code, failureMechanism.Name, serializableTotalAssembly,
                                                    SerializableFailureMechanismResultCreator.Create(failureMechanism.FailureMechanismAssembly)));
        }
Пример #16
0
        /// <summary>
        /// Creates an instance of <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssembly"/>
        /// based on its input parameters.
        /// </summary>
        /// <param name="idGenerator">The generator to generate ids for the serializable components.</param>
        /// <param name="serializableTotalAssemblyResult">The <see cref="SerializableTotalAssemblyResult"/> the serializable
        /// components belongs to.</param>
        /// <param name="serializableFailureMechanismSectionCollection">The <see cref="SerializableFailureMechanismSectionCollection"/>
        /// the serializable failure mechanism sections belong to.</param>
        /// <param name="combinedSectionAssembly">The <see cref="ExportableCombinedSectionAssembly"/> to create an
        /// <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssembly"/> for.</param>
        /// <returns>An <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="combinedSectionAssembly"/>
        /// is invalid to create a serializable counterpart for.</exception>
        public static AggregatedSerializableCombinedFailureMechanismSectionAssembly Create(IdentifierGenerator idGenerator,
                                                                                           SerializableTotalAssemblyResult serializableTotalAssemblyResult,
                                                                                           SerializableFailureMechanismSectionCollection serializableFailureMechanismSectionCollection,
                                                                                           ExportableCombinedSectionAssembly combinedSectionAssembly)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

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

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

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

            SerializableFailureMechanismSection failureMechanismSection = SerializableFailureMechanismSectionCreator.Create(
                idGenerator, serializableFailureMechanismSectionCollection, combinedSectionAssembly.Section);

            return(new AggregatedSerializableCombinedFailureMechanismSectionAssembly(
                       failureMechanismSection,
                       new SerializableCombinedFailureMechanismSectionAssembly(
                           idGenerator.GetNewId(Resources.SerializableCombinedFailureMechanismSectionAssembly_IdPrefix),
                           serializableTotalAssemblyResult,
                           failureMechanismSection,
                           combinedSectionAssembly.FailureMechanismResults
                           .Select(SerializableCombinedFailureMechanismSectionAssemblyResultCreator.Create)
                           .ToArray(),
                           new SerializableFailureMechanismSubSectionAssemblyResult(
                               SerializableAssemblyMethod.BOI3C1,
                               SerializableFailureMechanismSectionAssemblyGroupCreator.Create(
                                   combinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup)))));
        }
 private static void AssertSerializableCombinedFailureMechanismSectionAssembly(string expectedId,
                                                                               SerializableTotalAssemblyResult expectedSerializableTotalAssemblyResult,
                                                                               SerializableFailureMechanismSection expectedSerializableFailureMechanismSection,
                                                                               SerializableCombinedFailureMechanismSectionAssembly serializableCombinedFailureMechanismSectionAssembly)
 {
     Assert.AreEqual(expectedSerializableTotalAssemblyResult.Id, serializableCombinedFailureMechanismSectionAssembly.TotalAssemblyResultId);
     Assert.AreEqual(expectedSerializableFailureMechanismSection.Id, serializableCombinedFailureMechanismSectionAssembly.FailureMechanismSectionId);
     Assert.AreEqual(expectedId, serializableCombinedFailureMechanismSectionAssembly.Id);
 }
Пример #18
0
        /// <summary>
        /// Creates an instance of <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssemblies"/>
        /// based on its input parameters.
        /// </summary>
        /// <param name="idGenerator">The generator to generate ids for the serializable components.</param>
        /// <param name="totalAssemblyResult">The <see cref="SerializableTotalAssemblyResult"/> the serializable components belong to.</param>
        /// <param name="combinedSectionAssemblies">The collection of <see cref="ExportableCombinedSectionAssembly"/>
        /// to create an <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssemblies"/> for.</param>
        /// <returns>An <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssemblies"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="combinedSectionAssemblies"/> is invalid to
        /// create a serializable counterpart for.</exception>
        public static AggregatedSerializableCombinedFailureMechanismSectionAssemblies Create(IdentifierGenerator idGenerator,
                                                                                             SerializableTotalAssemblyResult totalAssemblyResult,
                                                                                             IEnumerable <ExportableCombinedSectionAssembly> combinedSectionAssemblies)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

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

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

            var failureMechanismSectionCollection = new SerializableFailureMechanismSectionCollection(
                idGenerator.GetNewId(Resources.SerializableFailureMechanismSectionCollection_IdPrefix));

            AggregatedSerializableCombinedFailureMechanismSectionAssembly[] aggregatedAssemblies =
                combinedSectionAssemblies.Select(assembly => AggregatedSerializableCombinedFailureMechanismSectionAssemblyCreator.Create(
                                                     idGenerator, totalAssemblyResult, failureMechanismSectionCollection, assembly))
                .ToArray();

            return(new AggregatedSerializableCombinedFailureMechanismSectionAssemblies(failureMechanismSectionCollection,
                                                                                       aggregatedAssemblies.Select(ag => ag.FailureMechanismSection),
                                                                                       aggregatedAssemblies.Select(ag => ag.CombinedFailureMechanismSectionAssembly)));
        }
        private static SerializableAssembly CreateSerializableAssembly()
        {
            var assessmentSection = new SerializableAssessmentSection("section1", "Traject A", new[]
            {
                new Point2D(0, 0),
                new Point2D(100.0, 0.0)
            });

            var assessmentProcess = new SerializableAssessmentProcess("beoordelingsproces1",
                                                                      assessmentSection);

            var totalAssemblyResult = new SerializableTotalAssemblyResult(
                "veiligheidsoordeel_1", assessmentProcess,
                SerializableAssemblyMethod.BOI2A1, SerializableAssemblyMethod.BOI2B1,
                SerializableAssessmentSectionAssemblyGroup.B, 0.00068354);

            var failureMechanism = new SerializableFailureMechanism(
                "toetsspoorGABI", SerializableFailureMechanismType.Generic, "GABI", "Faalmechanisme GABI", totalAssemblyResult,
                new SerializableFailureMechanismAssemblyResult(0.08419, SerializableAssemblyMethod.BOI1A1));

            var specificFailureMechanism = new SerializableFailureMechanism(
                "specifiekFaalmechanisme", SerializableFailureMechanismType.Specific, "NIEUW", "Specifiek faalmechanisme",
                totalAssemblyResult, new SerializableFailureMechanismAssemblyResult(0.002834, SerializableAssemblyMethod.BOI1A1));

            var sections1 = new SerializableFailureMechanismSectionCollection("vakindelingGABI");
            var section1  = new SerializableFailureMechanismSection(
                "vak_GABI_1",
                sections1,
                0.12,
                10.23,
                new[]
            {
                new Point2D(0.23, 0.24),
                new Point2D(10.23, 10.24)
            },
                SerializableFailureMechanismSectionType.FailureMechanism);

            var result = new SerializableFailureMechanismSectionAssembly(
                "resultaat_GABI_1", failureMechanism, section1,
                new SerializableFailureMechanismSectionAssemblyResult(
                    SerializableAssemblyMethod.BOI0A2, SerializableAssemblyMethod.BOI0B1,
                    SerializableFailureMechanismSectionAssemblyGroup.III, 0.00073));

            var sections2 = new SerializableFailureMechanismSectionCollection("vakindeling_gecombineerd");
            var section2  = new SerializableFailureMechanismSection(
                "vak_gecombineerd_1",
                sections2,
                0.12,
                10.23,
                new[]
            {
                new Point2D(0.23, 0.24),
                new Point2D(10.23, 10.24)
            },
                SerializableFailureMechanismSectionType.Combined,
                SerializableAssemblyMethod.BOI3A1);
            var combinedResult = new SerializableCombinedFailureMechanismSectionAssembly(
                "resultaat_gecombineerd_1",
                totalAssemblyResult,
                section2,
                new[]
            {
                new SerializableCombinedFailureMechanismSectionAssemblyResult(
                    SerializableAssemblyMethod.BOI3B1,
                    SerializableFailureMechanismType.Generic, "HTKW", "Hoogte kunstwerk",
                    SerializableFailureMechanismSectionAssemblyGroup.III),
                new SerializableCombinedFailureMechanismSectionAssemblyResult(
                    SerializableAssemblyMethod.BOI3B1,
                    SerializableFailureMechanismType.Generic, "STPH", "Piping",
                    SerializableFailureMechanismSectionAssemblyGroup.II),
                new SerializableCombinedFailureMechanismSectionAssemblyResult(
                    SerializableAssemblyMethod.BOI3B1,
                    SerializableFailureMechanismType.Specific, "NIEUW", "Specifiek",
                    SerializableFailureMechanismSectionAssemblyGroup.Zero)
            },
                new SerializableFailureMechanismSubSectionAssemblyResult(
                    SerializableAssemblyMethod.BOI3C1, SerializableFailureMechanismSectionAssemblyGroup.I));

            var assembly = new SerializableAssembly(
                "assemblage_1",
                new Point2D(12.0, 34.0),
                new Point2D(56.053, 78.0002345),
                assessmentSection,
                assessmentProcess,
                totalAssemblyResult,
                new[]
            {
                failureMechanism,
                specificFailureMechanism
            },
                new[]
            {
                result
            },
                new[]
            {
                combinedResult
            },
                new[]
            {
                sections1,
                sections2
            },
                new[]
            {
                section1,
                section2
            });

            return(assembly);
        }
Пример #20
0
        public void Constructor_WithValidData_ReturnsExpectedValues()
        {
            // Setup
            const string id = "assemblyId1";

            var random                                  = new Random(39);
            var lowerCorner                             = new Point2D(random.NextDouble(), random.NextDouble());
            var upperCorner                             = new Point2D(random.NextDouble(), random.NextDouble());
            var assessmentSection                       = new SerializableAssessmentSection();
            var assessmentProcess                       = new SerializableAssessmentProcess();
            var totalAssemblyResult                     = new SerializableTotalAssemblyResult();
            var failureMechanism                        = new SerializableFailureMechanism();
            var failureMechanismSectionAssembly         = new SerializableFailureMechanismSectionAssembly();
            var combinedFailureMechanismSectionAssembly = new SerializableCombinedFailureMechanismSectionAssembly();
            var failureMechanismSections                = new SerializableFailureMechanismSectionCollection();
            var failureMechanismSection                 = new SerializableFailureMechanismSection();

            // Call
            var assembly = new SerializableAssembly(id,
                                                    lowerCorner,
                                                    upperCorner,
                                                    assessmentSection,
                                                    assessmentProcess,
                                                    totalAssemblyResult,
                                                    new[]
            {
                failureMechanism
            },
                                                    new[]
            {
                failureMechanismSectionAssembly
            },
                                                    new[]
            {
                combinedFailureMechanismSectionAssembly
            },
                                                    new[]
            {
                failureMechanismSections
            },
                                                    new[]
            {
                failureMechanismSection
            });

            // Assert
            Assert.AreEqual(id, assembly.Id);
            Assert.AreEqual(lowerCorner.X.ToString(CultureInfo.InvariantCulture) + " " + lowerCorner.Y.ToString(CultureInfo.InvariantCulture),
                            assembly.Boundary.Envelope.LowerCorner);
            Assert.AreEqual(upperCorner.X.ToString(CultureInfo.InvariantCulture) + " " + upperCorner.Y.ToString(CultureInfo.InvariantCulture),
                            assembly.Boundary.Envelope.UpperCorner);
            CollectionAssert.AreEqual(new SerializableFeatureMember[]
            {
                assessmentSection,
                assessmentProcess,
                totalAssemblyResult,
                failureMechanism,
                failureMechanismSectionAssembly,
                combinedFailureMechanismSectionAssembly,
                failureMechanismSections,
                failureMechanismSection
            }, assembly.FeatureMembers);
        }