// 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 Deltares.DamEngine.Data.Geometry; using NUnit.Framework; namespace Deltares.DamEngine.Data.Tests.Geometry; public class GeometryObjectTests { [Test] public void GetGeometryBounds_Always_ReturnNull() { // setup var geometry = new GeometryObjectTestExerciser(); // call var returnedBounds = geometry.GetGeometryBounds(); // assert Assert.That(returnedBounds, Is.Null); } [Test] [TestCase(null)] [TestCase("hihi")] public void Name_SetToEmptyString_NameNotChanged(string newName) { // setup var geometry = new GeometryObjectTestExerciser(); geometry.SetName("haha"); // call geometry.Name = newName; // assert if (newName == null) Assert.That("haha".Equals(geometry.Name)); else Assert.That(newName.Equals(geometry.Name)); } [Test] [TestCase(null)] [TestCase("")] [TestCase("haha")] public void SetName_AnyValue_NameIsSet(string expectedName) { // setup var geometry = new GeometryObjectTestExerciser(); // call geometry.SetName(expectedName); // assert if (expectedName == null) Assert.That(geometry.Name == null); else Assert.That(expectedName.Equals(geometry.Name)); } [Test] [TestCase(0.0000455454, 0.000)] [TestCase(0.004455454, 0.004)] [TestCase(0.004555454, 0.005)] public void TestRoundValue(double value, double expectedValue) { // setup var geometry = new GeometryObjectTestExerciser(); // call double resultValue = geometry.RoundValue(value); // assert Assert.That(resultValue, Is.EqualTo(expectedValue)); } private class GeometryObjectTestExerciser : GeometryObject {} }