Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableFailureMechanismSection"/> based on
        /// its input parameters.
        /// </summary>
        /// <param name="idGenerator">The id generator to generate an id
        /// for <see cref="SerializableFailureMechanismSection"/>.</param>
        /// <param name="serializableCollection">The <see cref="SerializableFailureMechanismSectionCollection"/>
        /// this section belongs to.</param>
        /// <param name="section">The <see cref="ExportableCombinedFailureMechanismSection"/>
        /// to create a <see cref="SerializableFailureMechanismSection"/> for.</param>
        /// <returns>A <see cref="SerializableFailureMechanismSection"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static SerializableFailureMechanismSection Create(IdentifierGenerator idGenerator,
                                                                 SerializableFailureMechanismSectionCollection serializableCollection,
                                                                 ExportableCombinedFailureMechanismSection section)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

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

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

            return(new SerializableFailureMechanismSection(idGenerator.GetNewId(Resources.SerializableFailureMechanismSection_IdPrefix),
                                                           serializableCollection,
                                                           section.StartDistance,
                                                           section.EndDistance,
                                                           section.Geometry,
                                                           SerializableFailureMechanismSectionType.Combined,
                                                           SerializableAssemblyMethodCreator.Create(section.AssemblyMethod)));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a collection of <see cref="ExportableCombinedSectionAssembly"/>
        /// based on <paramref name="combinedSectionAssemblyResults"/>.
        /// </summary>
        /// <param name="combinedSectionAssemblyResults">A collection of combined section results to
        /// create a collection of <see cref="ExportableCombinedSectionAssembly"/> for.</param>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> the section results belong to.</param>
        /// <returns>A collection of <see cref="ExportableCombinedSectionAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <ExportableCombinedSectionAssembly> CreateExportableCombinedSectionAssemblyCollection(
            IEnumerable <CombinedFailureMechanismSectionAssemblyResult> combinedSectionAssemblyResults,
            AssessmentSection assessmentSection)
        {
            if (combinedSectionAssemblyResults == null)
            {
                throw new ArgumentNullException(nameof(combinedSectionAssemblyResults));
            }

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

            var sectionResults = new List <ExportableCombinedSectionAssembly>();

            foreach (CombinedFailureMechanismSectionAssemblyResult assemblyResult in combinedSectionAssemblyResults)
            {
                var exportableSection = new ExportableCombinedFailureMechanismSection(
                    FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                        assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd),
                    assemblyResult.SectionStart,
                    assemblyResult.SectionEnd,
                    ExportableAssemblyMethodFactory.Create(assemblyResult.CommonSectionAssemblyMethod));

                var exportableSectionResult = new ExportableCombinedSectionAssembly(
                    exportableSection, new ExportableFailureMechanismSectionAssemblyResult(
                        exportableSection, assemblyResult.TotalResult, ExportableAssemblyMethodFactory.Create(assemblyResult.CombinedSectionResultAssemblyMethod)),
                    CreateFailureMechanismCombinedSectionAssemblyResults(assemblyResult, assessmentSection));

                sectionResults.Add(exportableSectionResult);
            }

            return(sectionResults);
        }
