// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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; namespace Deltares.DamEngine.Io.Tests; [TestFixture] public class IdValidatorTests { [TestCase("ABCDEFGHIJLMNOPQRSTUVWXYZ")] [TestCase("A")] [TestCase("Z")] [TestCase("K")] [TestCase("JUSTATEST")] [TestCase("abcdefghijklmnopqrstuvwxyz")] [TestCase("a")] [TestCase("z")] [TestCase("k")] [TestCase("justatest")] [TestCase("01234567879")] [TestCase("0")] [TestCase("9")] [TestCase("5")] [TestCase("!#$%&()*+,-./")] [TestCase(":;<=>?@")] [TestCase("[]^_`")] [TestCase("{|}~")] [TestCase("!")] [TestCase("Een locatie 1!")] public void GivenCorrectIdWhenValidatingThenSucceeds(string id) { // Given Correct Id When Validating bool isOk = IdValidator.IsCorrectName(id); // Then Succeeds Assert.That(isOk, Is.True); } [TestCase("location_12_2_1D1")] // Between "location_12" and "_2_1D1" there are 2 illegal characters (1F hex) [TestCase("The last character is incorrectÀ")] [TestCase("A character ¡ in the middle is incorrect")] [TestCase("ÀThe first character is incorrect")] public void GivenInCorrectIdWhenValidatingThenFails(string id) { // Given Inorrect Id When Validating bool isOk = IdValidator.IsCorrectName(id); // Then Fails Assert.That(isOk, Is.False); } }