Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyFactory.cs =================================================================== diff -u -r22862b0450a931d23bb13ab79874e54a05df5772 -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyFactory.cs (.../ExportableAssemblyFactory.cs) (revision 22862b0450a931d23bb13ab79874e54a05df5772) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyFactory.cs (.../ExportableAssemblyFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -56,10 +56,10 @@ ExportableAssessmentSection exportableAssessmentSection = ExportableAssessmentSectionFactory.CreateExportableAssessmentSection( idGenerator, assessmentSection); - var exportableAssessmentProcess = new ExportableAssessmentProcess(idGenerator.GetNewId(Resources.ExportableAssessmentProcess_IdPrefix), + var exportableAssessmentProcess = new ExportableAssessmentProcess(idGenerator.GetUniqueId(Resources.ExportableAssessmentProcess_IdPrefix), 2023, 2035); - return new ExportableAssembly(idGenerator.GetNewId(Resources.ExportableAssembly_IdPrefix), + return new ExportableAssembly(idGenerator.GetUniqueId(Resources.ExportableAssembly_IdPrefix), exportableAssessmentSection, exportableAssessmentProcess); } } Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs =================================================================== diff -u -r6718dc9ecdd2863f11f0e9936a7a13629212945b -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 6718dc9ecdd2863f11f0e9936a7a13629212945b) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -110,7 +110,7 @@ AssessmentSectionAssemblyResultWrapper assemblyResultWrapper = AssessmentSectionAssemblyFactory.AssembleAssessmentSection(assessmentSection); AssessmentSectionAssemblyResult assemblyResult = assemblyResultWrapper.AssemblyResult; return new ExportableAssessmentSectionAssemblyResult( - idGenerator.GetNewId(Resources.ExportableTotalAssemblyResult_IdPrefix), + idGenerator.GetUniqueId(Resources.ExportableTotalAssemblyResult_IdPrefix), ConvertAssemblyGroup(assemblyResult.AssemblyGroup), assemblyResult.Probability, ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyGroupMethod), ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.ProbabilityMethod)); Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs =================================================================== diff -u -rf8d1729383c35f7c6e435afbfc314beed2b3175e -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision f8d1729383c35f7c6e435afbfc314beed2b3175e) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -88,7 +88,7 @@ ExportableCombinedFailureMechanismSection exportableCombinedSection = registry.Get(assemblyResult); var exportableSectionResult = new ExportableCombinedSectionAssembly( - idGenerator.GetNewId(Resources.ExportableCombinedSectionAssembly_IdPrefix), exportableCombinedSection, + idGenerator.GetUniqueId(Resources.ExportableCombinedSectionAssembly_IdPrefix), exportableCombinedSection, ExportableFailureMechanismSectionAssemblyGroupConverter.ConvertTo(assemblyResult.TotalResult), ExportableAssemblyMethodConverter.ConvertTo(assemblyResult.CombinedSectionResultAssemblyMethod), CreateFailureMechanismCombinedSectionAssemblyResults(registry, exportableCombinedSection, assemblyResult, assessmentSection)); Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs =================================================================== diff -u -r1a5616c5fe4da4c7d7c4fe75efad59f88b6aa90b -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision 1a5616c5fe4da4c7d7c4fe75efad59f88b6aa90b) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -96,7 +96,7 @@ } FailureMechanismAssemblyResultWrapper assemblyResultWrapper = assembleFailureMechanismFunc(failureMechanism, assessmentSection); - return new ExportableGenericFailureMechanism(idGenerator.GetNewId(Resources.ExportableFailureMechanism_IdPrefix), + return new ExportableGenericFailureMechanism(idGenerator.GetUniqueId(Resources.ExportableFailureMechanism_IdPrefix), new ExportableFailureMechanismAssemblyResult( assemblyResultWrapper.AssemblyResult, ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyMethod)), @@ -158,7 +158,7 @@ } FailureMechanismAssemblyResultWrapper assemblyResultWrapper = assembleFailureMechanismFunc(failureMechanism, assessmentSection); - return new ExportableSpecificFailureMechanism(idGenerator.GetNewId(Resources.ExportableFailureMechanism_IdPrefix), + return new ExportableSpecificFailureMechanism(idGenerator.GetUniqueId(Resources.ExportableFailureMechanism_IdPrefix), new ExportableFailureMechanismAssemblyResult( assemblyResultWrapper.AssemblyResult, ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyMethod)), Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs =================================================================== diff -u -rf70260f208dfbbac4b822a2a4b00a8edc5351ccd -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs (.../ExportableFailureMechanismSectionAssemblyResultFactory.cs) (revision f70260f208dfbbac4b822a2a4b00a8edc5351ccd) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs (.../ExportableFailureMechanismSectionAssemblyResultFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -105,7 +105,7 @@ } var exportableFailureMechanismSectionAssemblyResult = new ExportableFailureMechanismSectionAssemblyResult( - idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionAssemblyResult_IdPrefix), + idGenerator.GetUniqueId(Resources.ExportableFailureMechanismSectionAssemblyResult_IdPrefix), registry.Get(sectionResult.Section), assemblyResult.SectionProbability, ExportableFailureMechanismSectionAssemblyGroupConverter.ConvertTo(assemblyResult.FailureMechanismSectionAssemblyGroup), Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionCollectionFactory.cs =================================================================== diff -u -r3f16d047b4c6d2a626357315f8ae38d678be17bb -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionCollectionFactory.cs (.../ExportableFailureMechanismSectionCollectionFactory.cs) (revision 3f16d047b4c6d2a626357315f8ae38d678be17bb) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionCollectionFactory.cs (.../ExportableFailureMechanismSectionCollectionFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -75,7 +75,7 @@ startDistance = exportableFailureMechanismSection.EndDistance; } - return new ExportableFailureMechanismSectionCollection(idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionCollection_IdPrefix), exportableSections); + return new ExportableFailureMechanismSectionCollection(idGenerator.GetUniqueId(Resources.ExportableFailureMechanismSectionCollection_IdPrefix), exportableSections); } /// @@ -119,7 +119,7 @@ idGenerator, registry, referenceLine, assemblyResult)) .ToArray(); - var exportableCollection = new ExportableFailureMechanismSectionCollection(idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionCollection_IdPrefix), + var exportableCollection = new ExportableFailureMechanismSectionCollection(idGenerator.GetUniqueId(Resources.ExportableFailureMechanismSectionCollection_IdPrefix), exportableSections); return exportableCollection; } Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionFactory.cs =================================================================== diff -u -rb355635a42391cc4f1699f6d3a0e3439ef7a7e52 -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionFactory.cs (.../ExportableFailureMechanismSectionFactory.cs) (revision b355635a42391cc4f1699f6d3a0e3439ef7a7e52) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionFactory.cs (.../ExportableFailureMechanismSectionFactory.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -73,7 +73,7 @@ } double endDistance = startDistance + section.Length; - var exportableSection = new ExportableFailureMechanismSection(idGenerator.GetNewId(Resources.ExportableFailureMechanismSection_IdPrefix), + var exportableSection = new ExportableFailureMechanismSection(idGenerator.GetUniqueId(Resources.ExportableFailureMechanismSection_IdPrefix), section.Points, startDistance, endDistance); registry.Register(section, exportableSection); return exportableSection; @@ -119,7 +119,7 @@ } var exportableSection = new ExportableCombinedFailureMechanismSection( - idGenerator.GetNewId(Resources.ExportableFailureMechanismSection_IdPrefix), + idGenerator.GetUniqueId(Resources.ExportableFailureMechanismSection_IdPrefix), FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd), assemblyResult.SectionStart, assemblyResult.SectionEnd, ExportableAssemblyMethodConverter.ConvertTo(assemblyResult.CommonSectionAssemblyMethod)); Index: Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/IdentifierGenerator.cs =================================================================== diff -u -r6718dc9ecdd2863f11f0e9936a7a13629212945b -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/IdentifierGenerator.cs (.../IdentifierGenerator.cs) (revision 6718dc9ecdd2863f11f0e9936a7a13629212945b) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/IdentifierGenerator.cs (.../IdentifierGenerator.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -25,7 +25,7 @@ namespace Riskeer.Integration.IO.Helpers { /// - /// Class to generate unique ids. + /// Class to generate ids. /// public class IdentifierGenerator { @@ -40,13 +40,13 @@ } /// - /// Gets a new unique id prefixed by . + /// Gets an unique id prefixed by . /// /// The prefix to be used for the generated id. /// An unique id. /// Thrown when is /// null, empty or consists of only whitespaces. - public string GetNewId(string prefix) + public string GetUniqueId(string prefix) { if (string.IsNullOrWhiteSpace(prefix)) { Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/IdentifierGeneratorTest.cs =================================================================== diff -u -r6718dc9ecdd2863f11f0e9936a7a13629212945b -rdb35fac9d09304befdae9dc51aa4ef734657f11b --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/IdentifierGeneratorTest.cs (.../IdentifierGeneratorTest.cs) (revision 6718dc9ecdd2863f11f0e9936a7a13629212945b) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/IdentifierGeneratorTest.cs (.../IdentifierGeneratorTest.cs) (revision db35fac9d09304befdae9dc51aa4ef734657f11b) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2022. All rights reserved. +// Copyright (C) Stichting Deltares 2022. All rights reserved. // // This file is part of Riskeer. // @@ -33,92 +33,71 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void GetNewId_InvalidPrefix_ThrowsArgumentException(string invalidPrefix) + public void GetUniqueId_InvalidPrefix_ThrowsArgumentException(string invalidPrefix) { // Setup var generator = new IdentifierGenerator(); // Call - void Call() => generator.GetNewId(invalidPrefix); + void Call() => generator.GetUniqueId(invalidPrefix); // Assert const string expectedMessage = "'prefix' is null, empty or consists of whitespace."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); } [Test] - public void GetNewId_WithPrefix_ReturnsExpectedValue() + public void GetUniqueId_WithPrefix_ReturnsExpectedValue() { // Setup const string prefix = "prefix"; var generator = new IdentifierGenerator(); // Call - string id = generator.GetNewId(prefix); + string id = generator.GetUniqueId(prefix); // Assert Assert.AreEqual($"{prefix}.0", id); } [Test] - public void GetNewId_PrefixAlreadyUsed_ReturnsExpectedValue() + public void GetUniqueId_PrefixAlreadyUsed_ReturnsExpectedValue() { // Setup const string prefix = "prefix"; var generator = new IdentifierGenerator(); - string currentId = generator.GetNewId(prefix); + string currentId = generator.GetUniqueId(prefix); // Precondition Assert.AreEqual($"{prefix}.0", currentId); // Call - string generatedId = generator.GetNewId(prefix); + string generatedId = generator.GetUniqueId(prefix); // Assert Assert.AreEqual($"{prefix}.1", generatedId); } [Test] - public void GetNewId_NewPrefix_ReturnsExpectedValues() + public void GetUniqueId_NewPrefix_ReturnsExpectedValues() { // Given const string prefix = "prefix"; var generator = new IdentifierGenerator(); // Precondition - Assert.AreEqual($"{prefix}.0", generator.GetNewId(prefix)); + Assert.AreEqual($"{prefix}.0", generator.GetUniqueId(prefix)); const string newPrefix = "NewPrefix"; // When - string newPrefixId = generator.GetNewId(newPrefix); + string newPrefixId = generator.GetUniqueId(newPrefix); // Then Assert.AreEqual($"{newPrefix}.0", newPrefixId); } [Test] - public void GivenIdGenerator_WhenMultiplePrefixesUsed_ThenReturnsExpectedValues() - { - // Given - const string prefix = "prefix"; - var generator = new IdentifierGenerator(); - - // Precondition - Assert.AreEqual($"{prefix}.0", generator.GetNewId(prefix)); - - const string newPrefix = "NewPrefix"; - - // When - string oldPrefixId = generator.GetNewId(prefix); - string newPrefixId = generator.GetNewId(newPrefix); - - // Then - Assert.AreEqual($"{prefix}.1", oldPrefixId); - Assert.AreEqual($"{newPrefix}.0", newPrefixId); - } - - [Test] [TestCase(null)] [TestCase("")] [TestCase(" ")]