Пример #1
0
        public void Transform_SurfaceLineIntersectsReferenceLineMultipleTimes_ThrowsImportedDataTransformException()
        {
            // Setup
            var referenceLine = new ReferenceLine();
            var transformer   = new MacroStabilityInwardsSurfaceLineTransformer(referenceLine);

            const string surfaceLineName = "somewhere";
            var          surfaceLine     = new SurfaceLine
            {
                Name = surfaceLineName
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1.0, 5.0, 2.1),
                new Point3D(1.0, 3.0, 2.1)
            });
            referenceLine.SetGeometry(new[]
            {
                new Point2D(0.0, 5.0),
                new Point2D(2.0, 4.0),
                new Point2D(0.0, 3.0)
            });

            // Call
            TestDelegate test = () => transformer.Transform(surfaceLine, null);

            // Assert
            string message   = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd.";
            var    exception = Assert.Throws <ImportedDataTransformException>(test);

            Assert.AreEqual(message, exception.Message);
        }
Пример #2
0
        public void Transform_WithoutCharacteristicPoints_ThrowsImportedDataTransformException()
        {
            // Setup
            var          referenceLine = new ReferenceLine();
            var          transformer   = new MacroStabilityInwardsSurfaceLineTransformer(referenceLine);
            const string locationName  = "a location";

            var    random  = new Random(21);
            double randomZ = random.NextDouble();

            var surfaceLine = new SurfaceLine
            {
                Name = locationName
            };

            var point1 = new Point3D(3.5, 4.8, randomZ);
            var point2 = new Point3D(7.2, 9.3, randomZ);
            var point3 = new Point3D(12.0, 5.6, randomZ);

            surfaceLine.SetGeometry(new[]
            {
                point1,
                point2,
                point3
            });

            referenceLine.SetGeometry(new[]
            {
                new Point2D(5.6, 2.5),
                new Point2D(6.8, 15)
            });

            MacroStabilityInwardsSurfaceLine result = null;

            // Call
            TestDelegate test = () => result = transformer.Transform(surfaceLine, null);

            // Assert
            string message   = $"Karakteristieke punten definitie voor profielschematisatie '{locationName}' is verplicht.";
            var    exception = Assert.Throws <ImportedDataTransformException>(test);

            Assert.AreEqual(message, exception.Message);
            Assert.IsNull(result);
        }
Пример #3
0
        public void Transform_MandatoryCharacteristicPointNotOnSurfaceLine_ThrowsImportedDataTransformException(
            Action <CharacteristicPoints, Point3D> pointChange,
            Func <MacroStabilityInwardsSurfaceLine, Point3D> pointWhichIsNull,
            string changedCharacteristicPointName)
        {
            // Setup
            var          referenceLine = new ReferenceLine();
            var          transformer   = new MacroStabilityInwardsSurfaceLineTransformer(referenceLine);
            const string locationName  = "a location";

            var    random  = new Random(21);
            double randomZ = random.NextDouble();

            var surfaceLine = new SurfaceLine
            {
                Name = locationName
            };

            var point1 = new Point3D(3.5, 4.8, randomZ);
            var point2 = new Point3D(7.2, 9.3, randomZ);
            var point3 = new Point3D(12.0, 5.6, randomZ);
            var notOnSurfaceLinePoint = new Point3D(7.3, 9.3, randomZ);

            surfaceLine.SetGeometry(new[]
            {
                point1,
                point2,
                point3
            });

            var characteristicPoints = new CharacteristicPoints(locationName)
            {
                SurfaceLevelOutside   = point2,
                DikeToeAtRiver        = point2,
                DikeTopAtPolder       = point2,
                DikeTopAtRiver        = point2,
                ShoulderBaseInside    = point3,
                ShoulderTopInside     = point3,
                BottomDitchDikeSide   = point3,
                BottomDitchPolderSide = point3,
                DitchPolderSide       = point3,
                DitchDikeSide         = point3,
                DikeToeAtPolder       = point3,
                SurfaceLevelInside    = point3
            };

            pointChange(characteristicPoints, notOnSurfaceLinePoint);

            referenceLine.SetGeometry(new[]
            {
                new Point2D(5.6, 2.5),
                new Point2D(6.8, 15)
            });

            // Call
            TestDelegate test = () => transformer.Transform(surfaceLine, characteristicPoints);

            // Assert
            var    exception = Assert.Throws <ImportedDataTransformException>(test);
            string message   = $"Profielschematisatie '{locationName}' kan niet gebruikt worden. " +
                               $"De geometrie bevat geen punt op locatie {notOnSurfaceLinePoint} om als \'{changedCharacteristicPointName}\' in te stellen. " +
                               "Dit karakteristieke punt is verplicht.";

            Assert.AreEqual(message, exception.Message);
        }
