Index: Riskeer/Common/src/Riskeer.Common.Forms/MapLayers/CalculatableFailureMechanismSectionResultsMapLayer.cs =================================================================== diff -u --- Riskeer/Common/src/Riskeer.Common.Forms/MapLayers/CalculatableFailureMechanismSectionResultsMapLayer.cs (revision 0) +++ Riskeer/Common/src/Riskeer.Common.Forms/MapLayers/CalculatableFailureMechanismSectionResultsMapLayer.cs (revision 9616d6e1fe303f236014e8f5f668a3990373d16b) @@ -0,0 +1,85 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Core.Common.Base; +using Riskeer.AssemblyTool.Data; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.FailureMechanism; + +namespace Riskeer.Common.Forms.MapLayers +{ + /// + /// Map layer to show section results for . + /// + /// The type of failure mechanism. + /// The type of section result. + /// The type of calculation input. + public class CalculatableFailureMechanismSectionResultsMapLayer : NonCalculatableFailureMechanismSectionResultsMapLayer + where TFailureMechanism : IHasSectionResults, ICalculatableFailureMechanism + where TSectionResult : FailureMechanismSectionResult + where TCalculationInput : class, ICalculationInput + { + private readonly RecursiveObserver calculationInputsObserver; + private readonly RecursiveObserver calculationGroupsObserver; + private readonly RecursiveObserver calculationScenariosObserver; + + /// + /// Creates a new instance of . + /// + /// The failure path to get the data from. + /// The used to assemble the result of a section result. + /// Thrown when is null. + public CalculatableFailureMechanismSectionResultsMapLayer( + TFailureMechanism failureMechanism, Func performAssemblyFunc) + : base(failureMechanism, performAssemblyFunc) + { + calculationGroupsObserver = new RecursiveObserver(UpdateFeatures, pcg => pcg.Children) + { + Observable = failureMechanism.CalculationsGroup + }; + + calculationInputsObserver = new RecursiveObserver( + UpdateFeatures, pcg => pcg.Children.Concat(pcg.Children.OfType>().Select(pc => pc.InputParameters))) + { + Observable = failureMechanism.CalculationsGroup + }; + + calculationScenariosObserver = new RecursiveObserver(UpdateFeatures, pcg => pcg.Children) + { + Observable = failureMechanism.CalculationsGroup + }; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + calculationInputsObserver.Dispose(); + calculationGroupsObserver.Dispose(); + calculationScenariosObserver.Dispose(); + } + + base.Dispose(disposing); + } + } +} \ No newline at end of file Index: Riskeer/Common/src/Riskeer.Common.Forms/MapLayers/NonCalculatableFailureMechanismSectionResultsMapLayer.cs =================================================================== diff -u --- Riskeer/Common/src/Riskeer.Common.Forms/MapLayers/NonCalculatableFailureMechanismSectionResultsMapLayer.cs (revision 0) +++ Riskeer/Common/src/Riskeer.Common.Forms/MapLayers/NonCalculatableFailureMechanismSectionResultsMapLayer.cs (revision 9616d6e1fe303f236014e8f5f668a3990373d16b) @@ -0,0 +1,117 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base; +using Core.Components.Gis.Data; +using Riskeer.AssemblyTool.Data; +using Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Forms.Factories; + +namespace Riskeer.Common.Forms.MapLayers +{ + /// + /// Map layer to show section results. + /// + /// The type of section result. + public class NonCalculatableFailureMechanismSectionResultsMapLayer : IDisposable + where TSectionResult : FailureMechanismSectionResult + { + private readonly Func performAssemblyFunc; + + private readonly IHasSectionResults failureMechanism; + + private Observer failureMechanismObserver; + private RecursiveObserver, TSectionResult> sectionResultObserver; + + /// + /// Creates a new instance of . + /// + /// The failure path to get the data from. + /// The used to assemble the result of a section result. + /// Thrown when is null. + public NonCalculatableFailureMechanismSectionResultsMapLayer( + IHasSectionResults failureMechanism, + Func performAssemblyFunc) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (performAssemblyFunc == null) + { + throw new ArgumentNullException(nameof(performAssemblyFunc)); + } + + this.failureMechanism = failureMechanism; + this.performAssemblyFunc = performAssemblyFunc; + + CreateObservers(); + + MapData = AssemblyMapDataFactory.CreateAssemblyMapData(); + SetFeatures(); + } + + /// + /// Gets the section results map data. + /// + public MapLineData MapData { get; } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + failureMechanismObserver.Dispose(); + sectionResultObserver.Dispose(); + } + } + + private void CreateObservers() + { + failureMechanismObserver = new Observer(UpdateFeatures) + { + Observable = failureMechanism + }; + sectionResultObserver = new RecursiveObserver, TSectionResult>(UpdateFeatures, sr => sr) + { + Observable = failureMechanism.SectionResults + }; + } + + protected void UpdateFeatures() + { + SetFeatures(); + MapData.NotifyObservers(); + } + + private void SetFeatures() + { + MapData.Features = AssemblyMapDataFeaturesFactory.CreateAssemblyGroupFeatures(failureMechanism, performAssemblyFunc); + } + } +} \ No newline at end of file Index: Riskeer/Common/test/Riskeer.Common.Data.TestUtil/TestFailureMechanism.cs =================================================================== diff -u -re696050dcb37fb80db692f88a8263640e61cd335 -r9616d6e1fe303f236014e8f5f668a3990373d16b --- Riskeer/Common/test/Riskeer.Common.Data.TestUtil/TestFailureMechanism.cs (.../TestFailureMechanism.cs) (revision e696050dcb37fb80db692f88a8263640e61cd335) +++ Riskeer/Common/test/Riskeer.Common.Data.TestUtil/TestFailureMechanism.cs (.../TestFailureMechanism.cs) (revision 9616d6e1fe303f236014e8f5f668a3990373d16b) @@ -31,7 +31,7 @@ /// Simple failure mechanism which can be used for testing. /// public class TestFailureMechanism : FailureMechanismBase, IHasSectionResults, - IHasGeneralInput + IHasGeneralInput, ICalculatableFailureMechanism { private const string defaultName = "Test failure mechanism"; private const string defaultCode = "TFM"; @@ -70,13 +70,16 @@ { sectionResultsOld = new ObservableList(); sectionResults = new ObservableList(); - Calculations = calculations; + CalculationsGroup = new CalculationGroup(); + CalculationsGroup.Children.AddRange(calculations); GeneralInput = new GeneralInput(); } + public CalculationGroup CalculationsGroup { get; } + public GeneralInput GeneralInput { get; } - public override IEnumerable Calculations { get; } + public override IEnumerable Calculations => CalculationsGroup.GetCalculations(); public IObservableEnumerable SectionResultsOld => sectionResultsOld; Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/MapLayers/CalculatableFailureMechanismSectionResultsMapLayerTest.cs =================================================================== diff -u --- Riskeer/Common/test/Riskeer.Common.Forms.Test/MapLayers/CalculatableFailureMechanismSectionResultsMapLayerTest.cs (revision 0) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/MapLayers/CalculatableFailureMechanismSectionResultsMapLayerTest.cs (revision 9616d6e1fe303f236014e8f5f668a3990373d16b) @@ -0,0 +1,235 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.AssemblyTool.Data; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.MapLayers; +using Riskeer.Common.Forms.TestUtil; + +namespace Riskeer.Common.Forms.Test.MapLayers +{ + [TestFixture] + public class CalculatableFailureMechanismSectionResultsMapLayerTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var random = new Random(21); + var failureMechanism = new TestFailureMechanism(); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + // Call + using (var mapLayer = new CalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + // Assert + Assert.IsInstanceOf>(mapLayer); + } + } + + [Test] + public void GivenMapLayerWithFailureMechanismSectionAssemblyResults_WhenChangingCalculationGroupDataAndObserversNotified_ThenMapDataUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(21); + var failureMechanism = new TestFailureMechanism(); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + using (var mapLayer = new CalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + mapLayer.MapData.Attach(observer); + + // Precondition + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + + // When + failureMechanism.CalculationsGroup.Children.Add(new TestCalculation()); + failureMechanism.CalculationsGroup.NotifyObservers(); + + // Then + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + + mocks.VerifyAll(); + } + + [Test] + public void GivenMapLayerWithFailureMechanismSectionAssemblyResults_WhenChangingCalculationScenarioDataAndObserversNotified_ThenMapDataUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(21); + var calculationScenario = new TestCalculationScenario(); + var failureMechanism = new TestFailureMechanism(new[] + { + calculationScenario + }); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + using (var mapLayer = new CalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + mapLayer.MapData.Attach(observer); + + // Precondition + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + + // When + calculationScenario.IsRelevant = false; + calculationScenario.NotifyObservers(); + + // Then + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + + mocks.VerifyAll(); + } + + [Test] + public void GivenMapLayerWithFailureMechanismSectionAssemblyResults_WhenChangingRootCalculationScenarioInputDataAndObserversNotified_ThenMapDataUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(21); + var calculationScenario = new TestCalculationScenario(); + var failureMechanism = new TestFailureMechanism(new[] + { + calculationScenario + }); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + using (var mapLayer = new CalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + mapLayer.MapData.Attach(observer); + + // Precondition + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + + // When + calculationScenario.InputParameters.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + calculationScenario.InputParameters.NotifyObservers(); + + // Then + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + + mocks.VerifyAll(); + } + + [Test] + public void GivenMapLayerWithFailureMechanismSectionAssemblyResults_WhenChangingNestedCalculationScenarioInputDataAndObserversNotified_ThenMapDataUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(21); + var calculationScenario = new TestCalculationScenario(); + var failureMechanism = new TestFailureMechanism(new[] + { + calculationScenario + }); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var nestedCalculationScenario = new TestCalculationScenario(); + var nestedCalculationGroup = new CalculationGroup(); + nestedCalculationGroup.Children.Add(nestedCalculationScenario); + failureMechanism.CalculationsGroup.Children.Add(nestedCalculationGroup); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + using (var mapLayer = new CalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + mapLayer.MapData.Attach(observer); + + // Precondition + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + + // When + nestedCalculationScenario.InputParameters.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + nestedCalculationScenario.InputParameters.NotifyObservers(); + + // Then + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/MapLayers/NonCalculatableFailureMechanismSectionResultsMapLayerTest.cs =================================================================== diff -u --- Riskeer/Common/test/Riskeer.Common.Forms.Test/MapLayers/NonCalculatableFailureMechanismSectionResultsMapLayerTest.cs (revision 0) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/MapLayers/NonCalculatableFailureMechanismSectionResultsMapLayerTest.cs (revision 9616d6e1fe303f236014e8f5f668a3990373d16b) @@ -0,0 +1,179 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.AssemblyTool.Data; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.MapLayers; +using Riskeer.Common.Forms.TestUtil; + +namespace Riskeer.Common.Forms.Test.MapLayers +{ + [TestFixture] + public class NonCalculatableFailureMechanismSectionResultsMapLayerTest + { + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + void Call() => new NonCalculatableFailureMechanismSectionResultsMapLayer( + null, result => null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("failureMechanism", exception.ParamName); + } + + [Test] + public void Constructor_PerformAssemblyFuncNull_ThrowsArgumentNullException() + { + // Call + void Call() => new NonCalculatableFailureMechanismSectionResultsMapLayer( + new TestFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("performAssemblyFunc", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var random = new Random(21); + var failureMechanism = new TestFailureMechanism(); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + // Call + using (var mapLayer = new NonCalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + // Assert + Assert.IsInstanceOf(mapLayer); + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + } + + [Test] + public void GivenMapLayerWithFailureMechanismSectionAssemblyResults_WhenChangingSectionResultsDataAndObserversNotified_ThenMapDataUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(21); + var failureMechanism = new TestFailureMechanism(); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + using (var mapLayer = new NonCalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + mapLayer.MapData.Attach(observer); + + // Precondition + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + + // When + TestFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.First(); + sectionResult.IsRelevant = false; + sectionResult.NotifyObservers(); + + // Then + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + + mocks.VerifyAll(); + } + + [Test] + public void GivenMapLayerWithFailureMechanismSectionAssemblyResults_WhenChangingFailureMechanismDataAndObserversNotified_ThenMapDataUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(21); + var failureMechanism = new TestFailureMechanism(); + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }, string.Empty); + + var assemblyResult = new FailureMechanismSectionAssemblyResult( + random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextEnumValue()); + + using (var mapLayer = new NonCalculatableFailureMechanismSectionResultsMapLayer( + failureMechanism, result => assemblyResult)) + { + mapLayer.MapData.Attach(observer); + + // Precondition + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + + // When + failureMechanism.SetSections(new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }), + FailureMechanismSectionTestFactory.CreateFailureMechanismSection(new[] + { + new Point2D(1, 1), + new Point2D(2, 2) + }) + }, string.Empty); + failureMechanism.NotifyObservers(); + + // Then + MapDataTestHelper.AssertAssemblyMapData(failureMechanism, assemblyResult, mapLayer.MapData); + } + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Riskeer/Common/test/Riskeer.Common.Forms.TestUtil/MapDataTestHelper.cs =================================================================== diff -u -r26259e86f36858575c3307e3a97602a899026bbf -r9616d6e1fe303f236014e8f5f668a3990373d16b --- Riskeer/Common/test/Riskeer.Common.Forms.TestUtil/MapDataTestHelper.cs (.../MapDataTestHelper.cs) (revision 26259e86f36858575c3307e3a97602a899026bbf) +++ Riskeer/Common/test/Riskeer.Common.Forms.TestUtil/MapDataTestHelper.cs (.../MapDataTestHelper.cs) (revision 9616d6e1fe303f236014e8f5f668a3990373d16b) @@ -34,6 +34,7 @@ using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.DikeProfiles; using Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Data.FailurePath; using Riskeer.Common.Forms.TypeConverters; namespace Riskeer.Common.Forms.TestUtil @@ -345,6 +346,48 @@ AssertAssemblyMapData("Gecombineerd toetsoordeel", failureMechanism, expectedCombinedAssemblyCategory, assemblyMapDataCollection.ElementAt(3)); } + /// + /// Asserts whether the contains the data that is representative + /// for the . + /// + /// The the that contains the original data. + /// The expected that contains the original data. + /// The that needs to be asserted. + /// Thrown when: + /// + /// the name of the is not Duidingsklasse per vak; + /// the amount of features in is not equal to the + /// amount of the ; + /// the geometries of the features in are not equal to + /// the expected geometry of the ; + /// the meta data does not contain the . + /// + /// + public static void AssertAssemblyMapData(IFailureMechanism failureMechanism, + FailureMechanismSectionAssemblyResult expectedAssemblyResult, + MapData mapData) + { + var assemblyMapLineData = (MapLineData) mapData; + Assert.AreEqual("Duidingsklasse per vak", assemblyMapLineData.Name); + + MapFeature[] features = assemblyMapLineData.Features.ToArray(); + FailureMechanismSection[] sections = failureMechanism.Sections.ToArray(); + Assert.AreEqual(sections.Length, features.Length); + + for (var index = 0; index < sections.Length; index++) + { + MapFeature feature = features[index]; + + FailureMechanismSection failureMechanismSection = sections[index]; + CollectionAssert.AreEqual(failureMechanismSection.Points, feature.MapGeometries.Single().PointCollections.Single()); + + Assert.AreEqual(1, feature.MetaData.Count); + Assert.AreEqual(new EnumDisplayWrapper( + DisplayFailureMechanismSectionAssemblyGroupConverter.Convert(expectedAssemblyResult.AssemblyGroup)).DisplayName, + feature.MetaData["Categorie"]); + } + } + private static void AssertAssemblyMapData(string expectedMapDataName, IFailureMechanism failureMechanism, FailureMechanismSectionAssemblyOld expectedAssembly,