// 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; using System.Collections.Generic; using System.Linq; using Deltares.Dam.Data; namespace Deltares.Dam.TestHelper { public static class FactoryForWaterBoard { public const string cLocation01Id = "Lcoation01"; /// /// Create waterlevel timeseries /// /// public static TimeSerieCollection CreateTimeSerieCollectionWithOneLocation() { var timeSerieCollection = new TimeSerieCollection(); var waterLevelTimeSerie = new TimeSerie(); waterLevelTimeSerie.LocationId = cLocation01Id; waterLevelTimeSerie.ParameterId = "Waterlevel"; waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 1), 5)); waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 2), 6)); waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 3), 4)); waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 4), 7)); waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 5), 5)); timeSerieCollection.Series.Add(waterLevelTimeSerie); return timeSerieCollection; } /// /// Create waterboard job /// /// public static WaterBoardJob CreateWaterBoardJobWithOneLocationWithoutWaterLevelTimeSeries() { var dike = new Dike(); var location = new Location(); location.Name = cLocation01Id; dike.Locations.Add(location); var waterBoardJob = new WaterBoardJob(null); var dikeJob = new DikeJob(dike); waterBoardJob.Jobs.Add(dikeJob); var locationJob = new LocationJob(location); dikeJob.Jobs.Add(locationJob); // Make sure waterlevel timeseries are not assigned foreach (DamJob damJob in dikeJob.Jobs) { if (damJob.GetType() == typeof(LocationJob)) { ((LocationJob) damJob).WaterLevelTimeSerie = null; } } return waterBoardJob; } /// /// Gets the disposable objects from water board job constructed with . /// /// The water board job created with . /// public static IEnumerable GetDisposableObjectsFromWaterBoardJob(WaterBoardJob waterBoardJob) { foreach (DikeJob dikejob in waterBoardJob.Jobs.Cast()) { if (dikejob.Subject != null) { yield return (Dike) dikejob.Subject; } } } } }