Index: dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/DGeoStabilityResultReader.cs
===================================================================
diff -u -r426 -r430
--- dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/DGeoStabilityResultReader.cs (.../DGeoStabilityResultReader.cs) (revision 426)
+++ dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/DGeoStabilityResultReader.cs (.../DGeoStabilityResultReader.cs) (revision 430)
@@ -15,7 +15,7 @@
///
public static class DGeoStabilityResultReader
{
- private enum StabilityZone { stabilityZone1a = 1, stabilityZone1b = 2, stabilityZone2a = 3, stabilityZone2b = 4, stabilityZone3a = 5, stabilityZone3b = 6 };
+ internal enum StabilityZone { stabilityZone1a = 1, stabilityZone1b = 2, stabilityZone2a = 3, stabilityZone2b = 4, stabilityZone3a = 5, stabilityZone3b = 6 };
#region structs
@@ -234,7 +234,7 @@
return resultsSingleZone;
}
- private static DGeoStabilityResultsSingleZone? ParseZoneResults(string fileContent, int stabilityZone)
+ internal static DGeoStabilityResultsSingleZone? ParseZoneResults(string fileContent, int stabilityZone)
{
StringReader stringReader = new StringReader(fileContent);
string line = "";
Index: dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.nl-NL.resx
===================================================================
diff -u -r428 -r430
--- dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 428)
+++ dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 430)
@@ -151,13 +151,13 @@
Geen geldige berekening uitgevoerd
- Kan stabilityZone niet inlezen:
+ Kan zone results niet inlezen:
Kan kolom identificatie niet lezen
- stabilityZone of stabilityFactorIndex niet gevonden
+ Zone nummer of stabiliteitsfactor niet gevonden
Stabiliteitsbestand bevat geen identificator
Index: dam failuremechanisms/damMacroStability/trunk/src/Tests/Files/damCorruptParsingZonePlot.std
===================================================================
diff -u
--- dam failuremechanisms/damMacroStability/trunk/src/Tests/Files/damCorruptParsingZonePlot.std (revision 0)
+++ dam failuremechanisms/damMacroStability/trunk/src/Tests/Files/damCorruptParsingZonePlot.std (revision 430)
@@ -0,0 +1,16 @@
+[Dump]
+[Dump Header]
+[Column Indication]
+Stability factor
+Number of slices
+X-Centrepoint
+Y-Centrepoint
+Radius
+X coordinate left surface
+X coordinate right surface
+Zone number
+Dump name
+[End of Column Indication]
+[Data]
+ TextInsteadOfValue 35 46.429 7.714 11.357 35.401 54.764 3 Design level
+[End of Data]
Index: dam failuremechanisms/damMacroStability/trunk/src/Tests/Files/damCorruptFactorsMissing.std
===================================================================
diff -u
--- dam failuremechanisms/damMacroStability/trunk/src/Tests/Files/damCorruptFactorsMissing.std (revision 0)
+++ dam failuremechanisms/damMacroStability/trunk/src/Tests/Files/damCorruptFactorsMissing.std (revision 430)
@@ -0,0 +1,12 @@
+[Dump]
+[Dump Header]
+[Column Indication]
+Number of slices
+Stability factor
+X coordinate left surface
+X coordinate right surface
+Zone number
+[End of Column Indication]
+[Data]
+ 35
+[End of Data]
Index: dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.resx
===================================================================
diff -u -r428 -r430
--- dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.resx (.../Resources.resx) (revision 428)
+++ dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.resx (.../Resources.resx) (revision 430)
@@ -148,10 +148,10 @@
Could not read Column Indication
- Could not parse stabilityZone:
+ Could not parse zone results:
- stabilityZone or stabilityFactorIndex not found
+ Zone number or stability factor not found
Stability zone 1a or 1b should exist
Index: dam failuremechanisms/damMacroStability/trunk/src/Tests/Deltares.DamMacroStability.CalculatorTests/DGeoStabilityResultReaderTests.cs
===================================================================
diff -u -r425 -r430
--- dam failuremechanisms/damMacroStability/trunk/src/Tests/Deltares.DamMacroStability.CalculatorTests/DGeoStabilityResultReaderTests.cs (.../DGeoStabilityResultReaderTests.cs) (revision 425)
+++ dam failuremechanisms/damMacroStability/trunk/src/Tests/Deltares.DamMacroStability.CalculatorTests/DGeoStabilityResultReaderTests.cs (.../DGeoStabilityResultReaderTests.cs) (revision 430)
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Linq.Expressions;
using Deltares.DamMacroStability.Calculator;
using NUnit.Framework;
@@ -26,71 +27,73 @@
{
// expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 230
var contents = @" 28.237 28.850 23.786 2.324 " + Environment.NewLine +
- @"[End of CircleResults]" + Environment.NewLine +
- Environment.NewLine +
- @"[Dumps]" + Environment.NewLine +
- @" 1 : number of dumps in file" + Environment.NewLine +
- Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Stability factor" + Environment.NewLine +
- @"Number of slices" + Environment.NewLine +
- @"X-Centrepoint" + Environment.NewLine +
- @"Y-Centrepoint" + Environment.NewLine +
- @"Radius" + Environment.NewLine +
- @"X coordinate left surface" + Environment.NewLine +
- @"X coordinate right surface" + Environment.NewLine +
- @"Dump name" + Environment.NewLine +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[SliceGeometry]" + Environment.NewLine +
- @"[Column Indication]" +
- @"[MODEL]" + Environment.NewLine +
- @" 1 : Bishop" + Environment.NewLine;
-
+ @"[End of CircleResults]" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dumps]" + Environment.NewLine +
+ @" 1 : number of dumps in file" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Stability factor" + Environment.NewLine +
+ @"Number of slices" + Environment.NewLine +
+ @"X-Centrepoint" + Environment.NewLine +
+ @"Y-Centrepoint" + Environment.NewLine +
+ @"Radius" + Environment.NewLine +
+ @"X coordinate left surface" + Environment.NewLine +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Dump name" + Environment.NewLine +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" +
+ Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[SliceGeometry]" + Environment.NewLine +
+ @"[Column Indication]" +
+ @"[MODEL]" + Environment.NewLine +
+ @" 1 : Bishop" + Environment.NewLine;
+
var result = DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
Assert.AreEqual(1.276, result.Zone1.SafetyFactor, 0.001);
}
-
+
[Test]
public void TestCanParseStringContentWhenSafetyFactorIsInOtherColumn()
{
// expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 230
var contents = @" 28.237 28.850 23.786 2.324 " + Environment.NewLine +
- @"[End of CircleResults]" + Environment.NewLine +
- Environment.NewLine +
- @"[Dumps]" + Environment.NewLine +
- @" 1 : number of dumps in file" + Environment.NewLine +
- Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Number of slices" + Environment.NewLine +
- @"X-Centrepoint" + Environment.NewLine +
- @"Y-Centrepoint" + Environment.NewLine +
- @"Stability factor" + Environment.NewLine +
- @"Radius" + Environment.NewLine +
- @"X coordinate left surface" + Environment.NewLine +
- @"X coordinate right surface" + Environment.NewLine +
- @"Dump name" + Environment.NewLine +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[SliceGeometry]" + Environment.NewLine +
- @"[Column Indication]" +
- @"[MODEL]" + Environment.NewLine +
- @" 1 : Bishop" + Environment.NewLine;
-
+ @"[End of CircleResults]" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dumps]" + Environment.NewLine +
+ @" 1 : number of dumps in file" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Number of slices" + Environment.NewLine +
+ @"X-Centrepoint" + Environment.NewLine +
+ @"Y-Centrepoint" + Environment.NewLine +
+ @"Stability factor" + Environment.NewLine +
+ @"Radius" + Environment.NewLine +
+ @"X coordinate left surface" + Environment.NewLine +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Dump name" + Environment.NewLine +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" +
+ Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[SliceGeometry]" + Environment.NewLine +
+ @"[Column Indication]" +
+ @"[MODEL]" + Environment.NewLine +
+ @" 1 : Bishop" + Environment.NewLine;
+
var result = DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
Assert.AreEqual(21.971, result.Zone1.SafetyFactor, 0.001);
}
-
+
[Test]
public void TestCanParseFileContentsStability()
{
@@ -101,7 +104,7 @@
Assert.AreEqual(1.276, result.Zone1.SafetyFactor, 0.001);
Assert.AreEqual(26.091, result.Zone1.CircleSurfacePointRightXCoordinate, 0.001);
}
-
+
[Test]
public void TestValidateIfFileContentsHasZonePlotEnabled()
{
@@ -117,94 +120,96 @@
{
// expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 230
string zonePlotOff = @"[MODEL]" + Environment.NewLine +
- @" 1 : Bishop" + Environment.NewLine +
- @" 1 : C phi" + Environment.NewLine +
- @" 0 : Probabilistic off" + Environment.NewLine +
- @" 1 : Mean" + Environment.NewLine +
- @" 0 : Geotextiles off" + Environment.NewLine +
- @" 0 : Nails off" + Environment.NewLine +
- @" 0 : Zone plot on" + Environment.NewLine +
- @" 0 : Local measurements" + Environment.NewLine +
- @"[END OF MODEL]" + Environment.NewLine;
-
+ @" 1 : Bishop" + Environment.NewLine +
+ @" 1 : C phi" + Environment.NewLine +
+ @" 0 : Probabilistic off" + Environment.NewLine +
+ @" 1 : Mean" + Environment.NewLine +
+ @" 0 : Geotextiles off" + Environment.NewLine +
+ @" 0 : Nails off" + Environment.NewLine +
+ @" 0 : Zone plot on" + Environment.NewLine +
+ @" 0 : Local measurements" + Environment.NewLine +
+ @"[END OF MODEL]" + Environment.NewLine;
+
bool actualZonePlot = DGeoStabilityResultReader.ParseHasZonePlotEnabled(zonePlotOff);
bool expectedZonePlot = false;
-
+
Assert.AreEqual(actualZonePlot, expectedZonePlot);
}
-
+
[Test]
public void TestFileContentsHasZonePlotZone1bAndZone2b()
{
// expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 230
string testWithZonePlot1bAnd2b = @"[MODEL]" + Environment.NewLine +
- @" 1 : Bishop" + Environment.NewLine +
- @" 1 : C phi" + Environment.NewLine +
- @" 0 : Probabilistic off" + Environment.NewLine +
- @" 1 : Mean" + Environment.NewLine +
- @" 0 : Geotextiles off" + Environment.NewLine +
- @" 0 : Nails off" + Environment.NewLine +
- @" 1 : Zone plot on" + Environment.NewLine +
- @" 0 : Local measurements" + Environment.NewLine +
- @"[END OF MODEL]" + Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Stability factor" + Environment.NewLine +
- @"Number of slices" + Environment.NewLine +
- @"X-Centrepoint" + Environment.NewLine +
- @"Y-Centrepoint" + Environment.NewLine +
- @"Radius" + Environment.NewLine +
- @"X coordinate left surface" + Environment.NewLine +
- @"X coordinate right surface" + Environment.NewLine +
- @"Zone number" + Environment.NewLine +
- @"Dump name" + Environment.NewLine +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.234 35 46.429 7.714 11.357 17.810 24.310 2 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Stability factor" + Environment.NewLine +
- @"Number of slices" + Environment.NewLine +
- @"X-Centrepoint" + Environment.NewLine +
- @"Y-Centrepoint" + Environment.NewLine +
- @"Radius" + Environment.NewLine +
- @"X coordinate left surface" + Environment.NewLine +
- @"X coordinate right surface" + Environment.NewLine +
- @"Zone number" + Environment.NewLine +
- @"Dump name" + Environment.NewLine +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.345 35 46.429 7.714 11.357 19.810 26.310 4 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine;
+ @" 1 : Bishop" + Environment.NewLine +
+ @" 1 : C phi" + Environment.NewLine +
+ @" 0 : Probabilistic off" + Environment.NewLine +
+ @" 1 : Mean" + Environment.NewLine +
+ @" 0 : Geotextiles off" + Environment.NewLine +
+ @" 0 : Nails off" + Environment.NewLine +
+ @" 1 : Zone plot on" + Environment.NewLine +
+ @" 0 : Local measurements" + Environment.NewLine +
+ @"[END OF MODEL]" + Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Stability factor" + Environment.NewLine +
+ @"Number of slices" + Environment.NewLine +
+ @"X-Centrepoint" + Environment.NewLine +
+ @"Y-Centrepoint" + Environment.NewLine +
+ @"Radius" + Environment.NewLine +
+ @"X coordinate left surface" + Environment.NewLine +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Zone number" + Environment.NewLine +
+ @"Dump name" + Environment.NewLine +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.234 35 46.429 7.714 11.357 17.810 24.310 2 Design level" +
+ Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Stability factor" + Environment.NewLine +
+ @"Number of slices" + Environment.NewLine +
+ @"X-Centrepoint" + Environment.NewLine +
+ @"Y-Centrepoint" + Environment.NewLine +
+ @"Radius" + Environment.NewLine +
+ @"X coordinate left surface" + Environment.NewLine +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Zone number" + Environment.NewLine +
+ @"Dump name" + Environment.NewLine +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.345 35 46.429 7.714 11.357 19.810 26.310 4 Design level" +
+ Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine;
- DGeoStabilityResultReader.DGeoStabilityResults actualMStabResults =
+ DGeoStabilityResultReader.DGeoStabilityResults actualMStabResults =
DGeoStabilityResultReader.GetDGeoStabilityResults(testWithZonePlot1bAnd2b);
- DGeoStabilityResultReader.DGeoStabilityResultsSingleZone expectedStabilityZone1 =
+ DGeoStabilityResultReader.DGeoStabilityResultsSingleZone expectedStabilityZone1 =
new DGeoStabilityResultReader.DGeoStabilityResultsSingleZone();
- DGeoStabilityResultReader.DGeoStabilityResultsSingleZone expectedStabilityZone2 =
+ DGeoStabilityResultReader.DGeoStabilityResultsSingleZone expectedStabilityZone2 =
new DGeoStabilityResultReader.DGeoStabilityResultsSingleZone();
expectedStabilityZone1.SafetyFactor = 1.234;
expectedStabilityZone1.CircleSurfacePointLeftXCoordinate = 17.810;
expectedStabilityZone1.CircleSurfacePointRightXCoordinate = 24.310;
expectedStabilityZone2.SafetyFactor = 1.345;
expectedStabilityZone2.CircleSurfacePointLeftXCoordinate = 19.810;
expectedStabilityZone2.CircleSurfacePointRightXCoordinate = 26.310;
-
+
Assert.IsNotNull(actualMStabResults);
Assert.AreEqual(expectedStabilityZone1.SafetyFactor, actualMStabResults.Zone1.SafetyFactor, 0.001);
- Assert.AreEqual(expectedStabilityZone1.CircleSurfacePointRightXCoordinate,
+ Assert.AreEqual(expectedStabilityZone1.CircleSurfacePointRightXCoordinate,
actualMStabResults.Zone1.CircleSurfacePointRightXCoordinate, 0.001);
Assert.IsNotNull(actualMStabResults.Zone2);
Assert.AreEqual(expectedStabilityZone2.SafetyFactor, actualMStabResults.Zone2.Value.SafetyFactor, 0.001);
- Assert.AreEqual(expectedStabilityZone2.CircleSurfacePointRightXCoordinate,
+ Assert.AreEqual(expectedStabilityZone2.CircleSurfacePointRightXCoordinate,
actualMStabResults.Zone2.Value.CircleSurfacePointRightXCoordinate, 0.001);
}
-
+
[Test]
public void TestCanParseFileHasStabilityFactorZone()
{
@@ -214,9 +219,43 @@
var result = DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
Assert.AreEqual(1.104, result.Zone1.SafetyFactor, 0.001);
}
-
+
+ [Test]
+ public void TestSafetyFactorForZoneResultsNoUplift()
+ {
+ // expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 230
+ // but added that safetyfactor is divided by factor 1.05 when IsUpliftResults is false
+ string fileName = Path.Combine(TestFolder, TestFileWithZonePlot);
+ var contents = DGeoStabilityResultReader.GetFileContents(fileName);
+ var result = DGeoStabilityResultReader.ParseZoneResults(contents,
+ (int) DGeoStabilityResultReader.StabilityZone.stabilityZone2a);
+ Assert.IsTrue(result != null);
+ var safetyFactor = ((DGeoStabilityResultReader.DGeoStabilityResultsSingleZone) result).SafetyFactor;
+ Assert.GreaterOrEqual(1.276/1.05, safetyFactor);
+ }
+
+ [Test]
+ public void TestInitStructs()
+ {
+ var results = new DGeoStabilityResultReader.DGeoStabilityResults();
+ results.Init();
+ var zone = results.Zone1;
+ Assert.AreEqual(zone.SafetyFactor, 0.0, 0.01);
+ Assert.AreEqual(zone.CircleSurfacePointLeftXCoordinate, 0.0, 0.01);
+ Assert.AreEqual(zone.CircleSurfacePointRightXCoordinate, 0.0, 0.01);
+ Assert.AreEqual(zone.EntryPointXCoordinate, 0.0, 0.01);
+ Assert.AreEqual(zone.ExitPointXCoordinate, 0.0, 0.01);
+ Assert.IsTrue(results.Zone2 != null);
+ zone = (DGeoStabilityResultReader.DGeoStabilityResultsSingleZone) results.Zone2;
+ Assert.AreEqual(zone.SafetyFactor, 0.0, 0.01);
+ Assert.AreEqual(zone.CircleSurfacePointLeftXCoordinate, 0.0, 0.01);
+ Assert.AreEqual(zone.CircleSurfacePointRightXCoordinate, 0.0, 0.01);
+ Assert.AreEqual(zone.EntryPointXCoordinate, 0.0, 0.01);
+ Assert.AreEqual(zone.ExitPointXCoordinate, 0.0, 0.01);
+ }
+
#region Exceptions
-
+
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Uitvoerbestand '' heeft geen inhoud")]
[SetUICulture("nl-NL")]
@@ -239,14 +278,14 @@
{
DGeoStabilityResultReader.GetDGeoStabilityResults(null);
}
-
+
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestThrowsExceptionWhenFileContainsOnlySpaces()
{
DGeoStabilityResultReader.GetDGeoStabilityResults(" ");
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfDumpsHeaderNotFoundInContent()
@@ -259,7 +298,7 @@
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfDumpHeaderNotFoundInContent()
@@ -271,7 +310,7 @@
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfDataHeaderNotFoundInContent()
@@ -284,161 +323,231 @@
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfStabilityColumnNotFound()
{
var contents = @" 28.237 28.850 23.786 2.324 " + Environment.NewLine +
- @"[End of CircleResults]" + Environment.NewLine +
- Environment.NewLine +
- @"[Dumps]" + Environment.NewLine +
- @" 1 : number of dumps in file" + Environment.NewLine +
- Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- //@"Stability factor" + Environment.NewLine +
- @"Number of slices" + Environment.NewLine +
- @"X-Centrepoint" + Environment.NewLine +
- @"Y-Centrepoint" + Environment.NewLine +
- @"Radius" + Environment.NewLine +
- @"X coordinate left surface" + Environment.NewLine +
- @"X coordinate right surface" + Environment.NewLine +
- @"Dump name" + Environment.NewLine +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[SliceGeometry]" + Environment.NewLine +
- @"[Column Indication]";
+ @"[End of CircleResults]" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dumps]" + Environment.NewLine +
+ @" 1 : number of dumps in file" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ //@"Stability factor" + Environment.NewLine +
+ @"Number of slices" + Environment.NewLine +
+ @"X-Centrepoint" + Environment.NewLine +
+ @"Y-Centrepoint" + Environment.NewLine +
+ @"Radius" + Environment.NewLine +
+ @"X coordinate left surface" + Environment.NewLine +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Dump name" + Environment.NewLine +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" +
+ Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[SliceGeometry]" + Environment.NewLine +
+ @"[Column Indication]";
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfExitPointXCoordinateColumnNotFound()
{
var contents = @" 28.237 28.850 23.786 2.324 " + Environment.NewLine +
- @"[End of CircleResults]" + Environment.NewLine +
- Environment.NewLine +
- @"[Dumps]" + Environment.NewLine +
- @" 1 : number of dumps in file" + Environment.NewLine +
- Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Stability factor" + Environment.NewLine +
- @"Number of slices" + Environment.NewLine +
- @"X-Centrepoint" + Environment.NewLine +
- @"Y-Centrepoint" + Environment.NewLine +
- @"Radius" + Environment.NewLine +
- // @"X coordinate right surface" + Environment.NewLine +
- @"Dump name" + Environment.NewLine +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.276 35 18.216 21.971 12.907 17.810 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[SliceGeometry]" + Environment.NewLine +
- @"[Column Indication]";
+ @"[End of CircleResults]" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dumps]" + Environment.NewLine +
+ @" 1 : number of dumps in file" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Stability factor" + Environment.NewLine +
+ @"Number of slices" + Environment.NewLine +
+ @"X-Centrepoint" + Environment.NewLine +
+ @"Y-Centrepoint" + Environment.NewLine +
+ @"Radius" + Environment.NewLine +
+ // @"X coordinate right surface" + Environment.NewLine +
+ @"Dump name" + Environment.NewLine +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.276 35 18.216 21.971 12.907 17.810 Design level" + Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[SliceGeometry]" + Environment.NewLine +
+ @"[Column Indication]";
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfStabilityColumnCouldntBeParsed()
{
var contents = @" 28.237 28.850 23.786 2.324 " + Environment.NewLine +
- @"[End of CircleResults]" + Environment.NewLine +
- Environment.NewLine +
- @"[Dumps]" + Environment.NewLine +
- @" 1 : number of dumps in file" + Environment.NewLine +
- Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Stability factor " +
- @"Number of slices " +
- @"X-Centrepoint " +
- @"Y-Centrepoint " +
- @"Radius " +
- @"X coordinate left surface" + Environment.NewLine +
- @"X coordinate right surface" + Environment.NewLine +
- @"Dump name " +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[SliceGeometry]" + Environment.NewLine +
- @"[Column Indication]";
+ @"[End of CircleResults]" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dumps]" + Environment.NewLine +
+ @" 1 : number of dumps in file" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Stability factor " +
+ @"Number of slices " +
+ @"X-Centrepoint " +
+ @"Y-Centrepoint " +
+ @"Radius " +
+ @"X coordinate left surface" + Environment.NewLine +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Dump name " +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.276 35 18.216 21.971 12.907 12.907 17.810 Design level" +
+ Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[SliceGeometry]" + Environment.NewLine +
+ @"[Column Indication]";
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(DGeoStabilityResultReaderException))]
public void TestThrowIfExitPointXCoordinateColumnCouldntBeParsed()
{
var contents = @" 28.237 28.850 23.786 2.324 " + Environment.NewLine +
- @"[End of CircleResults]" + Environment.NewLine +
- Environment.NewLine +
- @"[Dumps]" + Environment.NewLine +
- @" 1 : number of dumps in file" + Environment.NewLine +
- Environment.NewLine +
- @"[Dump]" + Environment.NewLine +
- @"[Dump Header]" + Environment.NewLine +
- @"[Column Indication]" + Environment.NewLine +
- @"Stability factor " +
- @"Number of slices " +
- @"X-Centrepoint " +
- @"Y-Centrepoint " +
- @"Radius " +
- @"X coordinate right surface" + Environment.NewLine +
- @"Dump name " +
- @"[End of Column Indication]" + Environment.NewLine +
- @"[Data]" + Environment.NewLine +
- @" 1.276 35 18.216 21.971 12.907 17.810 Design level" + Environment.NewLine +
- @"[End of Data]" + Environment.NewLine +
- @"[End Of Dump Header]" + Environment.NewLine +
- @"[SliceGeometry]" + Environment.NewLine +
- @"[Column Indication]";
+ @"[End of CircleResults]" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dumps]" + Environment.NewLine +
+ @" 1 : number of dumps in file" + Environment.NewLine +
+ Environment.NewLine +
+ @"[Dump]" + Environment.NewLine +
+ @"[Dump Header]" + Environment.NewLine +
+ @"[Column Indication]" + Environment.NewLine +
+ @"Stability factor " +
+ @"Number of slices " +
+ @"X-Centrepoint " +
+ @"Y-Centrepoint " +
+ @"Radius " +
+ @"X coordinate right surface" + Environment.NewLine +
+ @"Dump name " +
+ @"[End of Column Indication]" + Environment.NewLine +
+ @"[Data]" + Environment.NewLine +
+ @" 1.276 35 18.216 21.971 12.907 17.810 Design level" + Environment.NewLine +
+ @"[End of Data]" + Environment.NewLine +
+ @"[End Of Dump Header]" + Environment.NewLine +
+ @"[SliceGeometry]" + Environment.NewLine +
+ @"[Column Indication]";
DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
}
-
+
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestThrowIfOuputFileNameEmpty()
{
DGeoStabilityResultReader.GetFileContents("");
}
-
+
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestThrowIfOuputFileNameIsNull()
{
DGeoStabilityResultReader.GetFileContents(null);
}
-
+
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestThrowIfOuputFileNameContainsSpaces()
{
DGeoStabilityResultReader.GetFileContents("");
}
-
+
[Test]
[ExpectedException(typeof(FileNotFoundException))]
- public void TestThrowIfOuputFileNotFound()
+ public void TestThrowIfOuputFileNotFoundAtGetFileContents()
{
DGeoStabilityResultReader.GetFileContents("test.std");
}
-
+
+ [Test]
+ [ExpectedException(typeof(FileNotFoundException))]
+ public void TestThrowIfOuputFileNotFoundAtParseResultsFromOutputFile()
+ {
+ DGeoStabilityResultReader.ParseResultsFromOutputFile("test.std");
+ }
+
+ [Test]
+ [ExpectedException(typeof(DGeoStabilityResultReaderException),
+ ExpectedMessage = "Stabiliteitszone 1a of 1b zou moeten bestaan")]
+ [SetUICulture("nl-NL")]
+ public void TestThrowIfZoneResults1DoNotExistInFileContent()
+ {
+ var contents = @" 1 : Zone plot on" + Environment.NewLine;
+ DGeoStabilityResultReader.GetDGeoStabilityResults(contents);
+ }
+
+ [Test]
+ [ExpectedException(typeof(DGeoStabilityResultReaderException),
+ ExpectedMessage = "Kan kolom identificatie niet lezen")]
+ [SetUICulture("nl-NL")]
+ public void TestThrowIfCouldNotReadColumnIndication()
+ {
+ var contents = @" 1 : Zone plot on" + Environment.NewLine +
+ @"[Dump]";
+ DGeoStabilityResultReader.ParseZoneResults(contents,
+ (int) DGeoStabilityResultReader.StabilityZone.stabilityZone2a);
+ }
+
+// [Test]
+// [ExpectedException(typeof(DGeoStabilityResultReaderException), ExpectedMessage = "Kan kolom identificatie niet lezen")]
+// [SetUICulture("nl-NL")]
+// public void TestThrowIfCouldNotReadColumnIndication()
+// {
+// var contents = @" 1 : Zone plot on" + Environment.NewLine +
+// @"[Dump]";
+// DGeoStabilityResultReader.ParseZoneResults(contents, (int)DGeoStabilityResultReader.StabilityZone.stabilityZone2a);
+// }
+
+ [Test]
+ [ExpectedException(typeof(DGeoStabilityResultReaderException),
+ ExpectedMessage = "Zone nummer of stabiliteitsfactor niet gevonden")]
+ [SetUICulture("nl-NL")]
+ public void TestThrowIfIndicesWereNotFound()
+ {
+ string fileName = Path.Combine(TestFolder, "damCorruptFactorsMissing.std");
+ var contents = DGeoStabilityResultReader.GetFileContents(fileName);
+ DGeoStabilityResultReader.ParseZoneResults(contents,
+ (int) DGeoStabilityResultReader.StabilityZone.stabilityZone2a);
+ }
+
+ [Test]
+ [SetUICulture("nl-NL")]
+ public void TestThrowIfParsingZoneResultsFails()
+ {
+ // It is not possible to check the ExpectedMessage here because it contains code information like line number etc.
+ string fileName = Path.Combine(TestFolder, "damCorruptParsingZonePlot.std");
+ var contents = DGeoStabilityResultReader.GetFileContents(fileName);
+ try
+ {
+ DGeoStabilityResultReader.ParseZoneResults(contents, (int)DGeoStabilityResultReader.StabilityZone.stabilityZone2a);
+ }
+ catch (Exception e)
+ {
+ Assert.IsTrue(e.Message.Contains("Kan zone results niet inlezen: "));
+ }
+
+ }
#endregion
}
Index: dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.Designer.cs
===================================================================
diff -u -r428 -r430
--- dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 428)
+++ dam failuremechanisms/damMacroStability/trunk/src/Deltares.DamMacroStability.Calculator/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 430)
@@ -161,7 +161,7 @@
}
///
- /// Looks up a localized string similar to Could not parse stabilityZone: .
+ /// Looks up a localized string similar to Could not parse zone results: .
///
internal static string DGeoStabilityResultReader_ParseZoneResults_CouldNotParseStabilityZone {
get {
@@ -179,7 +179,7 @@
}
///
- /// Looks up a localized string similar to stabilityZone or stabilityFactorIndex not found.
+ /// Looks up a localized string similar to Zone number or stability factor not found.
///
internal static string DGeoStabilityResultReader_ParseZoneResults_StabilityZoneOrStabilityFactorIndexNotFound {
get {