// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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.Linq; using Deltares.Dam.Data.Sensors; using Deltares.Standard.Extensions; using NUnit.Framework; namespace Deltares.Dam.Tests.Sensors { [TestFixture] public class GroupTest { /// /// This test was setup because the xml serializer had an issue with lists of enum types /// At the same time it is also good to test if all the required properties get the same value /// after deserializing the object state /// [Test] public void Deserialization_ValidXmlString_ShouldResturnValidGroupWithoutException() { // setup var sensor1 = new Sensor { Name = "Sensor1", ID = 1 }; var sensor2 = new Sensor { Name = "Sensor2", ID = 2 }; var group1 = new Group { ID = 1, SensorArray = new[] { sensor1, sensor2 } // SensorRelativeLocationsArray = new[] // { // new KeyValuePair(sensor1.ID, 10), // new KeyValuePair(sensor2.ID, 20), // }, }; // call string xml = group1.Serialize(); Group group2 = Group.Deserialize(xml); // assert Assert.That(group2.ID, Is.EqualTo(group1.ID)); //Assert.AreEqual(group2.Selection.Count(), group2.SensorRelativeLocations.Count()); foreach (Sensor sensor in group1.Selection) { Assert.That(group2.Selection.Any(s => s.Name == sensor.Name && s.ID == sensor.ID && s.Depth.AlmostEquals(sensor.Depth)), Is.True); //Assert.IsTrue(group2.SensorRelativeLocations.Any(s => s.Key == sensor)); } } #region Setup [SetUp] public void FixtureSetup() {} [TearDown] public void FixtureTearDown() {} [SetUp] public void TestSetup() {} [TearDown] public void TestTearDown() {} #endregion } }