// 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.IO; using Deltares.Dam.Data.DataPlugins.Configuration; using Deltares.Geotechnics; using Deltares.Geotechnics.Soils; using Deltares.Standard; using Deltares.Standard.Logging; namespace Deltares.Dam.Tests { using System; using System.Collections.Generic; using System.Linq; using System.Text; using Deltares.Dam.Data; using NUnit.Framework; internal class DikeRingInfo { public string DefinitionFilename = ""; public string ProjectFilename = ""; public int LocationCount = 0; } [TestFixture] public class WaterBoardImporterTest { private const string rootPath = @"..\..\..\data\Dam\Waterboards\HHNK All\"; private const double cToleranceCoordinates = 0.01; private const double cToleranceValues = 0.0001; private const string dikeRingId_Hempolder = "TPL_Hempolder"; private const string dikeRingId_HD_Bernisse = "HD_Bernisse"; private const string dikeRingId_TPL_BALGZANDKANAAL = "TPL_BALGZANDKANAAL"; [Test] public void CanImportDikeRingsOfHHNK() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\HHNK.defx"; DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damProjectFolder = Path.GetDirectoryName(definitionFilename); List importLogMessages; List dikeRingIds = WaterBoardImporter.ImportDikeRingIds(damProjectFolder, dataSourceContainer, DamType.Regional, DamProjectType.Assessment, out importLogMessages).ToList(); Assert.AreEqual(50, dikeRingIds.Count); //List selectedDikeIds = new List(); //selectedDikeIds.Add(dikeRingIds[0]); //selectedDikeIds.Add(dikeRingIds[1]); //WaterBoard waterBoard = waterBoardImporter.ImportDataForDikeRings(damProjectFolder, dataSourceContainer, // selectedDikeIds, DamType.Primary, null); } [Test] [Ignore("Under construction")] public void CanImportDeltaDijkSmallIntoProject() { const string definitionFilename = @"..\..\..\data\Dam\Deltadijk\Deltadijk small.defx"; using (var damProject = new DamProject()) { DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damProjectFolder = Path.GetDirectoryName(definitionFilename); // var dikeRingIds = waterBoardImporter.ImportDikeRingIds(damProjectFolder, dataSourceContainer); var selectedDikeRingIds = new List() { dikeRingId_HD_Bernisse }; damProject.Import(damProjectFolder, dataSourceContainer, selectedDikeRingIds, DamType.Primary, DamProjectType.Calamity, null); Assert.AreEqual(1, damProject.DamProjectData.WaterBoard.Dikes.Count); Assert.AreEqual(dikeRingId_HD_Bernisse, damProject.DamProjectData.WaterBoard.Dikes[0].Name); Assert.AreEqual(43, damProject.DamProjectData.WaterBoard.Dikes[0].Locations.Count); CheckWaterBoardData(damProject.DamProjectData.WaterBoard); } } [Test] [Ignore("Failing test; to be investigated")] public void CanImportHollandseDeltaSingleDikeRingIntoProject() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HD\Bernisse\HD.defx"; using (var damProject = new DamProject()) { DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damProjectFolder = Path.GetDirectoryName(definitionFilename); // var dikeRingIds = waterBoardImporter.ImportDikeRingIds(damProjectFolder, dataSourceContainer); var selectedDikeRingIds = new List() { dikeRingId_HD_Bernisse }; damProject.Import(damProjectFolder, dataSourceContainer, selectedDikeRingIds, DamType.Primary, DamProjectType.Calamity, null); Assert.AreEqual(1, damProject.DamProjectData.WaterBoard.Dikes.Count); Assert.AreEqual(dikeRingId_HD_Bernisse, damProject.DamProjectData.WaterBoard.Dikes[0].Name); Assert.AreEqual(43, damProject.DamProjectData.WaterBoard.Dikes[0].Locations.Count); CheckWaterBoardData(damProject.DamProjectData.WaterBoard); } } [Test] [Ignore("Takes 59 minutes on buildserver")] public void CanImportHHNKSingleDikeRingIntoProject() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\HHNK.defx"; using (var damProject = new DamProject()) { DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damProjectFolder = Path.GetDirectoryName(definitionFilename); // var dikeRingIds = waterBoardImporter.ImportDikeRingIds(damProjectFolder, dataSourceContainer); var selectedDikeRingIds = new List() { dikeRingId_Hempolder }; damProject.Import(damProjectFolder, dataSourceContainer, selectedDikeRingIds, DamType.Primary, DamProjectType.Calamity, null); Assert.AreEqual(1, damProject.DamProjectData.WaterBoard.Dikes.Count); Assert.AreEqual(dikeRingId_Hempolder, damProject.DamProjectData.WaterBoard.Dikes[0].Name); Assert.AreEqual(43, damProject.DamProjectData.WaterBoard.Dikes[0].Locations.Count); CheckWaterBoardData(damProject.DamProjectData.WaterBoard); } } [Test] [Ignore("For now only the dikering in the csv file will be read; so dikelist count will allways be 1")] public void CanImportHHNKDikeRingListWithWaterBoardImporter() { const string definitionFilenameHemPolder = @"..\..\..\data\Dam\Waterboards\HHNK All\TPL_Hempolder\HHNK.defx"; const string definitionFilenameBalgzandKanaal = @"..\..\..\data\Dam\Waterboards\HHNK All\TPL_BALGZANDKANAAL\HHNK.defx"; //const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\HHNK.defx"; const string projectFilename = @"..\..\..\data\Dam\Waterboards\HHNK\HHNK"; using (var damProject = new DamProject { DamProjectData = { WaterBoard = new WaterBoard(), DamProjectType = DamProjectType.Assessment } }) { //IList dikeList = // waterBoardImporter.ImportDikeRingIds(damProjectFolder, dataSourceContainer).ToList(); // Assert.AreEqual(50, dikeList.Count); var selectedDikeIds = new List { dikeRingId_Hempolder }; DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilenameHemPolder); string damImportFolder = Path.GetDirectoryName(definitionFilenameHemPolder); string damProjectFolder = Path.GetDirectoryName(damProject.ProjectFileName); using (WaterBoard waterBoard = WaterBoardImporter.ImportDataForDikeRings(damProjectFolder, damImportFolder, dataSourceContainer, selectedDikeIds, DamType.Primary, DamProjectType.Calamity, null)) { damProject.DamProjectData.WaterBoard.Dikes.Add(waterBoard.Dikes[0]); selectedDikeIds = new List() { dikeRingId_TPL_BALGZANDKANAAL }; dataSourceContainer = DataSourceContainer.Deserialize(definitionFilenameBalgzandKanaal); damImportFolder = Path.GetDirectoryName(definitionFilenameBalgzandKanaal); } using (WaterBoard waterBoard = WaterBoardImporter.ImportDataForDikeRings(damProjectFolder, damImportFolder, dataSourceContainer, selectedDikeIds, DamType.Primary, DamProjectType.Calamity, null)) { damProject.DamProjectData.WaterBoard.Dikes.Add(waterBoard.Dikes[0]); damProject.SaveXMLProject(projectFilename, null); Assert.AreEqual(2, waterBoard.Dikes.Count); Assert.AreEqual(dikeRingId_Hempolder, waterBoard.Dikes[0].Name); Assert.AreEqual(dikeRingId_TPL_BALGZANDKANAAL, waterBoard.Dikes[1].Name); Assert.AreEqual(43, waterBoard.Dikes[0].Locations.Count); Assert.AreEqual(107, waterBoard.Dikes[1].Locations.Count); CheckWaterBoardData(waterBoard); } } } [Test] [Category("Integration")] [Ignore("Takes 36 minutes on buildserver")] public void CanImportHHNKDikeRingListWithDampingFactor() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\dampingfactortest.defx"; DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damImportFolder = Path.GetDirectoryName(definitionFilename); List importLogMessages; IList dikeList = WaterBoardImporter.ImportDikeRingIds(damImportFolder, dataSourceContainer, DamType.Regional, DamProjectType.Assessment, out importLogMessages).ToList(); var selectedDikeIds = new List() {dikeRingId_Hempolder, dikeRingId_TPL_BALGZANDKANAAL}; using (WaterBoard waterBoard = WaterBoardImporter.ImportDataForDikeRings("", damImportFolder, dataSourceContainer, selectedDikeIds, DamType.Regional, DamProjectType.Assessment, null)) { Location location = waterBoard.Dikes[0].Locations.FirstOrDefault(t => t.Name == "TPL_Hempolder_0010"); Assert.AreEqual(0, location.DampingFactorPL3, cToleranceCoordinates); } } [Test] [Category("Integration")] [Ignore("Takes 36 minutes on buildserver")] public void CanImportHHNKDikeRingListWithTrafficLoad() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\trafficloadtest.defx"; DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damImportFolder = Path.GetDirectoryName(definitionFilename); List importLogMessages; IList dikeList = WaterBoardImporter.ImportDikeRingIds(damImportFolder, dataSourceContainer, DamType.Regional, DamProjectType.Assessment, out importLogMessages).ToList(); var selectedDikeIds = new List() {dikeRingId_Hempolder, dikeRingId_TPL_BALGZANDKANAAL}; using (WaterBoard waterBoard = WaterBoardImporter.ImportDataForDikeRings("", damImportFolder, dataSourceContainer, selectedDikeIds, DamType.Regional, DamProjectType.Assessment, null)) { Location location = waterBoard.Dikes[0].Locations.FirstOrDefault(t => t.Name == "TPL_Hempolder_0010"); Assert.AreEqual(5, location.TrafficLoad, cToleranceCoordinates); } } [Test] [Category("Integration")] [Ignore("Takes 46 minutes on buildserver")] public void CanImportHHNKDikeRingListWithHeadPL3() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\headpl3test.defx"; DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damImportFolder = Path.GetDirectoryName(definitionFilename); List importLogMessages; IList dikeList = WaterBoardImporter.ImportDikeRingIds(damImportFolder, dataSourceContainer, DamType.Regional, DamProjectType.Assessment, out importLogMessages).ToList(); var selectedDikeIds = new List() {dikeRingId_Hempolder, dikeRingId_TPL_BALGZANDKANAAL}; using (WaterBoard waterBoard = WaterBoardImporter.ImportDataForDikeRings("", damImportFolder, dataSourceContainer, selectedDikeIds, DamType.Regional, DamProjectType.Assessment, null)) { Location location = waterBoard.Dikes[0].Locations.FirstOrDefault(t => t.Name == "TPL_Hempolder_0070"); Assert.AreEqual(-1.50, location.HeadPl3.HasValue ? location.HeadPl3.Value : double.MinValue, cToleranceCoordinates); } } private void CheckWaterBoardData(WaterBoard waterBoard) { // Check for TLP_Hempolder_0010 and TLP_Hempolder_0170 // These values were visually determined by importing the shapefiles in Quantum GIS // and looking up the values for this location Location location = waterBoard.Dikes[0].Locations.FirstOrDefault(t => t.Name == "TPL_Hempolder_0010"); Assert.AreEqual(110637.4088, location.XRd, cToleranceCoordinates); Assert.AreEqual(506907.4483, location.YRd, cToleranceCoordinates); Assert.AreEqual("235", location.SegmentId); Assert.AreEqual(-1.4, location.PolderLevel, cToleranceValues); Assert.AreEqual(-1.4, location.PolderLevelLow, cToleranceValues); Assert.AreEqual(-1.3, location.HeadPl3.Value, cToleranceValues); Assert.AreEqual(SoilType.Clay, location.DikeMaterialType); Assert.AreEqual(0.0, location.DampingFactorPL3, cToleranceValues); Assert.AreEqual(0.0, location.DampingFactorPL4, cToleranceValues); Assert.AreEqual(8.6, location.SheetPileLength, cToleranceValues); Assert.AreEqual(-9.1, location.RwBankProtectionBottomLevel, cToleranceValues); Assert.AreEqual(0.0, location.PenetrationLength, cToleranceValues); Assert.AreEqual(5.0, location.TrafficLoad, cToleranceValues); Assert.AreEqual(PLLineCreationMethod.ExpertKnowledgeRRD, location.PLLineCreationMethod); Assert.AreEqual(0.0, location.PlLineOffsetBelowDikeTopAtRiver, cToleranceValues); Assert.AreEqual(0.0, location.PlLineOffsetBelowDikeTopAtPolder, cToleranceValues); Assert.AreEqual(0.25, location.PlLineOffsetBelowShoulderBaseInside, cToleranceValues); Assert.AreEqual(0.0, location.PlLineOffsetBelowDikeToeAtPolder, cToleranceValues); Assert.AreEqual(1.5, location.PLLineOffsetDryBelowDikeTopAtRiver, cToleranceValues); Assert.AreEqual(1.5, location.PLLineOffsetDryBelowDikeTopAtPolder, cToleranceValues); Assert.AreEqual(1.5, location.PLLineOffsetDryBelowShoulderBaseInside, cToleranceValues); Assert.AreEqual(0.0, location.PLLineOffsetDryBelowDikeToeAtPolder, cToleranceValues); Assert.AreEqual(-4.8, location.DredgingDepth, cToleranceValues); Assert.AreEqual(0.0, location.BoezemLevelTp, cToleranceValues); Assert.AreEqual(-0.5, location.BoezemLevelHbp, cToleranceValues); Assert.AreEqual(-0.3, location.BoezemLevelLbp, cToleranceValues); Assert.AreEqual(1.5, location.MinimalCircleDepth, cToleranceValues); Assert.AreEqual(1.2, location.ModelFactors.RequiredSafetyFactorPiping.Value, cToleranceValues); Assert.AreEqual(1.2, location.ModelFactors.UpliftCriterionPiping.Value, cToleranceValues); Assert.AreEqual(1.2, location.ModelFactors.UpliftCriterionStability.Value, cToleranceValues); location = waterBoard.Dikes[0].Locations.FirstOrDefault(t => t.Name == "TPL_Hempolder_0170"); Assert.AreEqual(111789.1695, location.XRd, cToleranceCoordinates); Assert.AreEqual(507499.3175, location.YRd, cToleranceCoordinates); Assert.AreEqual("234", location.SegmentId); Assert.AreEqual(-1.3, location.PolderLevel, cToleranceValues); Assert.AreEqual(-1.4, location.PolderLevelLow, cToleranceValues); Assert.AreEqual(-1.9, location.HeadPl3.Value, cToleranceValues); Assert.AreEqual(5.0, location.TrafficLoad, cToleranceValues); } /// /// Read Delfland data /// [Test] public void CanImportDelfland() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\Delfland\Delfland.defx"; using (var damProject = new DamProject()) { damProject.ImportWithDefinitionFile(definitionFilename, DamType.Regional, DamProjectType.Assessment, null); Assert.AreEqual(1, damProject.DamProjectData.WaterBoard.Dikes.Count); Assert.AreEqual(9, damProject.DamProjectData.WaterBoard.Dikes[0].Locations.Count); } } /// /// Create list of all dikerings of HHNK /// /// private List CreateHhnkDikeRinglist() { var dikeRingInfoList = new List(); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 89, ProjectFilename = "TPL_BALGZANDKANAAL", DefinitionFilename = @"TPL_BALGZANDKANAAL\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 6, ProjectFilename = "TPL_BEEMSTER_BU", DefinitionFilename = @"TPL_BEEMSTER_BU\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 19, ProjectFilename = "TPL_BERKMEER_ZUID", DefinitionFilename = @"TPL_BERKMEER_ZUID\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 3, ProjectFilename = "TPL_BLIJKMEER", DefinitionFilename = @"TPL_BLIJKMEER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 5, ProjectFilename = "TPL_BOEZEM_ALKMAAR", DefinitionFilename = @"TPL_BOEZEM_ALKMAAR\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 70, ProjectFilename = "TPL_BOEZEM_DH", DefinitionFilename = @"TPL_BOEZEM_DH\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 33, ProjectFilename = "TPL_BROEKERMEER", DefinitionFilename = @"TPL_BROEKERMEER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 46, ProjectFilename = "TPL_Buikslotermeer", DefinitionFilename = @"TPL_Buikslotermeer\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 5, ProjectFilename = "TPL_BURKMEER", DefinitionFilename = @"TPL_BURKMEER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 38, ProjectFilename = "TPL_DRIKHORN", DefinitionFilename = @"TPL_DRIKHORN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 43, ProjectFilename = "TPL_Hempolder", DefinitionFilename = @"TPL_Hempolder\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 2, ProjectFilename = "TPL_HV_04090_BU", DefinitionFilename = @"TPL_HV_04090_BU\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 1, ProjectFilename = "TPL_Karspel_BR", DefinitionFilename = @"TPL_Karspel_BR\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 237, ProjectFilename = "TPL_K_O_K_N", DefinitionFilename = @"TPL_K_O_K_N\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 186, ProjectFilename = "TPL_LRHHW", DefinitionFilename = @"TPL_LRHHW\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 96, ProjectFilename = "TPL_LRHHW2", DefinitionFilename = @"TPL_LRHHW2\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 136, ProjectFilename = "TPL_M_H", DefinitionFilename = @"TPL_M_H\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 27, ProjectFilename = "TPL_MONNIKENMEER", DefinitionFilename = @"TPL_MONNIKENMEER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 56, ProjectFilename = "TPL_NAUERNASCHE_VAART_Z", DefinitionFilename = @"TPL_NAUERNASCHE_VAART_Z\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 215, ProjectFilename = "TPL_NHK_AFTAKKINGEN_NO", DefinitionFilename = @"TPL_NHK_AFTAKKINGEN_NO\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 113, ProjectFilename = "TPL_NHK_AFTAKKINGEN_NW_A", DefinitionFilename = @"TPL_NHK_AFTAKKINGEN_NW_A \HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 64, ProjectFilename = "TPL_NHK_AFTAKKINGEN_NW_B", DefinitionFilename = @"TPL_NHK_AFTAKKINGEN_NW_B\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 127, ProjectFilename = "TPL_NHK_AFTAKKINGEN_ZO", DefinitionFilename = @"TPL_NHK_AFTAKKINGEN_ZO\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 28, ProjectFilename = "TPL_NHK_AFTAKKINGEN_ZW", DefinitionFilename = @"TPL_NHK_AFTAKKINGEN_ZW\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 54, ProjectFilename = "TPL_NHK_TZAND_DH_L", DefinitionFilename = @"TPL_NHK_TZAND_DH_L\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 73, ProjectFilename = "TPL_NHK_TZAND_DHR_R", DefinitionFilename = @"TPL_NHK_TZAND_DHR_R\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 229, ProjectFilename = "TPL_NHK_TZAND_ZIJPERSLUIS", DefinitionFilename = @"TPL_NHK_TZAND_ZIJPERSLUIS\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 29, ProjectFilename = "TPL_NOORMEER", DefinitionFilename = @"TPL_NOORMEER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 57, ProjectFilename = "TPL_OUDE_VEER", DefinitionFilename = @"TPL_OUDE_VEER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 27, ProjectFilename = "TPL_OUDORPERPOLDER", DefinitionFilename = @"TPL_OUDORPERPOLDER\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 124, ProjectFilename = "TPL_PURMERRINGVAART_BU", DefinitionFilename = @"TPL_PURMERRINGVAART_BU\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 101, ProjectFilename = "TPL_SBN_E_B", DefinitionFilename = @"TPL_SBN_E_B\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 221, ProjectFilename = "TPL_SCHAGEN_KOLHORN", DefinitionFilename = @"TPL_SCHAGEN_KOLHORN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 30, ProjectFilename = "TPL_SCHERMER_BUITEN", DefinitionFilename = @"TPL_SCHERMER_BUITEN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 30, ProjectFilename = "TPL_SCHERMER_BUITENRING", DefinitionFilename = @"TPL_SCHERMER_BUITENRING\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 69, ProjectFilename = "TPL_STARNMEER_BINNEN", DefinitionFilename = @"TPL_STARNMEER_BINNEN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 29, ProjectFilename = "TPL_STARNMEER_BUITEN", DefinitionFilename = @"TPL_STARNMEER_BUITEN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 90, ProjectFilename = "TPL_TTWISKE", DefinitionFilename = @"TPL_TTWISKE\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 47, ProjectFilename = "TPL_VOORL_W", DefinitionFilename = @"TPL_VOORL_W\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 168, ProjectFilename = "TPL_WAARD_GROETKANAAL", DefinitionFilename = @"TPL_WAARD_GROETKANAAL\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 59, ProjectFilename = "TPL_WESTZ_NAUERN", DefinitionFilename = @"TPL_WESTZ_NAUERN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 38, ProjectFilename = "TPL_W_L_", DefinitionFilename = @"TPL_W_L_\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 9, ProjectFilename = "TPL_ZAAN", DefinitionFilename = @"TPL_ZAAN\HHNK.defx" }); dikeRingInfoList.Add(new DikeRingInfo { LocationCount = 181, ProjectFilename = "TPL_NHK_ZIJPERSLUIS_ALKMAAR", DefinitionFilename = @"TPL_NHK_ZIJPERSLUIS_ALKMAAR\HHNK.defx" }); return dikeRingInfoList; } [Test] [Ignore("Not a test, but just to import dikerings HHNK")] public void CanImportAllHhnkDikerings() { List dikeRingInfoList = CreateHhnkDikeRinglist(); var messages = new List(); foreach (DikeRingInfo dikeRingInfo in dikeRingInfoList) { using (var damProject = new DamProject()) { string defintionFilename = Path.Combine(rootPath, dikeRingInfo.DefinitionFilename); string projectFilename = Path.Combine(rootPath, dikeRingInfo.ProjectFilename); DateTime startTime = DateTime.Now; try { damProject.ImportWithDefinitionFile(defintionFilename, DamType.Regional, DamProjectType.Assessment, null); damProject.DamProjectData.DamProjectType = DamProjectType.Assessment; damProject.SaveXMLProject(projectFilename, null); DateTime endTime = DateTime.Now; TimeSpan timeSpan = endTime - startTime; messages.Add(String.Format("Imported '{0}': location count = {1}, time = {2}", dikeRingInfo.ProjectFilename, damProject.DamProjectData.WaterBoard.Dikes[0].Locations.Count, timeSpan)); Assert.AreEqual(1, damProject.DamProjectData.WaterBoard.Dikes.Count); Assert.AreEqual(dikeRingInfo.LocationCount, damProject.DamProjectData.WaterBoard.Dikes[0].Locations.Count); } catch (Exception e) { messages.Add(String.Format("Error importing '{0}': {1}", dikeRingInfo.ProjectFilename, e.Message)); } string messagesFilename = Path.Combine(rootPath, "Import.log"); File.WriteAllLines(messagesFilename, messages.ToArray()); } } } [Test] [Category("Integration")] [Ignore("Takes more than 17 minutes on buildserver")] public void CanImportHHNKDikeRingListWithScenarios() { const string definitionFilename = @"..\..\..\data\Dam\Waterboards\HHNK\scenariostest.defx"; DataSourceContainer dataSourceContainer = DataSourceContainer.Deserialize(definitionFilename); string damImportFolder = Path.GetDirectoryName(definitionFilename); List importLogMessages; IList dikeList = WaterBoardImporter.ImportDikeRingIds(damImportFolder, dataSourceContainer, DamType.Regional, DamProjectType.Assessment, out importLogMessages).ToList(); var selectedDikeIds = new List() { dikeRingId_Hempolder, dikeRingId_TPL_BALGZANDKANAAL }; using (WaterBoard waterBoard = WaterBoardImporter.ImportDataForDikeRings("", damImportFolder, dataSourceContainer, selectedDikeIds, DamType.Regional, DamProjectType.Assessment, null)) { Location location = waterBoard.Dikes[0].Locations.FirstOrDefault(t => t.Name == "TPL_Hempolder_0070"); Assert.AreEqual(10, location.Scenarios.Count); var scenario = location.Scenarios.FirstOrDefault(n => n.LocationScenarioID.Equals("2")); Assert.AreEqual(1.09, scenario.RiverLevel, cToleranceValues); Assert.AreEqual(2.46, scenario.DikeTableHeight.Value, cToleranceValues); Assert.AreEqual(1.19, scenario.ModelFactors.RequiredSafetyFactorStabilityInnerSlope.Value, cToleranceValues); Assert.AreEqual(0.4, scenario.WaterHeightDecimeringsHoogte.Value, cToleranceValues); Assert.AreEqual(4.0, scenario.MaxWaterLevel.Value, cToleranceValues); Assert.AreEqual(0.001, scenario.ModelFactors.RequiredProbabilityOfFailureStabilityInnerslope.Value, cToleranceValues); Assert.AreEqual(0.001, scenario.ModelFactors.RequiredProbabilityOfFailurePiping.Value, cToleranceValues); } } } }