예제 #1
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityWithPointsAndAllCharacteristicPointsSetToSamePoint_ReturnsExpectedSurfaceLine()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var random    = new Random(31);

            Point3D[] points =
            {
                CreatePoint3D(random),
                CreatePoint3D(random)
            };

            var entity = new SurfaceLineEntity
            {
                Name = "Better name.",
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points),
                MacroStabilityInwardsCharacteristicPointEntities =
                {
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeToeAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeTopAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeTopAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.ShoulderBaseInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.ShoulderTopInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DikeToeAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.BottomDitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.BottomDitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.DitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], MacroStabilityInwardsCharacteristicPointType.SurfaceLevelInside)
                }
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.AreEqual(entity.ReferenceLineIntersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.AreEqual(entity.ReferenceLineIntersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            Point3D[] geometry = surfaceLine.Points.ToArray();
            Assert.AreEqual(2, geometry.Length);
            Point3D geometryPoint = geometry[0];

            Assert.AreSame(geometryPoint, surfaceLine.SurfaceLevelOutside);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.DikeTopAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DikeTopAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.ShoulderBaseInside);
            Assert.AreSame(geometryPoint, surfaceLine.ShoulderTopInside);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.DitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.SurfaceLevelInside);
        }
예제 #2
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_WithInvalidMacroStabilityCharacteristicPointType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            var random = new Random(31);

            Point3D[] points =
            {
                CreatePoint3D(random)
            };

            const byte invalidCharacteristicPointType = 37;
            var        entity = new SurfaceLineEntity
            {
                Name = "Better name.",
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points),
                MacroStabilityInwardsCharacteristicPointEntities =
                {
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], (MacroStabilityInwardsCharacteristicPointType)invalidCharacteristicPointType)
                }
            };

            // Call
            TestDelegate call = () => entity.ReadAsMacroStabilityInwardsSurfaceLine(new ReadConversionCollector());

            // Assert
            string exoectedMessage = $"The value of argument 'type' ({invalidCharacteristicPointType}) is invalid for Enum type '{nameof(MacroStabilityInwardsCharacteristicPointType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, exoectedMessage).ParamName;

            Assert.AreEqual("type", parameterName);
        }
예제 #3
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityReadMultipleTimes_ReturnSameSurfaceLine()
        {
            // Setup
            var collector = new ReadConversionCollector();

            var entity = new SurfaceLineEntity
            {
                Name      = "surface line",
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(new Point3D[0])
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine1 = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);
            MacroStabilityInwardsSurfaceLine surfaceLine2 = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreSame(surfaceLine1, surfaceLine2);
        }