Esempio n. 4
0
        private static void AssertExportableCombinedFailureMechanismSectionResult(CombinedFailureMechanismSectionAssemblyResult expectedSection,
                                                                                  ExportableCombinedFailureMechanismSection actualSection,
                                                                                  ExportableCombinedSectionAssembly actualSectionResult,
                                                                                  bool hasAssemblyGroupResults)
        {
            Assert.AreSame(actualSection, actualSectionResult.Section);
            Assert.AreEqual(expectedSection.TotalResult, actualSectionResult.CombinedSectionAssemblyResult.AssemblyGroup);
            Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CombinedSectionResultAssemblyMethod), actualSectionResult.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod);

            IEnumerable <ExportableFailureMechanismCombinedSectionAssemblyResult> failureMechanismCombinedSectionResults = actualSectionResult.FailureMechanismResults;

            if (!hasAssemblyGroupResults)
            {
                CollectionAssert.IsEmpty(failureMechanismCombinedSectionResults);
                return;
            }

            Assert.AreEqual(17, failureMechanismCombinedSectionResults.Count());
            Assert.IsTrue(failureMechanismCombinedSectionResults.All(result => result.SectionAssemblyResult.AssemblyMethod == ExportableAssemblyMethodFactory.Create(
                                                                         expectedSection.FailureMechanismResultsAssemblyMethod)));

            AssertSubSection(expectedSection.Piping, "STPH", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(0));
            AssertSubSection(expectedSection.GrassCoverErosionInwards, "GEKB", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(1));
            AssertSubSection(expectedSection.MacroStabilityInwards, "STBI", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(2));
            AssertSubSection(expectedSection.Microstability, "STMI", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(3));
            AssertSubSection(expectedSection.StabilityStoneCover, "ZST", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(4));
            AssertSubSection(expectedSection.WaveImpactAsphaltCover, "AGK", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(5));
            AssertSubSection(expectedSection.WaterPressureAsphaltCover, "AWO", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(6));
            AssertSubSection(expectedSection.GrassCoverErosionOutwards, "GEBU", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(7));
            AssertSubSection(expectedSection.GrassCoverSlipOffOutwards, "GABU", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(8));
            AssertSubSection(expectedSection.GrassCoverSlipOffInwards, "GABI", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(9));
            AssertSubSection(expectedSection.HeightStructures, "HTKW", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(10));
            AssertSubSection(expectedSection.ClosingStructures, "BSKW", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(11));
            AssertSubSection(expectedSection.PipingStructure, "PKW", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(12));
            AssertSubSection(expectedSection.StabilityPointStructures, "STKWp", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(13));
            AssertSubSection(expectedSection.DuneErosion, "DA", ExportableFailureMechanismType.Generic,
                             failureMechanismCombinedSectionResults.ElementAt(14));
            AssertSubSection(expectedSection.SpecificFailureMechanisms[0], "Nieuw1", ExportableFailureMechanismType.Specific,
                             failureMechanismCombinedSectionResults.ElementAt(15));
            AssertSubSection(expectedSection.SpecificFailureMechanisms[1], "Nieuw2", ExportableFailureMechanismType.Specific,
                             failureMechanismCombinedSectionResults.ElementAt(16));
        }
Esempio n. 5
0
        private static void AssertExportableCombinedFailureMechanismSection(CombinedFailureMechanismSectionAssemblyResult expectedSection,
                                                                            ExportableCombinedFailureMechanismSection actualSection,
                                                                            ReferenceLine referenceLine)
        {
            IEnumerable <Point2D> expectedGeometry = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                referenceLine,
                actualSection.StartDistance,
                actualSection.EndDistance).ToArray();

            CollectionAssert.IsNotEmpty(expectedGeometry);

            Assert.AreEqual(expectedSection.SectionStart, actualSection.StartDistance);
            Assert.AreEqual(expectedSection.SectionEnd, actualSection.EndDistance);
            CollectionAssert.AreEqual(expectedGeometry, actualSection.Geometry);
            Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CommonSectionAssemblyMethod), actualSection.AssemblyMethod);
        }
Esempio n. 6
0
        public void CreateWithCombinedAssemblySection_WithSection_ReturnsSerializableFailureMechanismSection()
        {
            // Setup
            const string collectionId = "collectionId";
            var          collection   = new SerializableFailureMechanismSectionCollection(collectionId);

            var idGenerator = new IdentifierGenerator();
            ExportableCombinedFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableCombinedFailureMechanismSection();

            // Call
            SerializableFailureMechanismSection serializableSection =
                SerializableFailureMechanismSectionCreator.Create(idGenerator, collection, section);

            // Assert
            SerializableFailureMechanismSectionTestHelper.AssertFailureMechanismSection(section, collection, serializableSection);
        }
        /// <summary>
        /// Asserts a <see cref="SerializableFailureMechanismSection"/> against
        /// an <see cref="ExportableCombinedFailureMechanismSection"/>.
        /// </summary>
        /// <param name="expectedSection">The <see cref="ExportableCombinedFailureMechanismSection"/> to assert against.</param>
        /// <param name="expectedCollection">The <see cref="SerializableFailureMechanismSectionCollection"/> the section belongs to.</param>
        /// <param name="actualSerializableSection">The <see cref="SerializableFailureMechanismSection"/> to assert.</param>
        /// <param name="expectedId">The expected id for the <see cref="SerializableFailureMechanismSection"/>.</param>
        /// <exception cref="AssertionException">Thrown when:
        /// <list type="bullet">
        /// <item>The id does not match with the expected id.</item>
        /// <item>The id of the failure mechanism section collection does not match.</item>
        /// <item>The geometry, start distance or the end distance of the failure mechanism section does not match.</item>
        /// <item>The failure mechanism section type does not match.</item>
        /// <item>The used assembly method to obtain the section does not match.</item>
        /// </list>
        /// </exception>
        public static void AssertFailureMechanismSection(ExportableCombinedFailureMechanismSection expectedSection,
                                                         SerializableFailureMechanismSectionCollection expectedCollection,
                                                         SerializableFailureMechanismSection actualSerializableSection,
                                                         int expectedId = 0)
        {
            Assert.AreEqual($"Bv.{expectedId}", actualSerializableSection.Id);
            Assert.AreEqual(expectedCollection.Id, actualSerializableSection.FailureMechanismSectionCollectionId);

            Assert.AreEqual(GeometrySerializationFormatter.Format(expectedSection.Geometry),
                            actualSerializableSection.Geometry.LineString.Geometry);
            Assert.AreEqual(expectedSection.StartDistance, actualSerializableSection.StartDistance.Value);
            Assert.AreEqual(expectedSection.EndDistance, actualSerializableSection.EndDistance.Value);
            Assert.AreEqual(SerializableFailureMechanismSectionType.Combined,
                            actualSerializableSection.FailureMechanismSectionType);
            Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedSection.AssemblyMethod),
                            actualSerializableSection.AssemblyMethod);
        }
