Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs =================================================================== diff -u -r1800188e6e297e9ff843ac4e7299b776e89d7fe9 -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 1800188e6e297e9ff843ac4e7299b776e89d7fe9) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -79,7 +79,7 @@ throw new ArgumentNullException(nameof(assessmentSection)); } - var registry = new ExportableModelRegistry(); + var registry = new ExportableFailureMechanismSectionRegistry(); return new ExportableAssessmentSection(IdentifierGenerator.GenerateId(assessmentSection), assessmentSection.Name, assessmentSection.ReferenceLine.Points, @@ -149,14 +149,14 @@ /// for failure mechanisms that are in assembly based on . /// /// The generator to generate ids for the exportable components. - /// The to keep track of the created items. + /// The to keep track of the created . /// The assessment section to create a collection of /// with probability for. /// A collection of based on failure /// mechanisms that are in assembly. /// Thrown when assembly results cannot be created for . private static IEnumerable CreateExportableFailureMechanisms( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, AssessmentSection assessmentSection) + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, AssessmentSection assessmentSection) { var exportableFailureMechanisms = new List(); @@ -235,7 +235,7 @@ } private static void AddGenericFailureMechanismWhenInAssembly( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, List exportableFailureMechanisms, + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, List exportableFailureMechanisms, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection, Func assembleFailureMechanismFunc, Func assembleFailureMechanismSectionFunc) @@ -251,7 +251,7 @@ } private static IEnumerable CreateExportableFailureMechanismSectionCollections( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, AssessmentSection assessmentSection) + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, AssessmentSection assessmentSection) { IEnumerable failureMechanismsInAssembly = assessmentSection.GetFailureMechanisms() .Concat(assessmentSection.SpecificFailureMechanisms) Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs =================================================================== diff -u -rd41d466b016e29fb8e52680f61a8cb744be378ce -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision d41d466b016e29fb8e52680f61a8cb744be378ce) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -42,7 +42,7 @@ /// with assembly results based on the input parameters. /// /// The generator to generate ids for the exportable components. - /// The to keep track of the created items. + /// The to keep track of the created . /// The failure mechanism to create an for. /// The assessment section the failure mechanism belongs to. /// The to perform @@ -55,7 +55,7 @@ /// Thrown when any parameter is null. /// Thrown when assembly results cannot be created. public static ExportableGenericFailureMechanism CreateExportableGenericFailureMechanism( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection, + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection, Func assembleFailureMechanismFunc, Func assembleFailureMechanismSectionFunc) where TFailureMechanism : IFailureMechanism @@ -106,7 +106,7 @@ /// with assembly results based on the input parameters. /// /// The generator to generate ids for the exportable components. - /// The to keep track of the created items. + /// The to keep track of the created . /// The failure mechanism to create an for. /// The assessment section the failure mechanism belongs to. /// The to perform @@ -117,7 +117,7 @@ /// Thrown when any parameter is null. /// Thrown when assembly results cannot be created. public static ExportableSpecificFailureMechanism CreateExportableSpecificFailureMechanism( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, SpecificFailureMechanism failureMechanism, IAssessmentSection assessmentSection, + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, SpecificFailureMechanism failureMechanism, IAssessmentSection assessmentSection, Func assembleFailureMechanismFunc, Func assembleFailureMechanismSectionFunc) { @@ -166,7 +166,7 @@ /// with assembly results based on . /// /// The generator to generate ids for the exportable components. - /// The to keep track of the created items. + /// The to keep track of the created . /// The failure mechanism to create a collection of /// for. /// The to use in the assembly. @@ -178,7 +178,7 @@ /// Thrown when assembly results cannot be created. private static IEnumerable CreateExportableFailureMechanismSectionResults ( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection, + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection, Func assembleFailureMechanismSectionFunc) where TFailureMechanism : IFailureMechanism where TSectionResult : FailureMechanismSectionResult Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionCollectionFactory.cs =================================================================== diff -u -r287331eb74e6e8044ea74ab4acfab6164109bcec -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionCollectionFactory.cs (.../ExportableFailureMechanismSectionCollectionFactory.cs) (revision 287331eb74e6e8044ea74ab4acfab6164109bcec) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionCollectionFactory.cs (.../ExportableFailureMechanismSectionCollectionFactory.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -38,13 +38,13 @@ /// . /// /// The generator to generate ids for the exportable components. - /// The to keep track of the created items. + /// The to keep track of the created . /// The collection of to create the /// with. /// An . /// Thrown when any parameter is null. public static ExportableFailureMechanismSectionCollection CreateExportableFailureMechanismSectionCollection( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, IEnumerable sections) + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, IEnumerable sections) { if (idGenerator == null) { @@ -61,11 +61,6 @@ throw new ArgumentNullException(nameof(sections)); } - if (registry.Contains(sections)) - { - return registry.Get(sections); - } - var exportableSections = new List(); double startDistance = 0; foreach (FailureMechanismSection section in sections) @@ -79,7 +74,6 @@ var exportableCollection = new ExportableFailureMechanismSectionCollection(idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionCollection_IdPrefix), exportableSections); - registry.Register(sections, exportableCollection); return exportableCollection; } } Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionFactory.cs =================================================================== diff -u -r287331eb74e6e8044ea74ab4acfab6164109bcec -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionFactory.cs (.../ExportableFailureMechanismSectionFactory.cs) (revision 287331eb74e6e8044ea74ab4acfab6164109bcec) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionFactory.cs (.../ExportableFailureMechanismSectionFactory.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -36,7 +36,7 @@ /// Creates an based on its input arguments. /// /// The generator to generate ids for the exportable components. - /// The to keep track of the created items. + /// The to keep track of the created . /// The to create the /// with. /// The start distance of the failure mechanism section between the section @@ -45,7 +45,7 @@ /// Thrown when , /// or is null. public static ExportableFailureMechanismSection CreateExportableFailureMechanismSection( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, FailureMechanismSection section, + IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, FailureMechanismSection section, double startDistance) { if (idGenerator == null) Index: Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/ExportableFailureMechanismSectionRegistry.cs =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/ExportableFailureMechanismSectionRegistry.cs (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/ExportableFailureMechanismSectionRegistry.cs (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -0,0 +1,115 @@ +// Copyright (C) Stichting Deltares 2022. 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.Collections.Generic; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.Common.Data.FailureMechanism; + +namespace Riskeer.Integration.IO.Helpers +{ + /// + /// Class that keeps track of the the created . + /// + public class ExportableFailureMechanismSectionRegistry + { + private readonly Dictionary failureMechanismSections; + + /// + /// Creates a new instance of . + /// + public ExportableFailureMechanismSectionRegistry() + { + failureMechanismSections = new Dictionary(); + } + + /// + /// Obtains the which was registered for the + /// given . + /// + /// The that has been registered. + /// The associated . + /// Thrown when is null. + /// Thrown when no + /// has been registered for . + /// Use to find out whether a create + /// operation has been registered for . + public ExportableFailureMechanismSection Get(FailureMechanismSection section) + { + if (failureMechanismSections == null) + { + throw new ArgumentNullException(nameof(failureMechanismSections)); + } + + if (section == null) + { + throw new ArgumentNullException(nameof(section)); + } + + try + { + return failureMechanismSections[section]; + } + catch (KeyNotFoundException e) + { + throw new InvalidOperationException(e.Message); + } + } + + /// + /// Registers a and the + /// that was constructed with the information. + /// + /// The to be registered with. + /// The to be registered. + /// Thrown when any of the input parameters is null. + internal void Register(FailureMechanismSection section, ExportableFailureMechanismSection exportableSection) + { + if (exportableSection == null) + { + throw new ArgumentNullException(nameof(exportableSection)); + } + + if (section == null) + { + throw new ArgumentNullException(nameof(section)); + } + + failureMechanismSections[section] = exportableSection; + } + + /// + /// Checks whether the given has been registered. + /// + /// The to check for. + /// true if the was registered before, false otherwise. + /// Thrown when is null. + internal bool Contains(FailureMechanismSection section) + { + if (section == null) + { + throw new ArgumentNullException(nameof(section)); + } + + return failureMechanismSections.ContainsKey(section); + } + } +} \ No newline at end of file Fisheye: Tag 838241db2e78d6f4dc62648bca2fc58aec061365 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/ExportableModelRegistry.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs =================================================================== diff -u -rd41d466b016e29fb8e52680f61a8cb744be378ce -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs (.../ExportableFailureMechanismFactoryTest.cs) (revision d41d466b016e29fb8e52680f61a8cb744be378ce) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs (.../ExportableFailureMechanismFactoryTest.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -50,7 +50,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableGenericFailureMechanism( - null, new ExportableModelRegistry(), new TestFailureMechanism(), assessmentSection, (fm, section) => null, (sr, fm, section) => null); + null, new ExportableFailureMechanismSectionRegistry(), new TestFailureMechanism(), assessmentSection, (fm, section) => null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -86,7 +86,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableGenericFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), null, assessmentSection, (fm, section) => null, (sr, fm, section) => null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), null, assessmentSection, (fm, section) => null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -99,7 +99,7 @@ { // Call void Call() => ExportableFailureMechanismFactory.CreateExportableGenericFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), new TestFailureMechanism(), null, (fm, section) => null, (sr, fm, section) => null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), new TestFailureMechanism(), null, (fm, section) => null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -116,7 +116,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableGenericFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), new TestFailureMechanism(), assessmentSection, null, (sr, fm, section) => null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), new TestFailureMechanism(), assessmentSection, null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -134,7 +134,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableGenericFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), new TestFailureMechanism(), assessmentSection, (fm, section) => null, null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), new TestFailureMechanism(), assessmentSection, (fm, section) => null, null); // Assert var exception = Assert.Throws(Call); @@ -157,7 +157,7 @@ var idGenerator = new IdentifierGenerator(); - var registry = new ExportableModelRegistry(); + var registry = new ExportableFailureMechanismSectionRegistry(); RegisterFailureMechanismSections(registry, failureMechanism.Sections); // Call @@ -192,7 +192,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableSpecificFailureMechanism( - null, new ExportableModelRegistry(), new SpecificFailureMechanism(), assessmentSection, (fm, section) => null, (sr, fm, section) => null); + null, new ExportableFailureMechanismSectionRegistry(), new SpecificFailureMechanism(), assessmentSection, (fm, section) => null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -228,7 +228,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableSpecificFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), null, assessmentSection, (fm, section) => null, (sr, fm, section) => null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), null, assessmentSection, (fm, section) => null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -241,7 +241,7 @@ { // Call void Call() => ExportableFailureMechanismFactory.CreateExportableSpecificFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), new SpecificFailureMechanism(), null, (fm, section) => null, (sr, fm, section) => null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), new SpecificFailureMechanism(), null, (fm, section) => null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -258,7 +258,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableSpecificFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), new SpecificFailureMechanism(), assessmentSection, null, (sr, fm, section) => null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), new SpecificFailureMechanism(), assessmentSection, null, (sr, fm, section) => null); // Assert var exception = Assert.Throws(Call); @@ -276,7 +276,7 @@ // Call void Call() => ExportableFailureMechanismFactory.CreateExportableSpecificFailureMechanism( - new IdentifierGenerator(), new ExportableModelRegistry(), new SpecificFailureMechanism(), assessmentSection, (fm, section) => null, null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), new SpecificFailureMechanism(), assessmentSection, (fm, section) => null, null); // Assert var exception = Assert.Throws(Call); @@ -298,7 +298,7 @@ FailureMechanismSectionAssemblyResultWrapper expectedSectionOutput = FailureMechanismSectionAssemblyResultWrapperTestFactory.Create(); var idGenerator = new IdentifierGenerator(); - var registry = new ExportableModelRegistry(); + var registry = new ExportableFailureMechanismSectionRegistry(); RegisterFailureMechanismSections(registry, failureMechanism.Sections); // Call @@ -323,7 +323,7 @@ expectedSectionOutput, exportableFailureMechanismSections, exportableFailureMechanism.SectionAssemblyResults); } - private static void RegisterFailureMechanismSections(ExportableModelRegistry registry, IEnumerable failureMechanismSections) + private static void RegisterFailureMechanismSections(ExportableFailureMechanismSectionRegistry registry, IEnumerable failureMechanismSections) { ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( new IdentifierGenerator(), registry, failureMechanismSections); Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionCollectionFactoryTest.cs =================================================================== diff -u -rb05ce5d95ae55fbb0fa4d89c871f18c6be626b75 -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionCollectionFactoryTest.cs (.../ExportableFailureMechanismSectionCollectionFactoryTest.cs) (revision b05ce5d95ae55fbb0fa4d89c871f18c6be626b75) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionCollectionFactoryTest.cs (.../ExportableFailureMechanismSectionCollectionFactoryTest.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; using NUnit.Framework; @@ -40,7 +39,7 @@ { // Call void Call() => ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( - null, new ExportableModelRegistry(), Enumerable.Empty()); + null, new ExportableFailureMechanismSectionRegistry(), Enumerable.Empty()); // Assert var exception = Assert.Throws(Call); @@ -58,13 +57,13 @@ var exception = Assert.Throws(Call); Assert.AreEqual("registry", exception.ParamName); } - + [Test] public void CreateExportableFailureMechanismSectionCollection_SectionsNull_ThrowsArgumentNullException() { // Call void Call() => ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( - new IdentifierGenerator(), new ExportableModelRegistry(), null); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), null); // Assert var exception = Assert.Throws(Call); @@ -95,7 +94,7 @@ }) }; - var registry = new ExportableModelRegistry(); + var registry = new ExportableFailureMechanismSectionRegistry(); // Call ExportableFailureMechanismSectionCollection collection = @@ -110,41 +109,18 @@ Assert.AreEqual("Bv.0", firstExportableSection.Id); Assert.AreEqual(0, firstExportableSection.StartDistance); Assert.AreEqual(10, firstExportableSection.EndDistance); - + ExportableFailureMechanismSection secondExportableSection = collection.Sections.ElementAt(1); Assert.AreSame(sections[1].Points, secondExportableSection.Geometry); Assert.AreEqual("Bv.1", secondExportableSection.Id); Assert.AreEqual(10, secondExportableSection.StartDistance); Assert.AreEqual(20, secondExportableSection.EndDistance); - + ExportableFailureMechanismSection thirdExportableSection = collection.Sections.ElementAt(2); Assert.AreEqual("Bv.2", thirdExportableSection.Id); Assert.AreSame(sections[2].Points, thirdExportableSection.Geometry); Assert.AreEqual(20, thirdExportableSection.StartDistance); Assert.AreEqual(40, thirdExportableSection.EndDistance); } - - [Test] - public void CreateExportableFailureMechanismSectionCollection_SectionsAlreadyRegistered_ReturnsRegisteredExportableModel() - { - // Setup - var sections = new List(); - - var registry = new ExportableModelRegistry(); - var idGenerator = new IdentifierGenerator(); - ExportableFailureMechanismSectionCollection exportableCollection1 = - ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection(idGenerator, registry, sections); - - - // Precondition - Assert.True(registry.Contains(sections)); - - // Call - ExportableFailureMechanismSectionCollection exportableCollection2 = - ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection(idGenerator, registry, sections); - - // Assert - Assert.AreSame(exportableCollection1, exportableCollection2); - } } } \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionFactoryTest.cs =================================================================== diff -u -r287331eb74e6e8044ea74ab4acfab6164109bcec -r838241db2e78d6f4dc62648bca2fc58aec061365 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionFactoryTest.cs (.../ExportableFailureMechanismSectionFactoryTest.cs) (revision 287331eb74e6e8044ea74ab4acfab6164109bcec) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionFactoryTest.cs (.../ExportableFailureMechanismSectionFactoryTest.cs) (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -40,7 +40,7 @@ // Call void Call() => ExportableFailureMechanismSectionFactory.CreateExportableFailureMechanismSection( - null, new ExportableModelRegistry(), FailureMechanismSectionTestFactory.CreateFailureMechanismSection(), random.NextDouble()); + null, new ExportableFailureMechanismSectionRegistry(), FailureMechanismSectionTestFactory.CreateFailureMechanismSection(), random.NextDouble()); // Assert var exception = Assert.Throws(Call); @@ -70,7 +70,7 @@ // Call void Call() => ExportableFailureMechanismSectionFactory.CreateExportableFailureMechanismSection( - new IdentifierGenerator(), new ExportableModelRegistry(), null, random.NextDouble()); + new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), null, random.NextDouble()); // Assert var exception = Assert.Throws(Call); @@ -87,7 +87,7 @@ var idGenerator = new IdentifierGenerator(); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var registry = new ExportableModelRegistry(); + var registry = new ExportableFailureMechanismSectionRegistry(); // Call ExportableFailureMechanismSection exportableSection = @@ -110,7 +110,7 @@ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var idGenerator = new IdentifierGenerator(); - var registry = new ExportableModelRegistry(); + var registry = new ExportableFailureMechanismSectionRegistry(); ExportableFailureMechanismSection exportableModel1 = ExportableFailureMechanismSectionFactory.CreateExportableFailureMechanismSection(idGenerator, registry, section, random.NextDouble()); Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionRegistryTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionRegistryTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionRegistryTest.cs (revision 838241db2e78d6f4dc62648bca2fc58aec061365) @@ -0,0 +1,163 @@ +// Copyright (C) Stichting Deltares 2022. 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 NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.TestUtil; +using Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Integration.IO.Helpers; + +namespace Riskeer.Integration.IO.Test.Helpers +{ + [TestFixture] + public class ExportableFailureMechanismSectionRegistryTest + { + [Test] + public void Register_SectionNull_ThrowsArgumentNullException() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + + // Call + void Call() => registry.Register(null, ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection()); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("section", paramName); + } + + [Test] + public void Register_ExportableSectionNull_ThrowsArgumentNullException() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + + // Call + void Call() => registry.Register(FailureMechanismSectionTestFactory.CreateFailureMechanismSection(), null); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("exportableSection", paramName); + } + + [Test] + public void Contains_SectionNull_ThrowsArgumentNullException() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + + // Call + void Call() => registry.Contains(null); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("section", paramName); + } + + [Test] + public void Contains_WithRegisteredSection_ReturnsTrue() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + registry.Register(section, ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection()); + + // Call + bool result = registry.Contains(section); + + // Assert + Assert.IsTrue(result); + } + + [Test] + public void Contains_WithUnregisteredSection_ReturnsFalse() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + registry.Register(FailureMechanismSectionTestFactory.CreateFailureMechanismSection(), + ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection()); + + // Call + bool result = registry.Contains(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void Contains_ExportableModelRegistryEmpty_ReturnsFalse() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + + // Call + bool result = registry.Contains(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void Get_SectionNull_ThrowsArgumentNullException() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + + // Call + void Call() => registry.Get(null); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("section", paramName); + } + + [Test] + public void GivenRegistryWithSectionAdded_WhenGetWithSameSection_ThenSameExportableFailureMechanismSectionReturned() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + ExportableFailureMechanismSection exportableSection = ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(); + registry.Register(section, exportableSection); + + // Call + ExportableFailureMechanismSection result = registry.Get(section); + + // Assert + Assert.AreSame(exportableSection, result); + } + + [Test] + public void GivenEmptyRegistry_WhenGettingExportableFailureMechanismSection_ThenInvalidOperationExceptionThrown() + { + // Setup + var registry = new ExportableFailureMechanismSectionRegistry(); + + // Call + void Call() => registry.Get(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + // Assert + Assert.Throws(Call); + } + } +} \ No newline at end of file Fisheye: Tag 838241db2e78d6f4dc62648bca2fc58aec061365 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/ExportableModelRegistryTest.cs'. Fisheye: No comparison available. Pass `N' to diff?