Exemple #1
0
        public void PerceptibleReciprocal_NegativeNan_ReturnsPositiveInfinity()
        {
            var script = new UnperspectiveScript();

            Type       type   = script.GetType();
            MethodInfo method = type.GetMethod("PerceptibleReciprocal", BindingFlags.Static | BindingFlags.NonPublic);

            var result = method.Invoke(null, new object[] { -double.NaN });

            Assert.AreEqual(result, double.PositiveInfinity);
        }
Exemple #2
0
        private static void GetRotation_Geometry10x10_ReturnsCorrectRotation(int x, int y, UnperspectiveRotation expectedRotation)
        {
            var script = new UnperspectiveScript();

            Type       type   = script.GetType();
            MethodInfo method = type.GetMethod("GetRotation", BindingFlags.Instance | BindingFlags.NonPublic);

            using (MagickImage image = new MagickImage(MagickColors.Fuchsia, 10, 10))
            {
                var result = method.Invoke(script, new object[] { new PointD[] { new PointD(x, y) }, image });
                Assert.AreEqual(expectedRotation, result);
            }
        }
Exemple #3
0
        private static void GetCoefficients_UnsolvableMatrix_ThrowsException(double[] arguments)
        {
            var script = new UnperspectiveScript();

            Type       type   = script.GetType();
            MethodInfo method = type.GetMethod("GetCoefficients", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(double[]) }, null);

            ExceptionAssert.Throws <InvalidOperationException>("Unsolvable matrix detected.", () =>
            {
                try
                {
                    method.Invoke(null, new object[] { arguments });
                }
                catch (TargetInvocationException ex)
                {
                    throw ex.InnerException;
                }
            });
        }
Exemple #4
0
        private static MagickGeometry GetDimensions(UnperspectiveDefault value)
        {
            var script = new UnperspectiveScript();

            script.AspectRatio = 1.5;
            script.Default     = value;

            Type       type   = script.GetType();
            MethodInfo method = type.GetMethod("GetDimensions", BindingFlags.Instance | BindingFlags.NonPublic);

            PointD[] corners = new PointD[4]
            {
                new PointD(0, 0),
                new PointD(300, 600),
                new PointD(10, 10),
                new PointD(290, 490)
            };
            MagickGeometry inputDimensions   = new MagickGeometry(1000, 1000);
            MagickGeometry trimmedDimensions = new MagickGeometry(800, 800);

            return((MagickGeometry)method.Invoke(script, new object[] { null, corners, inputDimensions, trimmedDimensions }));
        }