Fisheye: Tag 5532b8ad3a175ae4041caecd7329d1b848b3bcc9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/Helpers/IdValidator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/Helpers/SerializableIdValidator.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/Helpers/SerializableIdValidator.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/Helpers/SerializableIdValidator.cs (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -0,0 +1,48 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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.Text.RegularExpressions; + +namespace Ringtoets.AssemblyTool.IO.Model.Helpers +{ + /// + /// Validator to validate the id of a serializable object. + /// + public static class SerializableIdValidator + { + /// + /// Validates whether is a valid id to be used + /// as an identifier in an xml context. + /// + /// The identifier to validate. + /// true when is valid, false otherwise. + public static bool Validate(string id) + { + if (string.IsNullOrWhiteSpace(id)) + { + return false; + } + + var regex = new Regex(@"^[A-Za-z\\_][A-Za-z\\_\d\-\.]+$"); + return regex.IsMatch(id); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs =================================================================== diff -u -r6405d29291fd0a248baa49eac46911b0c9bb35af -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision 6405d29291fd0a248baa49eac46911b0c9bb35af) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -73,7 +73,7 @@ IEnumerable failureMechanismSectionCollections, IEnumerable failureMechanismSections) { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentProcess.cs =================================================================== diff -u -r1815be6776a818b0d390819ca63f89d3c5b78063 -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentProcess.cs (.../SerializableAssessmentProcess.cs) (revision 1815be6776a818b0d390819ca63f89d3c5b78063) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentProcess.cs (.../SerializableAssessmentProcess.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -50,7 +50,7 @@ public SerializableAssessmentProcess(string id, SerializableAssessmentSection assessmentSection) : this() { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs =================================================================== diff -u -rf567b2b8e99d56ee71cdb33116f85c0c918cc59e -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs (.../SerializableAssessmentSection.cs) (revision f567b2b8e99d56ee71cdb33116f85c0c918cc59e) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs (.../SerializableAssessmentSection.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -59,7 +59,7 @@ string name, IEnumerable geometry) : this() { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableCombinedFailureMechanismSectionAssembly.cs =================================================================== diff -u -r6e81e14b714b8842795eadb1995a824320d67554 -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableCombinedFailureMechanismSectionAssembly.cs (.../SerializableCombinedFailureMechanismSectionAssembly.cs) (revision 6e81e14b714b8842795eadb1995a824320d67554) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableCombinedFailureMechanismSectionAssembly.cs (.../SerializableCombinedFailureMechanismSectionAssembly.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -53,7 +53,7 @@ SerializableCombinedFailureMechanismSectionAssemblyResult[] failureMechanismResults, SerializableFailureMechanismSectionAssemblyResult combinedSectionResult) : this() { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanism.cs =================================================================== diff -u -r687840aefa58fd0ebd096f2a600ae0c36caadd76 -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanism.cs (.../SerializableFailureMechanism.cs) (revision 687840aefa58fd0ebd096f2a600ae0c36caadd76) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanism.cs (.../SerializableFailureMechanism.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -58,7 +58,7 @@ SerializableFailureMechanismGroup failureMechanismGroup, SerializableFailureMechanismAssemblyResult failureMechanismAssemblyResult) : this() { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSection.cs =================================================================== diff -u -r587928e72a2c456b39323dc44da85ebb639b2735 -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSection.cs (.../SerializableFailureMechanismSection.cs) (revision 587928e72a2c456b39323dc44da85ebb639b2735) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSection.cs (.../SerializableFailureMechanismSection.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -65,7 +65,7 @@ SerializableFailureMechanismSectionType sectionType, SerializableAssemblyMethod? assemblyMethod = null) { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionAssembly.cs =================================================================== diff -u -r273ffc28990ebc5fccfc3f97fba875873b4c35ae -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionAssembly.cs (.../SerializableFailureMechanismSectionAssembly.cs) (revision 273ffc28990ebc5fccfc3f97fba875873b4c35ae) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionAssembly.cs (.../SerializableFailureMechanismSectionAssembly.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -53,7 +53,7 @@ SerializableFailureMechanismSectionAssemblyResult[] sectionResults, SerializableFailureMechanismSectionAssemblyResult combinedSectionResult) : this() { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionCollection.cs =================================================================== diff -u -r5a7fbd8f43c609641b0a1398e2cab204a46542bf -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionCollection.cs (.../SerializableFailureMechanismSectionCollection.cs) (revision 5a7fbd8f43c609641b0a1398e2cab204a46542bf) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionCollection.cs (.../SerializableFailureMechanismSectionCollection.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -82,7 +82,7 @@ /// Thrown when is invalid. private SerializableFailureMechanismSectionCollection(string id) { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableTotalAssemblyResult.cs =================================================================== diff -u -r9c2c56fafb538c2367a09f52ff602d2bfba82f70 -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableTotalAssemblyResult.cs (.../SerializableTotalAssemblyResult.cs) (revision 9c2c56fafb538c2367a09f52ff602d2bfba82f70) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableTotalAssemblyResult.cs (.../SerializableTotalAssemblyResult.cs) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -53,7 +53,7 @@ SerializableFailureMechanismAssemblyResult assemblyResultWithProbability, SerializableAssessmentSectionAssemblyResult assessmentSectionAssemblyResult) : this() { - if (!IdValidator.Validate(id)) + if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj =================================================================== diff -u -r259f662afb80263cee647a25e6cadeeb654dc41d -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 259f662afb80263cee647a25e6cadeeb654dc41d) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -33,7 +33,7 @@ - + Fisheye: Tag 5532b8ad3a175ae4041caecd7329d1b848b3bcc9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Helpers/IdValidatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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 NUnit.Framework; +using Ringtoets.AssemblyTool.IO.Model.Helpers; + +namespace Ringtoets.AssemblyTool.IO.Test.Model.Helpers +{ + [TestFixture] + public class SerializableIdValidatorTest + { + [Test] + [TestCase("AValidId1-2.3")] + [TestCase("_AValidId1-2.3")] + [TestCase("aValidId1-2.3")] + public void Validate_WithValidIds_ReturnsTrue(string validId) + { + // Call + bool result = SerializableIdValidator.Validate(validId); + + // Assert + Assert.IsTrue(result); + } + + [Test] + [TestCase("-invalidId1-2.3")] + [TestCase("1nvalidId1-2.3")] + [TestCase(".invalidId1-2.3")] + [TestCase("invalidId#")] + [TestCase("invalid#Id")] + [TestCase("#invalidId")] + [TestCase("i nvalidId")] + [TestCase(" invalidId")] + [TestCase("invalidId ")] + [TestCase("i\rnvalidId")] + [TestCase("\rinvalidId")] + [TestCase("invalidId\r")] + [TestCase("")] + [TestCase(" ")] + [TestCase(null)] + public void Validate_WithInvalidIds_ReturnsFalse(string invalidId) + { + // Call + bool result = SerializableIdValidator.Validate(invalidId); + + // Assert + Assert.IsFalse(result); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj =================================================================== diff -u -r259f662afb80263cee647a25e6cadeeb654dc41d -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 259f662afb80263cee647a25e6cadeeb654dc41d) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -31,7 +31,7 @@ - + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil.Test/Ringtoets.AssemblyTool.IO.TestUtil.Test.csproj =================================================================== diff -u -r46c6e661ed805f0fe44e3a70e865415cf57f0cf6 -r5532b8ad3a175ae4041caecd7329d1b848b3bcc9 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil.Test/Ringtoets.AssemblyTool.IO.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.IO.TestUtil.Test.csproj) (revision 46c6e661ed805f0fe44e3a70e865415cf57f0cf6) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil.Test/Ringtoets.AssemblyTool.IO.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.IO.TestUtil.Test.csproj) (revision 5532b8ad3a175ae4041caecd7329d1b848b3bcc9) @@ -29,5 +29,4 @@ Ringtoets.AssemblyTool.IO.TestUtil - \ No newline at end of file