// 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.CodeDom.Compiler; using System.Collections.Generic; using System.Linq; using Deltares.Dam.Data; using Deltares.Dam.Data.DataPlugins; using Deltares.Dam.Data.DataPlugins.Configuration; using Deltares.Dam.Data.Properties; using Deltares.Standard.Language; using Deltares.Standard.TestUtils; using NUnit.Framework; namespace Deltares.Dam.Tests { [TestFixture] public class DataPluginImporterTests { const string directoryWithCsvFiles = @"..\..\..\data\Dam\Waterboards\Groot Salland\Binnenwaarts\"; [Test] public void CanDefineDataSources() { var srcDataSources = new List(); var dataPluginImporter = new DataPluginImporter(); srcDataSources.Add(new DataSource { DataSourceType = DataSourceType.CsvFiles, DataLocation = directoryWithCsvFiles }); dataPluginImporter.SetDataSources("", srcDataSources); //var destDataSources = dataPluginImporter.DataSources.ToList(); var destDataSources = dataPluginImporter.DataSources.ToList(); Assert.AreEqual(srcDataSources.Count, destDataSources.Count()); Assert.IsTrue(srcDataSources[0].Equals(destDataSources.FirstOrDefault())); } [Test] [ExpectedException(typeof(DataPluginImporterException))] public void ThrowsExceptionWhenRequestingDataWhenDataSourcesNotDefined() { var dataPluginImporter = new DataPluginImporter(); var info = dataPluginImporter.WaterBoardInfo; Assert.IsNotNull(info); } [Test] [Category(Categories.Slow)] public void CanRetrieveWaterboardInfo() { var srcDataSources = new List { new DataSource { DataSourceType = DataSourceType.CsvFiles, DataLocation = directoryWithCsvFiles } }; var dataPluginImporter = new DataPluginImporter(); dataPluginImporter.SetDataSources("", srcDataSources); dataPluginImporter.ImportDataForDikeRings(null, DamType.Primary, null); var info = dataPluginImporter.WaterBoardInfo; if (LocalizationManager.CurrentLanguage == LanguageType.Dutch) { Assert.AreEqual("Waterschap", info.Name); } else { Assert.AreEqual("WaterBoard", info.Name); } Assert.AreEqual("Waterschap", info.Description); } } }