Пример #4
0
        public void Transform_OptionalCharacteristicPointNotOnSurfaceLine_LogErrorAndReturnSurfaceLineWithoutCharacteristicPointSet(
            Action <CharacteristicPoints, Point3D> pointChange,
            Func <MacroStabilityInwardsSurfaceLine, Point3D> pointWhichIsNull,
            string changedCharacteristicPointName)
        {
            // Setup
            var          referenceLine = new ReferenceLine();
            var          transformer   = new MacroStabilityInwardsSurfaceLineTransformer(referenceLine);
            const string locationName  = "a location";

            var    random  = new Random(21);
            double randomZ = random.NextDouble();

            var surfaceLine = new SurfaceLine
            {
                Name = locationName
            };

            var point1 = new Point3D(3.5, 4.8, randomZ);
            var point2 = new Point3D(7.2, 9.3, randomZ);
            var point3 = new Point3D(12.0, 5.6, randomZ);
            var notOnSurfaceLinePoint = new Point3D(7.3, 9.3, randomZ);

            surfaceLine.SetGeometry(new[]
            {
                point1,
                point2,
                point3
            });

            var characteristicPoints = new CharacteristicPoints(locationName)
            {
                SurfaceLevelOutside   = point2,
                DikeToeAtRiver        = point2,
                DikeTopAtPolder       = point2,
                DikeTopAtRiver        = point2,
                ShoulderBaseInside    = point3,
                ShoulderTopInside     = point3,
                BottomDitchDikeSide   = point3,
                BottomDitchPolderSide = point3,
                DitchPolderSide       = point3,
                DitchDikeSide         = point3,
                DikeToeAtPolder       = point3,
                SurfaceLevelInside    = point3
            };

            pointChange(characteristicPoints, notOnSurfaceLinePoint);

            referenceLine.SetGeometry(new[]
            {
                new Point2D(5.6, 2.5),
                new Point2D(6.8, 15)
            });

            MacroStabilityInwardsSurfaceLine result = null;

            // Call
            Action call = () => result = transformer.Transform(surfaceLine, characteristicPoints);

            // Assert
            string message = $"Karakteristiek punt van profielschematisatie '{locationName}' is overgeslagen. De geometrie bevat geen punt op locatie {notOnSurfaceLinePoint} om als '{changedCharacteristicPointName}' in te stellen.";

            TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error));
            CollectionAssert.AreEqual(new[]
            {
                point1,
                point2,
                point3
            }, result.Points);
            Assert.IsNull(pointWhichIsNull(result));
            Assert.AreEqual(1, new Collection <Point3D>
            {
                result.SurfaceLevelOutside,
                result.DikeToeAtRiver,
                result.DikeTopAtPolder,
                result.ShoulderBaseInside,
                result.ShoulderTopInside,
                result.BottomDitchDikeSide,
                result.BottomDitchPolderSide,
                result.DitchPolderSide,
                result.DitchDikeSide,
                result.DikeToeAtPolder,
                result.SurfaceLevelInside
            }.Count(p => p == null));
        }