Esempio n. 8
0
        public void Constructor_CombinedSectionAssemblyResultNull_ThrowsArgumentNullException()
        {
            // Setup
            var random  = new Random(21);
            var section = new ExportableCombinedFailureMechanismSection(
                Enumerable.Empty <Point2D>(), random.NextDouble(), random.NextDouble(),
                random.NextEnumValue <ExportableAssemblyMethod>());

            // Call
            void Call() => new ExportableCombinedSectionAssembly(
                section, null, Enumerable.Empty <ExportableFailureMechanismCombinedSectionAssemblyResult>());

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

            Assert.AreEqual("combinedSectionAssemblyResult", exception.ParamName);
        }
Esempio n. 9
0
        public void Constructor_WithArguments_ExpectedValues()
        {
            // Setup
            var random = new Random(21);
            IEnumerable <Point2D> geometry = Enumerable.Empty <Point2D>();
            var    assemblyMethod          = random.NextEnumValue <ExportableAssemblyMethod>();
            double startDistance           = random.NextDouble();
            double endDistance             = random.NextDouble();

            // Call
            var section = new ExportableCombinedFailureMechanismSection(geometry, startDistance, endDistance, assemblyMethod);

            // Assert
            Assert.IsInstanceOf <ExportableFailureMechanismSection>(section);

            Assert.AreSame(geometry, section.Geometry);
            Assert.AreEqual(startDistance, section.StartDistance);
            Assert.AreEqual(endDistance, section.EndDistance);
            Assert.AreEqual(assemblyMethod, section.AssemblyMethod);
        }
Esempio n. 10
0
        public void Constructor_WithValidArguments_ExpectedValues()
        {
            // Setup
            var random  = new Random(21);
            var section = new ExportableCombinedFailureMechanismSection(
                Enumerable.Empty <Point2D>(), random.NextDouble(), random.NextDouble(),
                random.NextEnumValue <ExportableAssemblyMethod>());

            ExportableFailureMechanismSectionAssemblyResult combinedAssemblyResult = ExportableFailureMechanismSectionAssemblyResultTestFactory.Create(
                section, random.Next());

            IEnumerable <ExportableFailureMechanismCombinedSectionAssemblyResult> failureMechanismResults =
                Enumerable.Empty <ExportableFailureMechanismCombinedSectionAssemblyResult>();

            // Call
            var result = new ExportableCombinedSectionAssembly(section, combinedAssemblyResult, failureMechanismResults);

            // Assert
            Assert.AreSame(section, result.Section);
            Assert.AreSame(combinedAssemblyResult, result.CombinedSectionAssemblyResult);
            Assert.AreSame(failureMechanismResults, result.FailureMechanismResults);
        }
 private static ExportableCombinedSectionAssembly CreateCombinedSectionAssembly(ExportableCombinedFailureMechanismSection section)
 {
     return(new ExportableCombinedSectionAssembly(
                section,
                ExportableFailureMechanismSectionAssemblyResultTestFactory.Create(section, 21),
                new[]
     {
         CreateCombinedSectionAssemblyResult(21),
         CreateCombinedSectionAssemblyResult(22)
     }));
 }