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

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

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 4.0, 2.1),
                new Point3D(3.0, 5.0, 2.1)
            });
            referenceLine.SetGeometry(new[]
            {
                new Point2D(2.0, 4.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. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft.";
            var    exception = Assert.Throws <ImportedDataTransformException>(test);

            Assert.AreEqual(message, exception.Message);
        }
Пример #2
0
        public void Transform_WithoutCharacteristicPoints_ReturnsSurfaceLineWithoutCharacteristicPointsSet()
        {
            // Setup
            var referenceLine = new ReferenceLine();
            var transformer   = new PipingSurfaceLineTransformer(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, 4.0),
                new Point2D(2.0, 4.0)
            });

            // Call
            PipingSurfaceLine result = transformer.Transform(surfaceLine, null);

            // Assert
            Assert.IsNull(result.DitchDikeSide);
            Assert.IsNull(result.BottomDitchDikeSide);
            Assert.IsNull(result.BottomDitchPolderSide);
            Assert.IsNull(result.DitchPolderSide);
            Assert.IsNull(result.DikeToeAtPolder);
            Assert.IsNull(result.DikeToeAtRiver);
        }
Пример #3
0
        public void Transform_DikeToePolderOnOrBeforeDikeToeRiver_ThrowsImportedDataTransformException(double xDikeToePolder)
        {
            // Setup
            var          referenceLine = new ReferenceLine();
            var          transformer   = new PipingSurfaceLineTransformer(referenceLine);
            const string locationName  = "a location";

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

            var surfaceLine = new SurfaceLine();

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(2.0, randomY, randomZ),
                new Point3D(3.0, randomY, randomZ),
                new Point3D(3.5, randomY, randomZ),
                new Point3D(4.0, randomY, randomZ)
            });
            var characteristicPoints = new CharacteristicPoints(locationName)
            {
                DikeToeAtRiver  = new Point3D(3.5, 4, randomZ),
                DikeToeAtPolder = new Point3D(xDikeToePolder, 4, randomZ)
            };

            referenceLine.SetGeometry(new[]
            {
                new Point2D(3.2, randomY - 1),
                new Point2D(3.2, randomY + 1)
            });

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

            // Assert
            string message   = $"Het uittredepunt moet landwaarts van het intredepunt liggen voor locatie '{locationName}'.";
            var    exception = Assert.Throws <ImportedDataTransformException>(test);

            Assert.AreEqual(message, exception.Message);
        }
Пример #4
0
        public void Transform_CharacteristicPointNotOnSurfaceLine_LogErrorAndReturnSurfaceLineWithoutCharacteristicPointSet(Action <CharacteristicPoints, Point3D> pointChange, Func <PipingSurfaceLine, Point3D> pointWhichIsNull, string changedCharacteristicPointName)
        {
            // Setup
            var          referenceLine = new ReferenceLine();
            var          transformer   = new PipingSurfaceLineTransformer(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)
            {
                DikeToeAtRiver        = point2,
                BottomDitchDikeSide   = point2,
                BottomDitchPolderSide = point2,
                DitchPolderSide       = point2,
                DitchDikeSide         = point3,
                DikeToeAtPolder       = point3
            };

            pointChange(characteristicPoints, notOnSurfaceLinePoint);

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

            PipingSurfaceLine 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.DikeToeAtRiver,
                result.BottomDitchDikeSide,
                result.BottomDitchPolderSide,
                result.DitchPolderSide,
                result.DitchDikeSide,
                result.DikeToeAtPolder
            }.Count(p => p == null));
        }