// Copyright (C) Stichting Deltares 2018. 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 Deltares.Dam.TestHelper; using Deltares.Standard.Extensions; namespace Deltares.Dam.Tests { using NUnit.Framework; using Deltares.Dam.Data; [TestFixture] public class WaterBoardJobImporterTest { private IList disposables; [SetUp] public void SetUp() { disposables = new List(); } [TearDown] public void TearDown() { foreach (var disposable in disposables) { disposable.Dispose(); } disposables = null; } [Test] public void IsTimeSeriesNotImportedIntoLocationWhenNoMatchingId() { // Create waterBoardJob with location without waterlevels WaterBoardJob waterBoardJob = FactoryForWaterBoard.CreateWaterBoardJobWithOneLocationWithoutWaterLevelTimeSeries(); disposables.AddRange(FactoryForWaterBoard.GetDisposableObjectsFromWaterBoardJob(waterBoardJob)); // Assign other name to location to prevent timeserie assignment ((LocationJob) ((DikeJob) waterBoardJob.Jobs[0]).Jobs[0]).Location.Name = "Othername"; TimeSerieCollection timeSerieCollection = FactoryForWaterBoard.CreateTimeSerieCollectionWithOneLocation(); // Check if waterlevels assigned WaterBoardJobImporter.ImportWaterlevels(waterBoardJob, timeSerieCollection); Assert.IsFalse(waterBoardJob.AreAllDikeLocationsWaterLevelTimeSeriesAssigned(), "Check if waterlevels assigned"); } [Test] public void AreTimeSeriesImportedIntoLocations() { // Create waterBoardJob with location without waterlevels WaterBoardJob waterBoardJob = FactoryForWaterBoard.CreateWaterBoardJobWithOneLocationWithoutWaterLevelTimeSeries(); disposables.AddRange(FactoryForWaterBoard.GetDisposableObjectsFromWaterBoardJob(waterBoardJob)); TimeSerieCollection timeSerieCollection = FactoryForWaterBoard.CreateTimeSerieCollectionWithOneLocation(); // Check if waterlevels assigned WaterBoardJobImporter.ImportWaterlevels(waterBoardJob, timeSerieCollection); Assert.IsTrue(waterBoardJob.AreAllDikeLocationsWaterLevelTimeSeriesAssigned(), "Check if waterlevels assigned"); } } }