예제 #4
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityWithGeometryPointXmlAndCharacteristicPoints_ReturnFullSurfaceLine()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var random    = new Random(31);

            Point3D[] points = Array.ConvertAll(new Point3D[12], p => CreatePoint3D(random));

            var entity = new SurfaceLineEntity
            {
                Name = "Better name.",
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points),
                MacroStabilityInwardsCharacteristicPointEntities =
                {
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[0],  MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[1],  MacroStabilityInwardsCharacteristicPointType.DikeToeAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[2],  MacroStabilityInwardsCharacteristicPointType.DikeTopAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[3],  MacroStabilityInwardsCharacteristicPointType.DikeTopAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[4],  MacroStabilityInwardsCharacteristicPointType.ShoulderBaseInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[5],  MacroStabilityInwardsCharacteristicPointType.ShoulderTopInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[6],  MacroStabilityInwardsCharacteristicPointType.DikeToeAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[7],  MacroStabilityInwardsCharacteristicPointType.DitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[8],  MacroStabilityInwardsCharacteristicPointType.BottomDitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[9],  MacroStabilityInwardsCharacteristicPointType.BottomDitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[10], MacroStabilityInwardsCharacteristicPointType.DitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(points[11], MacroStabilityInwardsCharacteristicPointType.SurfaceLevelInside)
                }
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.AreEqual(entity.ReferenceLineIntersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.AreEqual(entity.ReferenceLineIntersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            CollectionAssert.AreEqual(points, surfaceLine.Points);

            Assert.AreSame(surfaceLine.Points.ElementAt(0), surfaceLine.SurfaceLevelOutside);
            Assert.AreSame(surfaceLine.Points.ElementAt(1), surfaceLine.DikeToeAtRiver);
            Assert.AreSame(surfaceLine.Points.ElementAt(2), surfaceLine.DikeTopAtPolder);
            Assert.AreSame(surfaceLine.Points.ElementAt(3), surfaceLine.DikeTopAtRiver);
            Assert.AreSame(surfaceLine.Points.ElementAt(4), surfaceLine.ShoulderBaseInside);
            Assert.AreSame(surfaceLine.Points.ElementAt(5), surfaceLine.ShoulderTopInside);
            Assert.AreSame(surfaceLine.Points.ElementAt(6), surfaceLine.DikeToeAtPolder);
            Assert.AreSame(surfaceLine.Points.ElementAt(7), surfaceLine.DitchDikeSide);
            Assert.AreSame(surfaceLine.Points.ElementAt(8), surfaceLine.BottomDitchDikeSide);
            Assert.AreSame(surfaceLine.Points.ElementAt(9), surfaceLine.BottomDitchPolderSide);
            Assert.AreSame(surfaceLine.Points.ElementAt(10), surfaceLine.DitchPolderSide);
            Assert.AreSame(surfaceLine.Points.ElementAt(11), surfaceLine.SurfaceLevelInside);
        }
예제 #5
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_WithNullValues_ReturnsMacroStabilityInwardsSurfaceLineWithNaNValues()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var point3D   = new Point3D(double.NaN, double.NaN, double.NaN);
            var entity    = new SurfaceLineEntity
            {
                Name      = "name",
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(new[]
                {
                    point3D
                }),
                MacroStabilityInwardsCharacteristicPointEntities =
                {
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.DikeToeAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.DikeTopAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.DikeTopAtRiver),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.ShoulderBaseInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.ShoulderTopInside),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.DikeToeAtPolder),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.DitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.BottomDitchDikeSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.BottomDitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.DitchPolderSide),
                    CreateMacroStabilityInwardsCharacteristicPointEntity(point3D, MacroStabilityInwardsCharacteristicPointType.SurfaceLevelInside)
                }
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.IsNaN(surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.IsNaN(surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            Point3D geometryPoint = surfaceLine.Points.Single();

            Assert.AreSame(geometryPoint, surfaceLine.SurfaceLevelOutside);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.DikeTopAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DikeTopAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.ShoulderBaseInside);
            Assert.AreSame(geometryPoint, surfaceLine.ShoulderTopInside);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.DitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.SurfaceLevelInside);
        }
예제 #6
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_CollectorNull_ThrowArgumentNullException()
        {
            // Setup
            var entity = new SurfaceLineEntity();

            // Call
            TestDelegate call = () => entity.ReadAsMacroStabilityInwardsSurfaceLine(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("collector", exception.ParamName);
        }
예제 #7
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_PointsXmlEmpty_ThrowsArgumentException()
        {
            var entity = new SurfaceLineEntity
            {
                Name      = "surface line",
                PointsXml = string.Empty
            };

            // Call
            TestDelegate call = () => entity.ReadAsMacroStabilityInwardsSurfaceLine(new ReadConversionCollector());

            // Assert
            string paramName = Assert.Throws <ArgumentException>(call).ParamName;

            Assert.AreEqual("xml", paramName);
        }
예제 #8
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityWithGeometryPointXmlButNoCharacteristicPoints_ReturnSurfaceLineWithGeometry()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var random    = new Random(31);

            Point3D[] points =
            {
                CreatePoint3D(random),
                CreatePoint3D(random),
                CreatePoint3D(random)
            };

            var entity = new SurfaceLineEntity
            {
                Name = nameof(SurfaceLineEntity),
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points)
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.AreEqual(entity.ReferenceLineIntersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.AreEqual(entity.ReferenceLineIntersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            CollectionAssert.AreEqual(points, surfaceLine.Points);

            Assert.IsNull(surfaceLine.SurfaceLevelOutside);
            Assert.IsNull(surfaceLine.DikeToeAtRiver);
            Assert.IsNull(surfaceLine.DikeTopAtPolder);
            Assert.IsNull(surfaceLine.DikeTopAtRiver);
            Assert.IsNull(surfaceLine.ShoulderBaseInside);
            Assert.IsNull(surfaceLine.ShoulderTopInside);
            Assert.IsNull(surfaceLine.DikeToeAtPolder);
            Assert.IsNull(surfaceLine.DitchDikeSide);
            Assert.IsNull(surfaceLine.BottomDitchDikeSide);
            Assert.IsNull(surfaceLine.BottomDitchPolderSide);
            Assert.IsNull(surfaceLine.DitchPolderSide);
            Assert.IsNull(surfaceLine.SurfaceLevelInside);
        }