// Copyright (C) Stichting Deltares 2024. 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;
using Deltares.Dam.Data.DamEngineIo;
using Deltares.DamEngine.Io;
using Deltares.DamEngine.Io.XmlOutput;
using Deltares.Geometry;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Standard.Logging;
using KellermanSoftware.CompareNetObjects;
using NUnit.Framework;
using SurfaceLine = Deltares.DamEngine.Io.XmlOutput.SurfaceLine;
using TimeSerie = Deltares.Dam.Data.TimeSerie;
using UpliftSituation = Deltares.DamEngine.Io.XmlOutput.UpliftSituation;
//
// 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.
namespace Deltares.Dam.Tests.DamEngineIo
{
[TestFixture]
public class FillDamUiFromXmlOutputTests
{
[Test]
public void CanWriteAndReadOutputCalculationMessagesToXmlString()
{
DamProjectData expectedDamProjectData = CreateDamProjectDataWithCalculationMessages();
Output output = FillXmlOutputFromDamUi.CreateOutput(expectedDamProjectData);
string outputString = DamXmlSerialization.SaveOutputAsXmlString(output);
output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
var actualDamProjectData = new DamProjectData();
actualDamProjectData = FillDamUiFromXmlOutput.AddOutputToDamProjectData(actualDamProjectData, output);
CompareDamProjectData(actualDamProjectData, expectedDamProjectData);
}
[Test]
public void ThrowWhenCalculationSubDirIsEmpty()
{
DamProjectData expectedDamProjectData = CreateDamProjectDataWithCalculationMessagesAndOneResult();
Output output = FillXmlOutputFromDamUi.CreateOutput(expectedDamProjectData);
output.Results.CalculationResults.First().CalculationSubDir = "";
string outputString = DamXmlSerialization.SaveOutputAsXmlString(output);
output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
var actualDamProjectData = new DamProjectData();
actualDamProjectData.WaterBoard.Dikes.Add(new Dike());
actualDamProjectData.DamProjectCalculationSpecification.CurrentSpecification = new DamFailureMechanismeCalculationSpecification();
Assert.That(() => FillDamUiFromXmlOutput.AddOutputToDamProjectData(actualDamProjectData, output),
Throws.InstanceOf());
}
[Test]
public void WhenOriginallyBaseFileNameIsEmptyItIsReset()
{
DamProjectData expectedDamProjectData = CreateDamProjectDataWithCalculationMessagesAndOneResult();
Output output = FillXmlOutputFromDamUi.CreateOutput(expectedDamProjectData);
output.Results.CalculationResults.First().BaseFileName = "";
string outputString = DamXmlSerialization.SaveOutputAsXmlString(output);
output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
var actualDamProjectData = new DamProjectData();
actualDamProjectData.WaterBoard.Dikes.Add(new Dike());
actualDamProjectData.DamProjectCalculationSpecification.CurrentSpecification =
new DamFailureMechanismeCalculationSpecification();
actualDamProjectData = FillDamUiFromXmlOutput.AddOutputToDamProjectData(actualDamProjectData, output);
Assert.That(string.IsNullOrEmpty(actualDamProjectData.DesignCalculations.First().BaseFileName), Is.False,
"BaseFileName should be reset");
}
[Test]
public void SimpleTestPiping()
{
DamProjectData inputProjectData = CreateInputProjectDataForPiping();
Output output = CreateTestOutputForPiping();
const string inputFilename = "OutputFilePiping.xml";
DamProjectData combinedDamProjectData = FillDamUiFromXmlOutput.AddOutputToDamProjectData(inputProjectData, output);
Assert.That(combinedDamProjectData.DesignCalculations.Count, Is.EqualTo(4));
Assert.That(combinedDamProjectData.DesignCalculations[0].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[2].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[3].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].ProfileName, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].ProfileName, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[0].Calculation, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].Calculation, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingModel, Is.EqualTo(PipingModelType.Bligh));
Assert.That(combinedDamProjectData.DesignCalculations[0].SafetyFactor, Is.EqualTo(0));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingExitPointX, Is.EqualTo(34.21));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingExitPointY, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingEntryPointX, Is.EqualTo(100.0));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingEntryPointY, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[0].DikeToeAtRiverXrd, Is.EqualTo(100));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingToeAtPolderZ, Is.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].PipingResultFile, Does.Contain(combinedDamProjectData.DesignCalculations[0].BaseFileName + ".prxml"));
Assert.That(combinedDamProjectData.DesignCalculations[1].ProfileName, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].ProfileName, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[1].Calculation, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].Calculation, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingModel, Is.EqualTo(PipingModelType.Bligh));
Assert.That(combinedDamProjectData.DesignCalculations[1].SafetyFactor, Is.EqualTo(1.03));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingExitPointX, Is.EqualTo(34.21));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingExitPointY, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingEntryPointX, Is.EqualTo(100.0));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingEntryPointY, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingToeAtPolderX, Is.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingToeAtPolderZ, Is.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].Pl3HeadAdjusted, Is.EqualTo(0.2));
Assert.That(combinedDamProjectData.DesignCalculations[1].Pl3MinUplift, Is.EqualTo(0.7));
Assert.That(combinedDamProjectData.DesignCalculations[1].Pl3LocationYMinUplift, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[1].PipingResultFile, Does.Contain(combinedDamProjectData.DesignCalculations[1].BaseFileName + ".prxml"));
DamXmlSerialization.SaveOutputAsXmlFile(inputFilename, output);
output = DamXmlSerialization.LoadOutputFromXmlFile(inputFilename);
DamProjectData actualDamProjectData = FillDamUiFromXmlOutput.AddOutputToDamProjectData(inputProjectData, output);
CompareDamProjectData(actualDamProjectData, combinedDamProjectData);
Assert.That(actualDamProjectData.DesignCalculations[0].CalculationResult, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].CalculationResult));
Assert.That(actualDamProjectData.DesignCalculations[0].SafetyFactor, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].SafetyFactor));
Assert.That(actualDamProjectData.DesignCalculations[0].LocationName, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].LocationName));
Assert.That(actualDamProjectData.DesignCalculations[0].StabilityModel, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].StabilityModel));
Assert.That(actualDamProjectData.DesignCalculations[0].RedesignedSurfaceLine2, Is.Not.Null);
}
[Test]
[TestCase(StabilityModelType.Bishop, "OutputFileStabilityBishop.xml")]
[TestCase(StabilityModelType.UpliftVan, "OutputFileStabilityUpliftVan.xml")]
public void SimpleTestStabilityInside(StabilityModelType stabilityModelType, string inputFilename)
{
DamProjectData inputProjectData = CreateInputProjectDataForStability(stabilityModelType);
Output output = CreateTestOutputForStability(stabilityModelType);
DamProjectData combinedDamProjectData = FillDamUiFromXmlOutput.AddOutputToDamProjectData(inputProjectData, output);
Assert.That(combinedDamProjectData.DesignCalculations.Count, Is.EqualTo(4));
Assert.That(combinedDamProjectData.DesignCalculations[0].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[2].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[3].Scenario, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].ProfileName, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].ProfileName, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[0].Calculation, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].Calculation, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[0].StabilityModel, Is.EqualTo(stabilityModelType));
Assert.That(combinedDamProjectData.DesignCalculations[0].SafetyFactor, Is.EqualTo(0));
Assert.That(combinedDamProjectData.DesignCalculations[0].StabilityShoulderHeight, Is.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].DikeLength, Is.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[0].Pl3HeadAdjusted, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[0].Pl3MinUplift, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[0].Pl3LocationYMinUplift, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[0].NumberOfIterations, Is.EqualTo(0));
Assert.That(combinedDamProjectData.DesignCalculations[0].GetDesignResultFile(),
Does.Contain(combinedDamProjectData.DesignCalculations[0].BaseFileName + ".rsxml"));
Assert.That(combinedDamProjectData.DesignCalculations[1].ProfileName, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].ProfileName, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[1].Calculation, Is.Not.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].Calculation, Is.Not.EqualTo(""));
Assert.That(combinedDamProjectData.DesignCalculations[1].StabilityModel, Is.EqualTo(stabilityModelType));
Assert.That(combinedDamProjectData.DesignCalculations[1].SafetyFactor, Is.EqualTo(1.2));
Assert.That(combinedDamProjectData.DesignCalculations[1].StabilityShoulderHeight, Is.EqualTo(null));
Assert.That(combinedDamProjectData.DesignCalculations[1].Pl3HeadAdjusted, Is.EqualTo(0.2));
Assert.That(combinedDamProjectData.DesignCalculations[1].Pl3MinUplift, Is.EqualTo(0.7));
Assert.That(combinedDamProjectData.DesignCalculations[1].Pl3LocationYMinUplift, Is.EqualTo(0.0));
Assert.That(combinedDamProjectData.DesignCalculations[1].NumberOfIterations, Is.EqualTo(1));
Assert.That(combinedDamProjectData.DesignCalculations[1].GetDesignResultFile(),
Does.Contain(combinedDamProjectData.DesignCalculations[1].BaseFileName + ".rsxml"));
DamXmlSerialization.SaveOutputAsXmlFile(inputFilename, output);
output = DamXmlSerialization.LoadOutputFromXmlFile(inputFilename);
DamProjectData actualDamProjectData = FillDamUiFromXmlOutput.AddOutputToDamProjectData(inputProjectData, output);
CompareDamProjectData(actualDamProjectData, combinedDamProjectData);
Assert.That(actualDamProjectData.DesignCalculations[0].CalculationResult, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].CalculationResult));
Assert.That(actualDamProjectData.DesignCalculations[0].SafetyFactor, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].SafetyFactor));
Assert.That(actualDamProjectData.DesignCalculations[0].LocationName, Is.EqualTo(combinedDamProjectData.DesignCalculations[0].LocationName));
Assert.That(actualDamProjectData.DesignCalculations[0].RedesignedSurfaceLine2, Is.Not.Null);
}
private static DamProjectData CreateDamProjectDataWithCalculationMessages()
{
var damProjectData = new DamProjectData();
damProjectData.CalculationMessages = new List();
damProjectData.CalculationMessages.Add(new LogMessage(LogMessageType.Error, null, "Error 1"));
damProjectData.CalculationMessages.Add(new LogMessage(LogMessageType.Error, null, "Error 2"));
damProjectData.CalculationMessages.Add(new LogMessage(LogMessageType.Warning, null, "Warning 1"));
FillOutputTimeSeries(damProjectData);
return damProjectData;
}
private static DamProjectData CreateDamProjectDataWithCalculationMessagesAndOneResult()
{
DamProjectData damProjectData = CreateDamProjectDataWithCalculationMessages();
var designResult = new CsvExportData("locationName", "scenarioName");
designResult.BaseFileName = "base";
designResult.CalculationSubDir = "aFolder";
damProjectData.DesignCalculations.Add(designResult);
return damProjectData;
}
private static void FillOutputTimeSeries(DamProjectData damProjectData)
{
const int timeSeriesCount = 2;
const int timeEntriesCount = 3;
const string idPipingBligh = "PipingFactorBligh";
const string idStabilityInsideFactor = "StabilityInsideFactor";
damProjectData.OutputTimeSerieCollection = new TimeSerieCollection();
for (var i = 0; i < timeSeriesCount; i++)
{
string locationId = String.Format("location{0}", i);
TimeSerie timeSerie = damProjectData.OutputTimeSerieCollection.AddNewSeries(locationId);
timeSerie.ParameterId = (i % 2 == 0) ? idPipingBligh : idStabilityInsideFactor;
timeSerie.ForecastDateTime = DateTime.Now;
timeSerie.StartDateTime = new DateTime(2012, 12, 31);
timeSerie.EndDateTime = new DateTime(2012, 12, 31, 1, 0, 0);
timeSerie.MissVal = -9999.0;
timeSerie.Units = "m";
for (var j = 0; j < timeEntriesCount; j++)
{
timeSerie.Entries.Add(new TimeSerieEntry
{
DateTime = new DateTime(2012, 12, 31, 1, j * 10, 0),
Value = 1 + j * 0.1
});
}
}
}
private DamProjectData CreateInputProjectDataForPiping()
{
var spec = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = FailureMechanismSystemType.Piping,
PipingModelType = PipingModelType.Bligh
};
return CreateInputProjectData(spec);
}
private DamProjectData CreateInputProjectDataForStability(StabilityModelType stabilityModelType)
{
var spec = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside,
CalculationModel = stabilityModelType
};
return CreateInputProjectData(spec);
}
private static DamProjectData CreateInputProjectData(DamFailureMechanismeCalculationSpecification spec)
{
var project = new DamProjectData
{
DamProjectCalculationSpecification =
{
CurrentSpecification = spec
}
};
project.WaterBoard.Dikes.Add(new Dike());
SurfaceLine2 surfaceline = CreateSurfaceLine2();
var location1 = new Location();
location1.Name = "Location 1";
location1.SurfaceLine2 = surfaceline;
var scenario1 = new Scenario();
scenario1.LocationScenarioID = "Scenario 1";
scenario1.Location = location1;
location1.Scenarios.Add(scenario1);
project.Locations.Add(location1);
var location2 = new Location("Location 2");
location2.SurfaceLine2 = surfaceline;
var scenario2 = new Scenario();
scenario2.LocationScenarioID = "Scenario 2";
scenario2.Location = location2;
location2.Scenarios.Add(scenario2);
project.Locations.Add(location2);
var location3 = new Location("Location 3");
location3.SurfaceLine2 = surfaceline;
var scenario3 = new Scenario();
scenario3.LocationScenarioID = "Scenario 3";
scenario3.Location = location3;
location3.Scenarios.Add(scenario3);
project.Locations.Add(location3);
var location4 = new Location("Location 4");
location4.SurfaceLine2 = surfaceline;
var scenario4 = new Scenario();
scenario4.LocationScenarioID = "Scenario 4";
scenario4.Location = location4;
location4.Scenarios.Add(scenario4);
project.Locations.Add(location4);
return project;
}
private Output CreateTestOutputForPiping()
{
Output output = CreateTestOutput();
for (var i = 0; i < 4; i++)
{
SurfaceLine surfaceline = CreateSurfaceLine();
UpliftSituation upliftSituation = CreateUpliftSituation(i);
DesignResultPipingDesignResults pipingdesignResults = CreateDesignResultPiping(i, surfaceline, upliftSituation);
output.Results.CalculationResults[i].PipingDesignResults = pipingdesignResults;
}
return output;
}
private Output CreateTestOutputForStability(StabilityModelType stabilityModelType)
{
Output output = CreateTestOutput();
for (var i = 0; i < 4; i++)
{
SurfaceLine surfaceLine = CreateSurfaceLine();
UpliftSituation upliftSituation = CreateUpliftSituation(i);
DesignResultStabilityDesignResults stabilityResults = CreateDesignResultStability(i, surfaceLine, upliftSituation, stabilityModelType);
output.Results.CalculationResults[i].StabilityDesignResults = stabilityResults;
}
return output;
}
private Output CreateTestOutput()
{
var output = new Output();
output.Results = new OutputResults();
output.Results.CalculationResults = new DesignResult[4];
for (var i = 0; i < 4; i++)
{
var desResult = new DesignResult
{
BaseFileName = "Basefilename" + (i + 1),
CalculationSubDir = "Subdir" + (i + 1),
LocationName = "Location " + (i + 1),
ScenarioName = "Scenario " + (i + 1),
ProfileName = "Profile " + (i + 1),
CalculationResult = 1 * i
};
output.Results.CalculationResults[i] = desResult;
}
return output;
}
private static UpliftSituation CreateUpliftSituation(int i)
{
var upliftSituation = new UpliftSituation
{
IsUplift = true,
Pl3HeadAdjusted = 0.2 * i,
Pl3LocationXMinUplift = 2.2 * i,
Pl3MinUplift = 0.7 * i,
Pl4HeadAdjusted = 0.4 * i,
Pl4LocationXMinUplift = 4.4 * i,
Pl4MinUplift = 4.7 * i
};
return upliftSituation;
}
private static DesignResultPipingDesignResults CreateDesignResultPiping(int i, SurfaceLine surfaceline, UpliftSituation upliftSituation)
{
var pipingdesignResults = new DesignResultPipingDesignResults
{
ResultMessage = "no run made",
UpliftFactorSpecified = true,
UpliftFactor = 1.3 * i,
HeaveFactorSpecified = true,
HeaveFactor = 1.1 * i,
BlighFactorSpecified = true,
BlighFactor = 1.03 * i,
BlighHcriticalSpecified = true,
BlighHcritical = 0.4,
ExitPointXSpecified = true,
ExitPointX = 34.21,
RedesignedSurfaceLine = surfaceline,
UpliftSituation = upliftSituation
};
return pipingdesignResults;
}
private static DesignResultStabilityDesignResults CreateDesignResultStability(int i, SurfaceLine surfaceline, UpliftSituation upliftSituation, StabilityModelType stabilityModelType)
{
var stabilityResults = new DesignResultStabilityDesignResults
{
ResultMessage = "aok",
SafetyFactor = 1.2 * i,
SafetyFactorSpecified = true,
NumberOfIterationsSpecified = true,
NumberOfIterations = 1 * i,
RedesignedSurfaceLine = surfaceline,
UpliftSituation = upliftSituation,
StabilityModelTypeSpecified = true,
StabilityModelType = ConversionHelper.ConvertToOutputStabilityModelType(stabilityModelType)
};
switch (stabilityModelType)
{
case StabilityModelType.Bishop:
var sl = new SlidingCircleMinimumSafetyCurveType();
sl.Center = new Point2DType
{
X = 10.1 * (i + 1),
Z = 11.1 * (i + 1)
};
sl.Radius = 101.1 * (i + 1);
stabilityResults.SlipCircleDefinition = sl;
break;
case StabilityModelType.UpliftVan:
var dsl = new DualSlidingCircleMinimumSafetyCurveType();
dsl.ActiveCircleCenter = new Point2DType
{
X = 20.2 * (i + 1),
Z = 22.2 * (i + 1)
};
dsl.ActiveCircleRadius = 202.2 * (i + 1);
dsl.PassiveCircleCenter = new Point2DType
{
X = 30.3 * (i + 1),
Z = 33.3 * (i + 1)
};
dsl.PassiveCircleRadius = 303.3 * (i + 1);
stabilityResults.SlipCircleDefinition = dsl;
break;
}
var slices = new List();
var slice1 = new MinimumSafetyCurveBaseTypeSlice
{
TopLeftPoint = new Point2DType
{
X = 11.1,
Z = 12.1
},
TopRightPoint = new Point2DType
{
X = 21.1,
Z = 22.1
},
BottomLeftPoint = new Point2DType
{
X = 31.1,
Z = 32.1
},
BottomRightPoint = new Point2DType
{
X = 41.1,
Z = 42.1
}
};
slices.Add(slice1);
var slice2 = new MinimumSafetyCurveBaseTypeSlice
{
TopLeftPoint = new Point2DType
{
X = 11.2,
Z = 12.2
},
TopRightPoint = new Point2DType
{
X = 21.2,
Z = 22.2
},
BottomLeftPoint = new Point2DType
{
X = 31.2,
Z = 32.2
},
BottomRightPoint = new Point2DType
{
X = 41.2,
Z = 42.2
}
};
slices.Add(slice2);
stabilityResults.SlipCircleDefinition.Slices = slices.ToArray();
return stabilityResults;
}
private static SurfaceLine CreateSurfaceLine()
{
var surfaceline = new SurfaceLine
{
Name = "Surfaceline 1",
Points = new SurfaceLinePoint[3]
};
var p1 = new SurfaceLinePoint
{
PointType = 0,
X = 0,
Z = 0
};
surfaceline.Points[0] = p1;
var p2 = new SurfaceLinePoint
{
PointType = 5,
X = 100,
Z = 10
};
surfaceline.Points[1] = p2;
var p3 = new SurfaceLinePoint
{
PointType = 25,
X = 120,
Z = 2
};
surfaceline.Points[2] = p3;
return surfaceline;
}
private static SurfaceLine2 CreateSurfaceLine2()
{
var surfaceline = new SurfaceLine2
{
Name = "Surfaceline 1"
};
surfaceline.CharacteristicPoints.Geometry = surfaceline.Geometry;
var p1 = new CharacteristicPoint
{
CharacteristicPointType = CharacteristicPointType.SurfaceLevelOutside,
GeometryPoint = new GeometryPoint(),
X = 0,
Z = 0
};
surfaceline.CharacteristicPoints.Add(p1);
var p2 = new CharacteristicPoint
{
CharacteristicPointType = CharacteristicPointType.DikeToeAtRiver,
GeometryPoint = new GeometryPoint(),
X = 100,
Z = 10
};
surfaceline.CharacteristicPoints.Add(p2);
var p3 = new CharacteristicPoint
{
CharacteristicPointType = CharacteristicPointType.SurfaceLevelInside,
GeometryPoint = new GeometryPoint(),
X = 120,
Z = 2
};
surfaceline.CharacteristicPoints.Add(p3);
return surfaceline;
}
private void CompareDamProjectData(DamProjectData actual, DamProjectData expected)
{
var compare = new CompareLogic
{
Config =
{
MaxDifferences = 100
}
};
compare.Config.MembersToIgnore = new List
{
"SheetPilePoint",
"SheetPilePointX",
"SheetPilePointY",
"SheetPilePointZ",
"LocalXZSheetPilePoint",
"SurfaceLine",
"LocalXZSurfaceLine",
"SoilLayer1D",
"MapForSoilGeometries2D"
};
ComparisonResult result = compare.Compare(expected, actual);
Assert.That(result.Differences.Count, Is.EqualTo(0), "Differences found read/write Input object");
}
}
}