Пример #1
0
        public void GetZAtL_SurfaceLineVerticalAtL_ThrowsMechanismSurfaceLineException()
        {
            // Setup
            double testZ = new Random(22).NextDouble();

            var surfaceLine = new TestMechanismSurfaceLine();
            var l           = (RoundedDouble)2.0;

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 2.2),
                new Point3D(l, 0.0, testZ),
                new Point3D(l, 0.0, testZ + 1),
                new Point3D(3.0, 0.0, 7.7)
            });

            // Call
            TestDelegate test = () => surfaceLine.GetZAtL(l);

            // Assert
            var    exception = Assert.Throws <MechanismSurfaceLineException>(test);
            string message   = $"Kan geen hoogte bepalen op het punt met de lokale coördinaat {l}, omdat de profielschematisatie verticaal loopt op dat punt.";

            Assert.AreEqual(message, exception.Message);
        }
Пример #2
0
        public void GetLocalPointFromGeometry_NoPointsOnSurfaceLine_ReturnsPointWithNaNValues()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            // Call
            Point2D localPoint = surfaceLine.GetLocalPointFromGeometry(new Point3D(1.0, 2.2, 4.4));

            // Assert
            Assert.AreEqual(new Point2D(double.NaN, double.NaN), localPoint);
        }
Пример #3
0
        private static void CreateTestGeometry(Point3D testPoint, TestMechanismSurfaceLine surfaceLine)
        {
            var random = new Random(21);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(testPoint),
                new Point3D(2 + random.NextDouble(), random.NextDouble(), random.NextDouble())
            });
        }
Пример #4
0
        public void ToString_ReturnName()
        {
            // Setup
            const string niceName    = "Nice name";
            var          surfaceLine = new TestMechanismSurfaceLine(niceName);

            // Call
            string text = surfaceLine.ToString();

            // Assert
            Assert.AreEqual(niceName, text);
        }
Пример #5
0
        public void DefaultConstructor_ExpectedValues()
        {
            // Call
            var surfaceLine = new TestMechanismSurfaceLine();

            // Assert
            Assert.IsInstanceOf <Observable>(surfaceLine);
            Assert.IsEmpty(surfaceLine.Name);
            CollectionAssert.IsEmpty(surfaceLine.Points);
            Assert.IsNull(surfaceLine.StartingWorldPoint);
            Assert.IsNull(surfaceLine.EndingWorldPoint);
            Assert.IsNull(surfaceLine.ReferenceLineIntersectionWorldPoint);
        }
Пример #6
0
        public void SetGeometry_GeometryIsNull_ThrowsArgumentNullException()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            // Call
            TestDelegate test = () => surfaceLine.SetGeometry(null);

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

            StringAssert.StartsWith("De geometrie die opgegeven werd voor de profielschematisatie heeft geen waarde.", exception.Message);
        }
Пример #7
0
        public void ReferenceLineIntersectionWorldPoint_SetNewValue_GetNewlySetValue()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            var point = new Point2D(1.2, 3.4);

            // Call
            surfaceLine.ReferenceLineIntersectionWorldPoint = point;

            // Assert
            Assert.AreEqual(point, surfaceLine.ReferenceLineIntersectionWorldPoint);
        }
Пример #8
0
        public void GetZAtL_GeometryIsEmpty_ThrowsInvalidOperationException()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();
            var l           = (RoundedDouble) new Random(21).NextDouble();

            // Call
            TestDelegate test = () => surfaceLine.GetZAtL(l);

            // Assert
            string exceptionMessage = Assert.Throws <InvalidOperationException>(test).Message;

            Assert.AreEqual("De profielschematisatie heeft geen geometrie.", exceptionMessage);
        }
Пример #9
0
        public void SetGeometry_EmptyCollection_PointsSetEmptyAndNullStartAndEndWorldPoints()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            IEnumerable <Point3D> sourceData = Enumerable.Empty <Point3D>();

            // Call
            surfaceLine.SetGeometry(sourceData);

            // Assert
            CollectionAssert.IsEmpty(surfaceLine.Points);
            Assert.IsNull(surfaceLine.StartingWorldPoint);
            Assert.IsNull(surfaceLine.EndingWorldPoint);
        }
Пример #10
0
        public void SetGeometry_GeometryContainsNullPoint_ThrowsArgumentException()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            // Call
            TestDelegate test = () => surfaceLine.SetGeometry(new Point3D[]
            {
                null
            });

            // Assert
            var exception = Assert.Throws <ArgumentException>(test);

            StringAssert.StartsWith("Een punt in de geometrie voor de profielschematisatie heeft geen waarde.", exception.Message);
        }
