Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilSurfaceProfileTests.cs =================================================================== diff -u -r3893 -r4000 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilSurfaceProfileTests.cs (.../SoilSurfaceProfileTests.cs) (revision 3893) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilSurfaceProfileTests.cs (.../SoilSurfaceProfileTests.cs) (revision 4000) @@ -71,18 +71,18 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(3)); SoilLayer2D topSoilLayer2D = soilLayer2Ds.Single(l => string.Equals(l.Name, topLayerName)); AssertDikeEmbankmentSoilLayerProperties(soilSurfaceProfile, topSoilLayer2D); - AssertGeometry(new [] + AssertGeometry(new[] { - new GeometryCurve(new Point2D(0, 0), new Point2D(5, 10)), - new GeometryCurve(new Point2D(5, 10), new Point2D(10, 10)), - new GeometryCurve(new Point2D(10, 10), new Point2D(10, -2)), - new GeometryCurve(new Point2D(10, -2), new Point2D(5, -2)), - new GeometryCurve(new Point2D(5, -2), new Point2D(0, -2)), + new GeometryCurve(new Point2D(0, 0), new Point2D(5, 10)), + new GeometryCurve(new Point2D(5, 10), new Point2D(10, 10)), + new GeometryCurve(new Point2D(10, 10), new Point2D(10, -2)), + new GeometryCurve(new Point2D(10, -2), new Point2D(5, -2)), + new GeometryCurve(new Point2D(5, -2), new Point2D(0, -2)), new GeometryCurve(new Point2D(0, -2), new Point2D(0, 0)) }, topSoilLayer2D.GeometrySurface.OuterLoop.CurveList); @@ -152,7 +152,7 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(2)); SoilLayer2D middleSoilLayer2D = soilLayer2Ds.Single(l => string.Equals(l.Name, middleLayerName)); @@ -215,7 +215,7 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(2)); SoilLayer2D middleLayer2D = soilLayer2Ds.Single(l => string.Equals(l.Name, middleLayerName)); @@ -244,7 +244,7 @@ } [Test] - public void ConvertToSoilProfile2D_WithSurfaceLinePartiallyEnvelopedByTopSoilLayer_ReturnsExpectedSoilProfile2D() + public void ConvertToSoilProfile2D_WithSurfaceLinePartiallyEnvelopedByTopSoilLayer_ReturnsExpectedSoilProfile2D() { // Setup const string bottomLayerName = "BottomLayer"; @@ -280,7 +280,7 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(3)); SoilLayer2D topSoilLayer2D = soilLayer2Ds.Single(l => string.Equals(l.Name, topLayerName)); @@ -363,20 +363,21 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(5)); - var topSoilLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, topLayerName)).ToArray(); + SoilLayer2D[] topSoilLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, topLayerName)).ToArray(); Assert.That(topSoilLayerSurfaces.Length, Is.EqualTo(2)); foreach (SoilLayer2D surface in topSoilLayerSurfaces) { AssertDikeEmbankmentSoilLayerProperties(soilSurfaceProfile, surface); } - AssertGeometry(new [] + + AssertGeometry(new[] { - new GeometryCurve(new Point2D(0, 2.5), new Point2D(2.5, 0)), - new GeometryCurve(new Point2D(2.5, 0), new Point2D(0, 0)), - new GeometryCurve(new Point2D(0, 0), new Point2D(0, 2.5)) + new GeometryCurve(new Point2D(0, 2.5), new Point2D(2.5, 0)), + new GeometryCurve(new Point2D(2.5, 0), new Point2D(0, 0)), + new GeometryCurve(new Point2D(0, 0), new Point2D(0, 2.5)) }, topSoilLayerSurfaces[0].GeometrySurface.OuterLoop.CurveList); AssertGeometry(new[] { @@ -385,12 +386,13 @@ new GeometryCurve(new Point2D(10, 0), new Point2D(7.5, 0)) }, topSoilLayerSurfaces[1].GeometrySurface.OuterLoop.CurveList); - var middleLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, middleLayerName)).ToArray(); + SoilLayer2D[] middleLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, middleLayerName)).ToArray(); Assert.That(middleLayerSurfaces.Length, Is.EqualTo(2)); foreach (SoilLayer2D surface in middleLayerSurfaces) { AssertSoilLayerProperties(middleLayer, surface); } + AssertGeometry(new[] { new GeometryCurve(new Point2D(0, 0), new Point2D(2.5, 0)), @@ -426,7 +428,6 @@ new GeometryCurve(new Point2D(3.75, -10), new Point2D(2.5, -10)), new GeometryCurve(new Point2D(2.5, -10), new Point2D(0, -10)), new GeometryCurve(new Point2D(0, -10), new Point2D(0, -1.25)) - }, bottomLayerSurface.GeometrySurface.OuterLoop.CurveList); } @@ -467,15 +468,16 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(5)); - var topSoilLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, topLayerName)).ToArray(); + SoilLayer2D[] topSoilLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, topLayerName)).ToArray(); Assert.That(topSoilLayerSurfaces.Length, Is.EqualTo(2)); foreach (SoilLayer2D surface in topSoilLayerSurfaces) { AssertDikeEmbankmentSoilLayerProperties(soilSurfaceProfile, surface); } + AssertGeometry(new[] { new GeometryCurve(new Point2D(0, 2.5), new Point2D(2.5, 0)), @@ -489,12 +491,13 @@ new GeometryCurve(new Point2D(10, 0), new Point2D(7.5, 0)) }, topSoilLayerSurfaces[1].GeometrySurface.OuterLoop.CurveList); - var middleLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, middleLayerName)).ToArray(); + SoilLayer2D[] middleLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, middleLayerName)).ToArray(); Assert.That(middleLayerSurfaces.Length, Is.EqualTo(2)); foreach (SoilLayer2D surface in middleLayerSurfaces) { AssertSoilLayerProperties(middleLayer, surface); } + AssertGeometry(new[] { new GeometryCurve(new Point2D(0, 0), new Point2D(2.5, 0)), @@ -567,15 +570,16 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; Assert.That(soilLayer2Ds, Has.Count.EqualTo(5)); - var topSoilLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, topLayerName)).ToArray(); + SoilLayer2D[] topSoilLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, topLayerName)).ToArray(); Assert.That(topSoilLayerSurfaces.Length, Is.EqualTo(2)); foreach (SoilLayer2D surface in topSoilLayerSurfaces) { AssertDikeEmbankmentSoilLayerProperties(soilSurfaceProfile, surface); } + AssertGeometry(new[] { new GeometryCurve(new Point2D(0, 2.5), new Point2D(2.5, 0)), @@ -589,12 +593,13 @@ new GeometryCurve(new Point2D(15, 0), new Point2D(12.5, 0)) }, topSoilLayerSurfaces[1].GeometrySurface.OuterLoop.CurveList); - var middleLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, middleLayerName)).ToArray(); + SoilLayer2D[] middleLayerSurfaces = soilLayer2Ds.Where(l => string.Equals(l.Name, middleLayerName)).ToArray(); Assert.That(middleLayerSurfaces.Length, Is.EqualTo(2)); foreach (SoilLayer2D surface in middleLayerSurfaces) { AssertSoilLayerProperties(middleLayer, surface); } + AssertGeometry(new[] { new GeometryCurve(new Point2D(0, 0), new Point2D(2.5, 0)), @@ -670,7 +675,7 @@ SoilProfile2D soilProfile2D = soilSurfaceProfile.ConvertToSoilProfile2D(); // Assert - var soilLayer2Ds = soilProfile2D.Surfaces; + IList soilLayer2Ds = soilProfile2D.Surfaces; SoilLayer2D topSoilLayer2D = soilLayer2Ds.Single(l => string.Equals(l.Name, topLayerName)); AssertDikeEmbankmentSoilLayerProperties(soilSurfaceProfile, topSoilLayer2D); AssertGeometry(new[] @@ -721,26 +726,26 @@ int nrOfExpectedCurves = expectedCurves.Count(); Assert.That(actualCurves.Count(), Is.EqualTo(nrOfExpectedCurves)); - var actualCurveString = actualCurves.Select(c => string.Format("Coordinate ({0}, {1}) --> ({2}, {3})", c.HeadPoint.X, c.HeadPoint.Z, c.EndPoint.X, c.EndPoint.Z)); + IEnumerable actualCurveString = actualCurves.Select(c => string.Format("Coordinate ({0}, {1}) --> ({2}, {3})", c.HeadPoint.X, c.HeadPoint.Z, c.EndPoint.X, c.EndPoint.Z)); foreach (GeometryCurve expectedCurve in expectedCurves) { Assert.That(actualCurves.Any(c => c.LocationEquals(expectedCurve)), Is.True, - $"Expected curve ({expectedCurve.HeadPoint.X}, {expectedCurve.HeadPoint.Z}) --> ({expectedCurve.EndPoint.X}, {expectedCurve.EndPoint.Z}) not found. " + - $"Actual curves {string.Join(", ", actualCurveString)}"); + $"Expected curve ({expectedCurve.HeadPoint.X}, {expectedCurve.HeadPoint.Z}) --> ({expectedCurve.EndPoint.X}, {expectedCurve.EndPoint.Z}) not found. " + + $"Actual curves {string.Join(", ", actualCurveString)}"); } } - private static void AssertSoilLayerProperties(SoilLayer1D expectedLayer, - SoilLayer2D actualSoilLayer) + private static void AssertSoilLayerProperties(SoilLayer1D expectedLayer, + SoilLayer2D actualSoilLayer) { Assert.That(actualSoilLayer.IsAquifer, Is.EqualTo(expectedLayer.IsAquifer)); Assert.That(actualSoilLayer.WaterpressureInterpolationModel, Is.EqualTo(expectedLayer.WaterpressureInterpolationModel)); Assert.That(actualSoilLayer.Soil, Is.SameAs(expectedLayer.Soil)); } private static void AssertDikeEmbankmentSoilLayerProperties(SoilSurfaceProfile expectedProfile, - SoilLayer2D actualSoilLayer) + SoilLayer2D actualSoilLayer) { Assert.That(actualSoilLayer.IsAquifer, Is.False); Assert.That(actualSoilLayer.WaterpressureInterpolationModel, Is.EqualTo(WaterpressureInterpolationModel.Hydrostatic)); @@ -752,8 +757,8 @@ var random = new Random(soilName.GetHashCode()); Array values = Enum.GetValues(typeof(WaterpressureInterpolationModel)); - var model = (WaterpressureInterpolationModel)values.GetValue(random.Next(values.Length)); - + var model = (WaterpressureInterpolationModel) values.GetValue(random.Next(values.Length)); + return new SoilLayer1D { TopLevel = topLevel, @@ -768,8 +773,8 @@ var surfaceLine = new SurfaceLine2(); surfaceLine.Geometry.Points.AddRange(coordinates); surfaceLine.Geometry.SyncCalcPoints(); - + return surfaceLine; } } -} +} \ No newline at end of file