// 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 System.IO;
using System.Linq;
using Deltares.Dam.Data;
using Deltares.Dam.TestHelper;
using Deltares.Geometry;
using Deltares.Geotechnics.GeotechnicalGeometry;
using Deltares.Geotechnics.Soils;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Standard.TestUtils;
using KellermanSoftware.CompareNetObjects;
using NUnit.Framework;
using Segment = Deltares.Dam.Data.Segment;
namespace Deltares.Dam.Tests
{
///
/// In this test the XML serialization is tested.
/// - Can old projects be loaded; A test should be included for each release of the software
/// - Can the project be saved and loaded with the current version of the source
///
[TestFixture]
public class LoadCompatiblityTest
{
CompareLogic compare;
///
/// Code that is run before each test
///
[SetUp]
public void Initialize()
{
compare = new CompareLogic();
compare.Config.MaxDifferences = 100;
compare.Config.CompareChildren = false;
compare.Config.MembersToIgnore = new List
{
"SheetPilePoint",
"SheetPilePointX",
"SheetPilePointY",
"SheetPilePointZ",
"LocalXZSheetPilePoint",
"SoilbaseDB",
"SurfaceLine",
"LocalXZSurfaceLine",
"SoilLayer1D",
"SoildatabaseName",
"SoilList",
"MapForSoilGeometries2D"
};
}
///
/// Create expected location for "TPL_Hempolder_0100"
///
///
private Location CreateHhnkTplHempolder100()
{
Location location = new Location
{
AreLocalXZObjectsCreated = true,
DamType = DamType.Regional,
Name = "TPL_Hempolder_0100",
DikeRingId = "TPL_Hempolder",
Description = "",
XRd = 111232.178664511,
YRd = 507197.06382921,
SegmentId = "234",
//SurfaceLineId = "",
//PL1LineId = "",
DredgingDepth = -1.59999995232,
PolderLevel = -1.29999995232,
PolderLevelLow = -1.39999997616,
HeadPL2 = -1.3,
HeadPl3 = -1.6,
HeadPl4 = null,
GrassQuality = 1.0,
Direction = 1.0,
XSoilGeometry2DOrigin = 0.0, // actual value
DikeMaterialType = SoilType.Clay,
DikeEmbankmentMaterial = "HHNK1_Bfg",
ShoulderEmbankmentMaterial = "HHNK1_Bfl",
DampingFactorPL3 = 0.0, // actual value
DampingFactorPL4 = 0.0, // actual value
SheetPilePointX = -151610.123065615,
SheetPilePointY = 0.0, // actual value
SheetPilePointZ = 0.0, // actual value
SheetPileLength = 2.19999990464,
RwBankProtectionBottomLevel = 0.0, // actual value
IsUseOriginalPLLineAssignments = false,
PenetrationLength = 0.0, // actual value
TrafficLoad = 5.0,
PLLineCreationMethod = PLLineCreationMethod.ExpertKnowledgeRRD,
PlLineOffsetBelowDikeTopAtRiver = 0.0, // actual value
PlLineOffsetBelowDikeTopAtPolder = 0.0, // actual value
PlLineOffsetBelowShoulderBaseInside = 0.25,
PlLineOffsetBelowDikeToeAtPolder = 0.0, // actual value
PLLineOffsetDryBelowDikeTopAtRiver = 1.5,
PLLineOffsetDryBelowDikeTopAtPolder = 1.5,
PLLineOffsetDryBelowShoulderBaseInside = 1.5,
PLLineOffsetDryBelowDikeToeAtPolder = 0.0, // actual value
StabilityShoulderGrowSlope = 0.333333333333333,
StabilityShoulderGrowDeltaX = 2.0,
StabilitySlopeAdaptionDeltaX = 2.0,
BoezemLevelTp = -0.15,
BoezemLevelHbp = -0.5,
BoezemLevelLbp = -0.3,
MinimalCircleDepth = 1.5,
LevelReductionInside = 0.5,
LevelReductionOutside = 0.6,
LayerHeightDistribution = 0.0,
LayerHeightDeviation = 0.0,
DistanceToEntryPoint = 0.0, // actual value
DetrimentFactor = 1.0,
StabilityZoneType = MStabZonesType.NoZones,
DikeTableHeight = 0.0,
SheetPilePoint = new GeometryPoint{X= -151610.123065615, Y= 0, Z =0},
LocalXZSheetPilePoint = new GeometryPoint { X = -151610.123065615, Y = 0, Z = 0 },
ModelFactors = new ModelFactors
{
RequiredProbabilityOfFailureStabilityInnerslope = 1.0e-08,
RequiredProbabilityOfFailureStabilityOuterslope = 1.0e-08,
UpliftCriterionPiping = 1.2,
UpliftCriterionStability = 1.2,
},
Segment = new Segment
{
Name = "234" ,
},
};
var soilProfile = new SoilProfile1D {Name = "Segment_234_1D1", BottomLevel = -29};
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_kade" }, 30) {IsAquifer = false} );
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfo" }, -1) { IsAquifer = false } );
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Ppp" }, -1.5) { IsAquifer = false } );
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfg" }, -4) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tcs" }, -5.5) { IsAquifer = true } );
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Bss" }, -24) { IsAquifer = true });
location.Segment.AddSoilProfileProbability(soilProfile, 0.0, FailureMechanismSystemType.StabilityInside);
location.Segment.SoilProfileProbabilities[0].Probability = 69.3;
soilProfile = new SoilProfile1D { Name = "Segment_234_1D2", BottomLevel = -29 };
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_kade" }, 30) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfo" }, -1) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Ppp" }, -1.5) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfg" }, -4) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tcc" }, -5.5) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tcs" }, -12.5) { IsAquifer = true });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Bss" }, -24) { IsAquifer = true });
location.Segment.AddSoilProfileProbability(soilProfile, 0.0, FailureMechanismSystemType.StabilityInside);
location.Segment.SoilProfileProbabilities[1].Probability = 0.7;
soilProfile = new SoilProfile1D { Name = "Segment_234_1D3", BottomLevel = -29 };
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_kade" }, 30) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfo" }, -1) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Ppp" }, -1.5) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfg" }, -4) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tcs" }, -7) { IsAquifer = true });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Bss" }, -24) { IsAquifer = true });
location.Segment.AddSoilProfileProbability(soilProfile, 0.0, FailureMechanismSystemType.StabilityInside);
location.Segment.SoilProfileProbabilities[2].Probability = 29.7;
soilProfile = new SoilProfile1D { Name = "Segment_234_1D4", BottomLevel = -29 };
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_kade" }, 30) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfo" }, -1) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Ppp" }, -1.5) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tfg" }, -4) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tcc" }, -7) { IsAquifer = false });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Tcs" }, -14) { IsAquifer = true });
soilProfile.Layers.Add(new SoilLayer1D(new Soil { Name = "HHNK1_Bss" }, -24) { IsAquifer = true });
location.Segment.AddSoilProfileProbability(soilProfile, 0.0, FailureMechanismSystemType.StabilityInside);
location.Segment.SoilProfileProbabilities[3].Probability = 0.3;
return location;
}
///
/// Compares the soil profiles.
///
/// The expected soilprofile1D.
/// The actual soilprofile1D.
void CompareSoilProfiles(SoilProfile1D expectedSoilProfile1D, SoilProfile1D actualSoilProfile1D)
{
int expectedLayerCount = expectedSoilProfile1D.Layers.Count;
int actualLayerCount = expectedSoilProfile1D.Layers.Count;
Assert.AreEqual(expectedLayerCount, actualLayerCount);
for (int layerIndex = 0; layerIndex < expectedLayerCount; layerIndex++)
{
Assert.AreEqual(expectedSoilProfile1D.Layers[layerIndex].Soil.Name, actualSoilProfile1D.Layers[layerIndex].Soil.Name, String.Format("Non-matching name in layer {0}", layerIndex));
Assert.AreEqual(expectedSoilProfile1D.Layers[layerIndex].IsAquifer, actualSoilProfile1D.Layers[layerIndex].IsAquifer, String.Format("Non-matching isAquifer in layer {0}", layerIndex));
}
}
[Test]
[Category("Integration")]
public void CanLoadVersion_1_3_3_1()
{
const string projectFilenameHhnk = @"..\..\..\data\Dam\Versions\V 1.3.3.1\HHNK\TPL_Hempolder.damx";
// HHNK (Hollands Noorderkwartier)
using (var projectData = ProjectLoader.LoadProjectData(projectFilenameHhnk))
{
// Check data
using (Location expectedLocation = CreateHhnkTplHempolder100())
{
expectedLocation.SoildatabaseName = @"..\..\..\data\Dam\Versions\V 1.3.3.1\HHNK\TPL_Hempolder0.soilmaterials.mdb";
Location actualLocation = projectData.Locations.Single(s => s.Name == "TPL_Hempolder_0100");
CompareSegments(expectedLocation, actualLocation);
var result = compare.Compare(expectedLocation, actualLocation);
Assert.AreEqual(0, result.Differences.Count, result.DifferencesString);
CheckHempolderSurfaceline(actualLocation);
// Check the surfaceline
// TODO Implement for Delfland
// TODO: Implement for HD (Hollandse Delta)
}
}
}
private static void CheckHempolderSurfaceline(Location actualLocation)
{
// quick check for surfaceline2 conversion
Assert.NotNull(actualLocation.SurfaceLine2);
Assert.AreEqual("TPL_Hempolder_0100", actualLocation.SurfaceLine2.Name);
Assert.AreEqual(true, actualLocation.SurfaceLine2.CharacteristicPoints.GeometryMustContainPoint);
Assert.AreEqual(true, actualLocation.SurfaceLine2.HasDike());
var dikeToeAtRiver = actualLocation.SurfaceLine2.CharacteristicPoints.FirstOrDefault(p => p.CharacteristicPointType == CharacteristicPointType.DikeToeAtRiver);
Assert.NotNull(dikeToeAtRiver);
Assert.AreEqual(111222.28, dikeToeAtRiver.X, GeometryConstants.Accuracy);
Assert.AreEqual(507206.24, dikeToeAtRiver.Y, GeometryConstants.Accuracy);
}
///
/// Compares the segments.
///
/// The expected location.
/// The actual location.
private void CompareSegments(Location expectedLocation, Location actualLocation)
{
for (int soilProfile1DIndex = 0;
soilProfile1DIndex < expectedLocation.Segment.SoilProfileProbabilities.Count;
soilProfile1DIndex++)
{
CompareSoilProfiles(expectedLocation.Segment.SoilProfileProbabilities[soilProfile1DIndex].SoilProfile,
actualLocation.Segment.SoilProfileProbabilities[soilProfile1DIndex].SoilProfile);
}
}
///
/// Determines whether version_1_5_1_7 can be loaded.
/// Check if the PL-line parameters are correcly copied from location to scenario; Projects before 15.1 do not have these parameters in scenarios
///
[Test]
[Category("Integration")]
public void CanLoadVersion_1_5_1_7_ScenariosPLLineParameters()
{
const double cTolerance = 0.001;
const string projectFilenameTutorialDesign = @"..\..\..\data\Dam\Versions\V 1.5.1.7\Tutorial Design\DAM Tutorial Design (Old 1.5.1.7).damx";
using (var projectData = ProjectLoader.LoadProjectData(projectFilenameTutorialDesign))
{
foreach (Location location in projectData.Locations)
{
foreach (Scenario scenario in location.Scenarios)
{
if (location.UsePlLineOffsetBelowDikeCrestMiddle != null)
{
Assert.AreEqual(location.UsePlLineOffsetBelowDikeCrestMiddle.Value, scenario.UsePlLineOffsetBelowDikeCrestMiddle.Value);
}
if (location.PlLineOffsetBelowDikeCrestMiddle != null)
{
Assert.AreEqual(location.PlLineOffsetBelowDikeCrestMiddle.Value, scenario.PlLineOffsetBelowDikeCrestMiddle.Value, cTolerance);
}
Assert.AreEqual(location.PlLineOffsetBelowDikeToeAtPolder, scenario.PlLineOffsetBelowDikeToeAtPolder, cTolerance);
Assert.AreEqual(location.PlLineOffsetBelowDikeTopAtPolder, scenario.PlLineOffsetBelowDikeTopAtPolder, cTolerance);
Assert.AreEqual(location.PlLineOffsetBelowDikeTopAtRiver, scenario.PlLineOffsetBelowDikeTopAtRiver, cTolerance);
Assert.AreEqual(location.PlLineOffsetBelowShoulderBaseInside, scenario.PlLineOffsetBelowShoulderBaseInside, cTolerance);
if (location.UsePlLineOffsetFactorBelowShoulderCrest != null)
{
Assert.AreEqual(location.UsePlLineOffsetFactorBelowShoulderCrest.Value, scenario.UsePlLineOffsetFactorBelowShoulderCrest.Value);
}
if (location.PlLineOffsetFactorBelowShoulderCrest != null)
{
Assert.AreEqual(location.PlLineOffsetFactorBelowShoulderCrest.Value, scenario.PlLineOffsetFactorBelowShoulderCrest.Value, cTolerance);
}
if (location.HeadPl3 != null)
{
Assert.AreEqual(location.HeadPl3.Value, scenario.HeadPl3.Value, cTolerance);
}
if (location.HeadPl4 != null)
{
Assert.AreEqual(location.HeadPl4.Value, scenario.HeadPl4.Value, cTolerance);
}
// surfaceline2 present with characteristic points ?
Assert.NotNull(location.SurfaceLine2);
Assert.AreEqual(location.Name, location.SurfaceLine2.Name);
Assert.AreEqual(true, location.SurfaceLine2.CharacteristicPoints.GeometryMustContainPoint);
Assert.AreEqual(true, location.SurfaceLine2.HasDike());
}
}
}
}
[Test]
[Category("Integration")]
public void CanLoadVersion_1_5_2_1()
{
const string fullProjectFilename = @"..\..\..\data\Dam\Versions\V 1.5.2.1\HHNK\TPL_Hempolder.damx";
// HHNK (Hollands Noorderkwartier)
using (var projectData = ProjectLoader.LoadProjectData(fullProjectFilename))
{
// Check data
using (Location expectedLocation = CreateHhnkTplHempolder100())
{
expectedLocation.SoildatabaseName = @"..\..\..\data\Dam\Versions\V 1.5.2.1\HHNK\TPL_Hempolder0.soilmaterials.mdb";
Location actualLocation = projectData.Locations.Single(s => s.Name == "TPL_Hempolder_0100");
CompareSegments(expectedLocation, actualLocation);
var result = compare.Compare(expectedLocation, actualLocation);
Assert.AreEqual(0, result.Differences.Count, result.DifferencesString);
CheckHempolderSurfaceline(actualLocation);
// TODO Implement for Delfland
// TODO: Implement for HD (Hollandse Delta)
}
}
}
[Test]
[Category("Integration")]
[TestCase(@"HHNK\TPL_Hempolder.damx", @"HHNK\TPL_Hempolder0.soilmaterials.mdb", "TPL_Hempolder_0100")]
// [TestCase(@"HD\Oude Tonge GO.damx", @"HD\Oude Tonge GO0.soilmaterials.mdb", "GO_16_17_9")]
// [TestCase(@"Delfland\Traject1_metDSM.damx", @"Traject1_metDSM0.soilmaterials.mdb", "VDP1")]
// For above cases to run we have to create funcitons CreateHdOudeTongeGO_16_17_9() and CreateDelflandTraject1_metDSM0VDP1()
public void CanLoadVersion_14_1_1_14(string projectFilename, string expectedSoilbaseName, string locationName)
{
const string dataFolder = @"..\..\..\data\Dam\Versions\V 14.1.1.14\";
string fullProjectFilename = Path.Combine(dataFolder, projectFilename);
using (var projectData = ProjectLoader.LoadProjectData(fullProjectFilename))
{
// Check data
using (Location expectedLocation = CreateHhnkTplHempolder100())
{
expectedLocation.SoildatabaseName = Path.Combine(dataFolder, expectedSoilbaseName);
Location actualLocation = projectData.Locations.Single(s => s.Name == locationName);
CompareSegments(expectedLocation, actualLocation);
var result = compare.Compare(expectedLocation, actualLocation);
Assert.AreEqual(0, result.Differences.Count, result.DifferencesString);
CheckHempolderSurfaceline(actualLocation);
}
}
}
[Test]
[Category("Integration")]
public void CanLoadVersion_14_1_1_14_SurfaceLine()
{
// Setup
const string projectFilenameHhnk = @"..\..\..\data\Dam\Versions\V 14.1.1.14\HHNK\TPL_Hempolder.damx";
// call
using (var projectData = ProjectLoader.LoadProjectData(projectFilenameHhnk))
{
// assert
Assert.AreEqual(1, projectData.WaterBoard.Dikes.Count);
var dike = projectData.WaterBoard.Dikes[0];
Assert.AreEqual(43, dike.Locations.Count);
Assert.AreEqual(43, dike.SurfaceLines2.Count);
var firstLocation = dike.Locations[0];
var firstSurfaceLine = dike.SurfaceLines2[0];
var localXzSurfaceLine = firstLocation.LocalXZSurfaceLine2;
Assert.AreNotSame(firstSurfaceLine, localXzSurfaceLine);
Assert.AreSame(firstSurfaceLine, firstLocation.SurfaceLine2);
Assert.AreEqual(firstSurfaceLine.Name, firstLocation.SurfaceLine2.Name);
foreach (var geometryPoint in localXzSurfaceLine.Geometry.Points)
{
CollectionAssert.DoesNotContain(firstSurfaceLine.Geometry.Points, geometryPoint,
"No reference should be shared between these two surfacelines.");
}
foreach (var geometryPoint in localXzSurfaceLine.CharacteristicPoints)
{
CollectionAssert.DoesNotContain(firstSurfaceLine.Geometry.Points, geometryPoint,
"No reference should be shared bewteen these two surfacelines.");
}
#region Test variable 'localXzSurfaceLine'
Assert.AreEqual(0, localXzSurfaceLine.Geometry.LatitudeAngle);
Assert.AreEqual(0, localXzSurfaceLine.Geometry.Offset);
Assert.AreEqual(DikeSideType.Outside, localXzSurfaceLine.Geometry.LeftDikeSideType);
Assert.AreEqual(new DateTime(2000, 1, 1), localXzSurfaceLine.Geometry.FromTime);
Assert.AreEqual(new DateTime(2000, 1, 1), localXzSurfaceLine.Geometry.UntilTime);
Assert.AreEqual("TPL_Hempolder_0010", localXzSurfaceLine.Name);
Assert.AreEqual(0, localXzSurfaceLine.Geometry.OriginalXy.X);
Assert.AreEqual(0, localXzSurfaceLine.Geometry.OriginalXy.Y);
Assert.AreEqual(13, localXzSurfaceLine.CharacteristicPoints.Count(cp => cp.CharacteristicPointType != CharacteristicPointType.None));
Assert.AreEqual(129, localXzSurfaceLine.Geometry.Points.Count);
Assert.AreSame(localXzSurfaceLine.Geometry.Points[0], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelOutside));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[16], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[16], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderBaseOutside));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[25], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[22], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.TrafficLoadOutside));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[28], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.TrafficLoadInside));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[29], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[37], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[40], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DitchDikeSide));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[41], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.BottomDitchDikeSide));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[42], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.BottomDitchPolderSide));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[43], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DitchPolderSide));
Assert.AreSame(localXzSurfaceLine.Geometry.Points[128], localXzSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelInside));
foreach (var geometryPoint in localXzSurfaceLine.Geometry.Points)
{
Assert.AreEqual(0, geometryPoint.Y);
Assert.AreEqual(" ", geometryPoint.Name);
Assert.AreEqual("", geometryPoint.Description);
}
// Check some geometry points:
Assert.AreEqual(39.056, localXzSurfaceLine.Geometry.Points[22].X, 1e-3);
Assert.AreEqual(0.0, localXzSurfaceLine.Geometry.Points[22].Z);
Assert.AreEqual(48.5778, localXzSurfaceLine.Geometry.Points[42].X, 1e-3);
Assert.AreEqual(-2.1, localXzSurfaceLine.Geometry.Points[42].Z);
Assert.AreEqual(130.0578, localXzSurfaceLine.Geometry.Points[127].X, 1e-3);
Assert.AreEqual(-1.18, localXzSurfaceLine.Geometry.Points[127].Z);
#endregion
#region Test variable 'firstSurfaceLine'
Assert.AreEqual(0, firstSurfaceLine.Geometry.LatitudeAngle);
Assert.AreEqual(0, firstSurfaceLine.Geometry.Offset);
Assert.AreEqual(DikeSideType.Outside, firstSurfaceLine.Geometry.LeftDikeSideType);
Assert.AreEqual(new DateTime(2000, 1, 1), firstSurfaceLine.Geometry.FromTime);
Assert.AreEqual(new DateTime(2000, 1, 1), firstSurfaceLine.Geometry.UntilTime);
Assert.AreEqual("TPL_Hempolder_0010", firstSurfaceLine.Name);
Assert.AreEqual(0, firstSurfaceLine.Geometry.OriginalXy.X);
Assert.AreEqual(0, firstSurfaceLine.Geometry.OriginalXy.Y);
Assert.AreEqual(13, firstSurfaceLine.CharacteristicPoints.Count(cp => cp.CharacteristicPointType != CharacteristicPointType.None));
Assert.AreEqual(129, firstSurfaceLine.Geometry.Points.Count);
Assert.AreSame(firstSurfaceLine.Geometry.Points[0], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelOutside));
Assert.AreSame(firstSurfaceLine.Geometry.Points[16], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver));
Assert.AreSame(firstSurfaceLine.Geometry.Points[16], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderBaseOutside));
Assert.AreSame(firstSurfaceLine.Geometry.Points[25], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver));
Assert.AreSame(firstSurfaceLine.Geometry.Points[22], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.TrafficLoadOutside));
Assert.AreSame(firstSurfaceLine.Geometry.Points[28], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.TrafficLoadInside));
Assert.AreSame(firstSurfaceLine.Geometry.Points[29], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder));
Assert.AreSame(firstSurfaceLine.Geometry.Points[37], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder));
Assert.AreSame(firstSurfaceLine.Geometry.Points[40], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DitchDikeSide));
Assert.AreSame(firstSurfaceLine.Geometry.Points[41], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.BottomDitchDikeSide));
Assert.AreSame(firstSurfaceLine.Geometry.Points[42], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.BottomDitchPolderSide));
Assert.AreSame(firstSurfaceLine.Geometry.Points[43], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DitchPolderSide));
Assert.AreSame(firstSurfaceLine.Geometry.Points[128], firstSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelInside));
foreach (var geometryPoint in firstSurfaceLine.Geometry.Points)
{
Assert.AreEqual(" ", geometryPoint.Name);
Assert.AreEqual("", geometryPoint.Description);
}
// Check some geometry points:
Assert.AreEqual(110615.85, firstSurfaceLine.Geometry.Points[5].X, 1e-6);
Assert.AreEqual(506911.84, firstSurfaceLine.Geometry.Points[5].Y, 1e-6);
Assert.AreEqual(-0.19, firstSurfaceLine.Geometry.Points[5].Z);
Assert.AreEqual(110620.75, firstSurfaceLine.Geometry.Points[15].X, 1e-6);
Assert.AreEqual(506910.84, firstSurfaceLine.Geometry.Points[15].Y, 1e-6);
Assert.AreEqual(-0.16, firstSurfaceLine.Geometry.Points[15].Z);
Assert.AreEqual(110713.35, firstSurfaceLine.Geometry.Points[127].X, 1e-3);
Assert.AreEqual(506891.99, firstSurfaceLine.Geometry.Points[127].Y, 1e-3);
Assert.AreEqual(-1.18, firstSurfaceLine.Geometry.Points[127].Z);
#endregion
var dikeJob = ((CompositeJob)projectData.WaterBoardJob).Jobs[0];
Assert.AreSame(dike, dikeJob.Subject);
Assert.AreSame(firstLocation, ((CompositeJob)dikeJob).Jobs[0].Subject);
}
}
[Test]
[Category("Integration")]
[TestCase(@"HHNK\TPL_Hempolder.damx", @"HHNK\TPL_Hempolder0.soilmaterials.mdb", "TPL_Hempolder_0100")]
//[TestCase(@"HD\Oude Tonge GO.damx", @"HD\Oude Tonge GO0.soilmaterials.mdb", "GO_16_17_9")]
//[TestCase(@"Delfland\Traject1_metDSM.damx", @"Traject1_metDSM0.soilmaterials.mdb", "VDP1")]
// For above cases to run we have to create funcitons CreateHdOudeTongeGO_16_17_9() and CreateDelflandTraject1_metDSM0VDP1()
public void CanLoadVersion_15_1_1_3(string projectFilename, string expectedSoilbaseName, string locationName)
{
const string dataFolder = @"..\..\..\data\Dam\Versions\V 14.1.1.14\";
string fullProjectFilename = Path.Combine(dataFolder, projectFilename);
using (var projectData = ProjectLoader.LoadProjectData(fullProjectFilename))
{
// Check data
using (Location expectedLocation = CreateHhnkTplHempolder100())
{
expectedLocation.SoildatabaseName = Path.Combine(dataFolder, expectedSoilbaseName);
Location actualLocation = projectData.Locations.Single(s => s.Name == locationName);
CompareSegments(expectedLocation, actualLocation);
var result = compare.Compare(expectedLocation, actualLocation);
Assert.AreEqual(0, result.Differences.Count, result.DifferencesString);
CheckHempolderSurfaceline(actualLocation);
}
}
}
[Test]
[Category("Integration")]
[TestCase(@"HHNK\TPL_Hempolder.damx", @"HHNK\TPL_Hempolder0.soilmaterials.mdb", "TPL_Hempolder_0100")]
//[TestCase(@"HD\Oude Tonge GO.damx", @"HD\Oude Tonge GO0.soilmaterials.mdb", "GO_16_17_9")]
//[TestCase(@"Delfland\Traject1_metDSM.damx", @"Traject1_metDSM0.soilmaterials.mdb", "VDP1")]
// For above cases to run we have to create funcitons CreateHdOudeTongeGO_16_17_9() and CreateDelflandTraject1_metDSM0VDP1()
public void CanLoadVersion_18_1_3(string projectFilename, string expectedSoilbaseName, string locationName)
{
const string dataFolder = @"..\..\..\data\Dam\Versions\V 18.1.3\";
string fullProjectFilename = Path.Combine(dataFolder, projectFilename);
using (var projectData = ProjectLoader.LoadProjectData(fullProjectFilename))
{
// Check data
using (Location expectedLocation = CreateHhnkTplHempolder100())
{
expectedLocation.SoildatabaseName = Path.Combine(dataFolder, expectedSoilbaseName);
Location actualLocation = projectData.Locations.Single(s => s.Name == locationName);
CompareSegments(expectedLocation, actualLocation);
var result = compare.Compare(expectedLocation, actualLocation);
Assert.AreEqual(0, result.Differences.Count, result.DifferencesString);
CheckHempolderSurfaceline(actualLocation);
}
}
}
///
/// Test if the project can be saved and loaded with the current version of the source
/// - Load old project
/// - save this project
/// - load this project
/// - compare for a specific location if the data is correct
/// This test is based on the same data as in CanLoadVersion_1_3_3_1()
///
[Test]
[Category(Categories.Slow)]
public void CanSaveAndLoadCurrentVersion()
{
const string projectFilenameHhnk = @"..\..\..\data\Dam\Versions\V 1.3.3.1\HHNK\TPL_Hempolder.damx";
const string projectFilenameCurrentVersion = @".\TPL_HempolderCurrent.damx";
// HHNK (Hollands Noorderkwartier)
using (var projectData = ProjectLoader.LoadProjectData(projectFilenameHhnk))
{
// Save in current XML format
DamProject.SaveData(projectFilenameCurrentVersion, projectData);
// Load from current XML format
using (var currentProjectData = ProjectLoader.LoadProjectData(projectFilenameCurrentVersion))
using (Location expectedLocation = CreateHhnkTplHempolder100())// Check data
{
expectedLocation.SoildatabaseName = @".\TPL_HempolderCurrent0.soilmaterials.mdb";
Location actualLocation = currentProjectData.Locations.Single(s => s.Name == "TPL_Hempolder_0100");
var result = compare.Compare(expectedLocation, actualLocation);
Assert.AreEqual(0, result.Differences.Count, result.DifferencesString);
}
}
}
}
}