Пример #11
0
        public void GetLocalPointFromGeometry_ValidSurfaceLine_ReturnsLocalPoint()
        {
            // Setup
            const double testX       = 1.0;
            const double testY       = 2.2;
            const double testZ       = 4.4;
            var          testPoint   = new Point3D(testX, testY, testZ);
            var          surfaceLine = new TestMechanismSurfaceLine();

            CreateTestGeometry(testPoint, surfaceLine);

            // Call
            Point2D localPoint = surfaceLine.GetLocalPointFromGeometry(testPoint);

            // Assert
            Assert.AreEqual(new Point2D(0.04, 4.4), localPoint);
        }
Пример #12
0
        public void ValidateInRange_PointInRange_ReturnsTrue(double validValue)
        {
            // Setup
            const double testX       = 1.0;
            const double testY       = 2.2;
            const double testZ       = 4.4;
            var          testPoint   = new Point3D(testX, testY, testZ);
            var          surfaceLine = new TestMechanismSurfaceLine();

            CreateTestGeometry(testPoint, surfaceLine);

            // Call
            bool valid = surfaceLine.ValidateInRange(validValue);

            // Assert
            Assert.IsTrue(valid);
        }
Пример #13
0
        public void SetGeometry_CollectionOfOnePoint_InitializeStartAndEndWorldPointsToSameInstanceAndInitializePoints()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            var sourceData = new[]
            {
                new Point3D(1.1, 2.2, 3.3)
            };

            // Call
            surfaceLine.SetGeometry(sourceData);

            // Assert
            Assert.AreNotSame(sourceData, surfaceLine.Points);
            CollectionAssert.AreEqual(sourceData, surfaceLine.Points);
            TestHelper.AssertAreEqualButNotSame(sourceData[0], surfaceLine.StartingWorldPoint);
            TestHelper.AssertAreEqualButNotSame(sourceData[0], surfaceLine.EndingWorldPoint);
        }
Пример #14
0
        public void GetLocalPointFromGeometry_OnePointOnSurfaceLine_ReturnsPointWithNaNValues()
        {
            // Setup
            const double testX       = 1.0;
            const double testY       = 2.2;
            const double testZ       = 4.4;
            var          testPoint   = new Point3D(testX, testY, testZ);
            var          surfaceLine = new TestMechanismSurfaceLine();

            surfaceLine.SetGeometry(new[]
            {
                testPoint
            });

            // Call
            Point2D localPoint = surfaceLine.GetLocalPointFromGeometry(testPoint);

            // Assert
            Assert.AreEqual(new Point2D(double.NaN, double.NaN), localPoint);
        }
Пример #15
0
        public void GetZAtL_SurfaceLineContainsPointAtL_ReturnsZOfPoint()
        {
            // Setup
            double testZ = new Random(22).NextDouble();

            var surfaceLine = new TestMechanismSurfaceLine();
            var l           = (RoundedDouble)2.0;

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 2.2),
                new Point3D(l, 0.0, testZ),
                new Point3D(3.0, 0.0, 7.7)
            });

            // Call
            double result = surfaceLine.GetZAtL(l);

            // Assert
            Assert.AreEqual(testZ, result, 1e-2);
        }
Пример #16
0
        public void SetGeometry_CollectionOfMultiplePoints_InitializeStartAndEndWorldPointsInitializePoints()
        {
            // Setup
            var surfaceLine = new TestMechanismSurfaceLine();

            var sourceData = new[]
            {
                new Point3D(1.1, 2.2, 3.3),
                new Point3D(4.4, 5.5, 6.6),
                new Point3D(7.7, 8.8, 9.9),
                new Point3D(10.10, 11.11, 12.12)
            };

            // Call
            surfaceLine.SetGeometry(sourceData);

            // Assert
            Assert.AreNotSame(sourceData, surfaceLine.Points);
            CollectionAssert.AreEqual(sourceData, surfaceLine.Points);
            Assert.AreEqual(sourceData[0], surfaceLine.StartingWorldPoint);
            Assert.AreEqual(sourceData[3], surfaceLine.EndingWorldPoint);
        }
Пример #17
0
        public void GetZAtL_SurfaceLineDoesNotContainsPointAtL_ThrowsArgumentOutOfRangeException(double l)
        {
            // Setup
            double testZ = new Random(22).NextDouble();

            var surfaceLine = new TestMechanismSurfaceLine();

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1.0, 0.0, 2.2),
                new Point3D(2.0, 0.0, testZ),
                new Point3D(4.1, 0.0, 7.7)
            });

            // Call
            TestDelegate test = () => surfaceLine.GetZAtL((RoundedDouble)l);

            // Assert
            const string expectedMessage = "Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [0,0, 3,1] liggen.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(test, expectedMessage);
        }