/// <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); }
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)); }
private static void AssertCombinedFailureMechanismSectionAssemblyResults(IEnumerable <CombinedFailureMechanismSectionAssemblyResult> assemblyResults, IEnumerable <ExportableCombinedSectionAssembly> exportableCombinedSectionAssemblies, ReferenceLine referenceLine, bool hasAssemblyGroupResults) { int expectedNrOfSections = assemblyResults.Count(); Assert.AreEqual(expectedNrOfSections, exportableCombinedSectionAssemblies.Count()); for (var i = 0; i < expectedNrOfSections; i++) { CombinedFailureMechanismSectionAssemblyResult combinedFailureMechanismSectionAssemblyResult = assemblyResults.ElementAt(i); ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableCombinedSectionAssemblies.ElementAt(i); AssertExportableCombinedFailureMechanismSection(combinedFailureMechanismSectionAssemblyResult, exportableCombinedSectionAssembly.Section, referenceLine); AssertExportableCombinedFailureMechanismSectionResult( combinedFailureMechanismSectionAssemblyResult, exportableCombinedSectionAssembly.Section, exportableCombinedSectionAssembly, hasAssemblyGroupResults); } }
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); }
public void CreateExportableAssessmentSection_WithAssessmentSectionWithReferenceLine_ReturnsExpectedValues() { // Setup const string name = "assessmentSectionName"; const string id = "assessmentSectionId"; var random = new Random(21); var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>()) { Name = name, Id = id }; ReferenceLineTestFactory.SetReferenceLineGeometry(assessmentSection.ReferenceLine); assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism()); assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism()); FailureMechanismTestHelper.AddSections(assessmentSection.Piping, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.MacroStabilityInwards, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverErosionInwards, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.HeightStructures, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.ClosingStructures, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.StabilityPointStructures, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.StabilityStoneCover, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.WaveImpactAsphaltCover, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverErosionOutwards, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.DuneErosion, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.Microstability, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverSlipOffOutwards, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverSlipOffInwards, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.PipingStructure, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.WaterPressureAsphaltCover, random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.SpecificFailureMechanisms.First(), random.Next(1, 10)); FailureMechanismTestHelper.AddSections(assessmentSection.SpecificFailureMechanisms.Last(), random.Next(1, 10)); using (new AssemblyToolCalculatorFactoryConfig()) { // Call ExportableAssessmentSection exportableAssessmentSection = ExportableAssessmentSectionFactory.CreateExportableAssessmentSection(assessmentSection); // Assert Assert.AreEqual(name, exportableAssessmentSection.Name); Assert.AreEqual(id, exportableAssessmentSection.Id); CollectionAssert.AreEqual(assessmentSection.ReferenceLine.Points, exportableAssessmentSection.Geometry); ExportableAssessmentSectionAssemblyResult exportableAssessmentSectionAssemblyResult = exportableAssessmentSection.AssessmentSectionAssembly; Assert.AreEqual(ExportableAssemblyMethod.BOI2A1, exportableAssessmentSectionAssemblyResult.ProbabilityAssemblyMethod); Assert.AreEqual(ExportableAssemblyMethod.BOI2B1, exportableAssessmentSectionAssemblyResult.AssemblyGroupAssemblyMethod); Assert.AreEqual(AssessmentSectionAssemblyGroup.APlus, exportableAssessmentSectionAssemblyResult.AssemblyGroup); Assert.AreEqual(0.14, exportableAssessmentSectionAssemblyResult.Probability); AssertExportableFailureMechanisms(exportableAssessmentSection.FailureMechanisms, assessmentSection); Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count()); ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0); Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup); Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod); Assert.AreEqual(0.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.StartDistance); Assert.AreEqual(1.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.EndDistance); AssertExportableFailureMechanismCombinedSectionAssemblyResults(exportableCombinedSectionAssembly.FailureMechanismResults, assessmentSection); Assert.AreEqual(ExportableAssemblyMethod.BOI3A1, exportableCombinedSectionAssembly.Section.AssemblyMethod); Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance); Assert.AreEqual(1.0, exportableCombinedSectionAssembly.Section.EndDistance); } }
/// <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))))); }