Beispiel #1
0
        public void Create_CreatingEntityForSameSurfaceLine_ReturnSamenEntity()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            var registry = new PersistenceRegistry();

            // Call
            SurfaceLineEntity entity1 = surfaceLine.Create(registry, 0);
            SurfaceLineEntity entity2 = surfaceLine.Create(registry, 0);

            // Assert
            Assert.AreSame(entity1, entity2);
        }
Beispiel #2
0
        public void Create_HasSurfaceLineSet_EntityHasSurfaceLineEntity()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty)
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(1.1, 2.2)
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(3.3, 6.6, 1.0)
            });

            var registry = new PersistenceRegistry();
            SurfaceLineEntity surfaceLineEntity = surfaceLine.Create(registry, 0);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            // Call
            ProbabilisticPipingCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.AreSame(surfaceLineEntity, entity.SurfaceLineEntity);
        }
Beispiel #3
0
        public void Create_SurfaceLineWithoutGeometry_ReturnSurfaceLineEntityWithoutAddingPointEntities()
        {
            // Setup
            var random      = new Random(31);
            int order       = random.Next();
            var registry    = new PersistenceRegistry();
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, order);

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

            Assert.IsNull(entity.FailureMechanismEntity);
            IEnumerable <Point3D> points = new Point3D[0];
            string expectedXml           = new Point3DCollectionXmlSerializer().ToXml(points);

            Assert.AreEqual(expectedXml, entity.PointsXml);
        }
Beispiel #4
0
        public void Create_SurfaceLineWithCharacteristicPointsOnSameGeometryPoint_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
        {
            // Setup
            var random   = new Random(31);
            var registry = new PersistenceRegistry();
            var geometry = new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble())
            };
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            surfaceLine.SetGeometry(geometry);
            surfaceLine.SetBottomDitchDikeSideAt(geometry[0]);
            surfaceLine.SetBottomDitchPolderSideAt(geometry[0]);
            surfaceLine.SetDikeToeAtPolderAt(geometry[0]);
            surfaceLine.SetDikeToeAtRiverAt(geometry[0]);
            surfaceLine.SetDitchDikeSideAt(geometry[0]);
            surfaceLine.SetDitchPolderSideAt(geometry[0]);

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, 0);

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

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.AreEqual(6, entity.PipingCharacteristicPointEntities.Count);

            CollectionAssert.AreEquivalent(new[]
            {
                (byte)PipingCharacteristicPointType.DikeToeAtRiver,
                (byte)PipingCharacteristicPointType.DikeToeAtPolder,
                (byte)PipingCharacteristicPointType.DitchDikeSide,
                (byte)PipingCharacteristicPointType.BottomDitchDikeSide,
                (byte)PipingCharacteristicPointType.BottomDitchPolderSide,
                (byte)PipingCharacteristicPointType.DitchPolderSide
            }, entity.PipingCharacteristicPointEntities
                                           .Select(cpe => cpe.Type));

            foreach (PipingCharacteristicPointEntity characteristicPointEntity in entity.PipingCharacteristicPointEntities)
            {
                Assert.AreEqual(geometry[0].X, characteristicPointEntity.X);
                Assert.AreEqual(geometry[0].Y, characteristicPointEntity.Y);
                Assert.AreEqual(geometry[0].Z, characteristicPointEntity.Z);
            }
        }
Beispiel #5
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            var registry    = new PersistenceRegistry();
            var surfaceLine = new PipingSurfaceLine("Test");

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, 0);

            // Assert
            TestHelper.AssertAreEqualButNotSame(surfaceLine.Name, entity.Name);
        }
Beispiel #6
0
        public void Create_PersistenceRegistryNull_ThrowArgumentNullException()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            // Call
            TestDelegate call = () => surfaceLine.Create(null, 0);

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

            Assert.AreEqual("registry", exception.ParamName);
        }
Beispiel #7
0
        public void Create_SurfaceLineWithGeometryAndCharacteristicPoints_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
        {
            // Setup
            var registry = new PersistenceRegistry();
            var random   = new Random(31);
            var geometry = new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble())
            };
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            surfaceLine.SetGeometry(geometry);
            const int bottomDitchDikeIndex = 1;

            surfaceLine.SetBottomDitchDikeSideAt(geometry[bottomDitchDikeIndex]);
            const int bottomDitchPolderIndex = 2;

            surfaceLine.SetBottomDitchPolderSideAt(geometry[bottomDitchPolderIndex]);
            const int toePolderIndex = 3;

            surfaceLine.SetDikeToeAtPolderAt(geometry[toePolderIndex]);
            const int toeDikeIndex = 4;

            surfaceLine.SetDikeToeAtRiverAt(geometry[toeDikeIndex]);
            const int ditchDikeIndex = 5;

            surfaceLine.SetDitchDikeSideAt(geometry[ditchDikeIndex]);
            const int ditchPolderIndex = 6;

            surfaceLine.SetDitchPolderSideAt(geometry[ditchPolderIndex]);

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, 0);

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

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.AreEqual(6, entity.PipingCharacteristicPointEntities.Count);
            foreach (PipingCharacteristicPointEntity characteristicPointEntity in entity.PipingCharacteristicPointEntities)
            {
                switch (characteristicPointEntity.Type)
                {
                case (byte)PipingCharacteristicPointType.BottomDitchDikeSide:
                    Assert.AreEqual(geometry[bottomDitchDikeIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[bottomDitchDikeIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[bottomDitchDikeIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.BottomDitchPolderSide:
                    Assert.AreEqual(geometry[bottomDitchPolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[bottomDitchPolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[bottomDitchPolderIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DikeToeAtPolder:
                    Assert.AreEqual(geometry[toePolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[toePolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[toePolderIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DikeToeAtRiver:
                    Assert.AreEqual(geometry[toeDikeIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[toeDikeIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[toeDikeIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DitchDikeSide:
                    Assert.AreEqual(geometry[ditchDikeIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[ditchDikeIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[ditchDikeIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DitchPolderSide:
                    Assert.AreEqual(geometry[ditchPolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[ditchPolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[ditchPolderIndex].Z, characteristicPointEntity.Z);
                    break;

                default:
                    Assert.Fail("Invalid characteristic point type found: {0}", characteristicPointEntity.Type);
                    break;
                }
            }
        }