Example #1
0
        public void TestBool()
        {
            var gv = new GValue();

            gv.SetType(GValue.GBoolType);
            gv.Set(true);
            var value = gv.Get();

            Assert.True(value as bool?);

            gv.Set(false);
            value = gv.Get();
            Assert.False(value as bool?);
        }
Example #2
0
        public void TestString()
        {
            var gv = new GValue();

            gv.SetType(GValue.GStrType);
            gv.Set("banana");
            var value = gv.Get();

            Assert.Equal("banana", value);
        }
Example #3
0
        public void TestDouble()
        {
            var gv = new GValue();

            gv.SetType(GValue.GDoubleType);
            gv.Set(3.1415);
            var value = gv.Get();

            Assert.Equal(3.1415, value);
        }
Example #4
0
        public void TestUint64()
        {
            var gv = new GValue();

            gv.SetType(GValue.GUint64Type);
            gv.Set(ulong.MaxValue);
            var value = gv.Get();

            Assert.Equal(ulong.MaxValue, value);
        }
Example #5
0
        public void TestInt()
        {
            var gv = new GValue();

            gv.SetType(GValue.GIntType);
            gv.Set(12);
            var value = gv.Get();

            Assert.Equal(12, value);
        }
Example #6
0
        public void TestArrayDouble()
        {
            var gv = new GValue();

            gv.SetType(GValue.ArrayDoubleType);
            gv.Set(new[] { 1.1, 2.1, 3.1 });
            var value = gv.Get();

            Assert.Equal(new[] { 1.1, 2.1, 3.1 }, value as IEnumerable);
        }
Example #7
0
        public void TestArrayInt()
        {
            var gv = new GValue();

            gv.SetType(GValue.ArrayIntType);
            gv.Set(new[] { 1, 2, 3 });
            var value = gv.Get();

            Assert.Equal(new[] { 1, 2, 3 }, value as IEnumerable);
        }
Example #8
0
        public void TestBlob()
        {
            var blob = File.ReadAllBytes(Helper.JpegFile);
            var gv   = new GValue();

            gv.SetType(GValue.BlobType);
            gv.Set(blob);
            var value = gv.Get();

            Assert.Equal(blob, value);
        }
Example #9
0
        public void TestImage()
        {
            var image = Image.NewFromFile(Helper.JpegFile);
            var gv    = new GValue();

            gv.SetType(GValue.ImageType);
            gv.Set(image);
            var value = gv.Get();

            Assert.Equal(image, value);
        }
Example #10
0
        public void TestArrayInt()
        {
            int[] actual;
            using (var gv = new GValue())
            {
                gv.SetType(GValue.ArrayIntType);
                gv.Set(new[] { 1, 2, 3 });
                actual = (int[])gv.Get();
            }

            Assert.Equal(new[] { 1, 2, 3 }, actual);
        }
Example #11
0
        public void TestArrayDouble()
        {
            double[] actual;
            using (var gv = new GValue())
            {
                gv.SetType(GValue.ArrayDoubleType);
                gv.Set(new[] { 1.1, 2.1, 3.1 });
                actual = (double[])gv.Get();
            }

            Assert.Equal(new[] { 1.1, 2.1, 3.1 }, actual);
        }
Example #12
0
        public void TestArrayImage()
        {
            var image  = Image.NewFromFile(Helper.JpegFile);
            var values = image.Bandsplit();

            var gv = new GValue();

            gv.SetType(GValue.ArrayImageType);
            gv.Set(values);
            var value = gv.Get();

            Assert.Equal(values, value as IEnumerable);
        }
Example #13
0
        public void TestDouble()
        {
            double actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.GDoubleType);
                gv.Set(3.1415);
                actual = (double)gv.Get();
            }

            Assert.Equal(3.1415, actual);
        }
Example #14
0
        public void TestUint64()
        {
            ulong actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.GUint64Type);
                gv.Set(ulong.MaxValue);
                actual = (ulong)gv.Get();
            }

            Assert.Equal(ulong.MaxValue, actual);
        }
Example #15
0
        public void TestBool()
        {
            bool actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.GBoolType);
                gv.Set(true);
                actual = (bool)gv.Get();
            }

            Assert.True(actual);
        }
Example #16
0
        public void TestInt()
        {
            int actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.GIntType);
                gv.Set(12);
                actual = (int)gv.Get();
            }

            Assert.Equal(12, actual);
        }
Example #17
0
        public void TestRefString()
        {
            string actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.RefStrType);
                gv.Set("banana");
                actual = (string)gv.Get();
            }

            Assert.Equal("banana", actual);
        }
Example #18
0
        public void TestEnum()
        {
            // the Interpretation enum is created when the first image is made --
            // make it ourselves in case we are run before the first image
            NetVips.VipsInterpretationGetType();
            var interpretationGtype = NetVips.TypeFromName("VipsInterpretation");
            var gv = new GValue();

            gv.SetType(interpretationGtype);
            gv.Set("xyz");
            var value = gv.Get();

            Assert.Equal("xyz", value);
        }
Example #19
0
        public void TestFlags()
        {
            // the OperationFlags enum is created when the first op is made --
            // make it ourselves in case we are run before that
            NetVips.VipsOperationFlagsGetType();
            var operationflagsGtype = NetVips.TypeFromName("VipsOperationFlags");
            var gv = new GValue();

            gv.SetType(operationflagsGtype);
            gv.Set(12);
            var value = gv.Get();

            Assert.Equal(12u, value);
        }
Example #20
0
        public void TestBlob()
        {
            var blob = File.ReadAllBytes(Helper.JpegFile);

            byte[] actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.BlobType);
                gv.Set(blob);
                actual = (byte[])gv.Get();
            }

            Assert.Equal(blob, actual);
        }
Example #21
0
        public void TestImage()
        {
            var image = Image.NewFromFile(Helper.JpegFile);

            Image actual;

            using (var gv = new GValue())
            {
                gv.SetType(GValue.ImageType);
                gv.Set(image);
                actual = (Image)gv.Get();
            }


            Assert.Equal(image, actual);
        }
Example #22
0
        public void TestEnum()
        {
            // the Interpretation enum is created when the first image is made --
            // make it ourselves in case we are run before the first image
            NetVips.VipsInterpretationGetType();
            var gtype = NetVips.TypeFromName("VipsInterpretation");

            Enums.Interpretation actual;
            using (var gv = new GValue())
            {
                gv.SetType(gtype);
                gv.Set(Enums.Interpretation.Xyz);
                actual = (Enums.Interpretation)gv.Get();
            }

            Assert.Equal(Enums.Interpretation.Xyz, actual);
        }
Example #23
0
        public void TestFlags()
        {
            // the OperationFlags enum is created when the first op is made --
            // make it ourselves in case we are run before that
            NetVips.VipsOperationFlagsGetType();
            var gtype = NetVips.TypeFromName("VipsOperationFlags");

            Enums.OperationFlags actual;
            using (var gv = new GValue())
            {
                gv.SetType(gtype);
                gv.Set(Enums.OperationFlags.DEPRECATED);
                actual = (Enums.OperationFlags)gv.Get();
            }

            Assert.Equal(Enums.OperationFlags.DEPRECATED, actual);
        }
Example #24
0
        public void TestArrayImage()
        {
            var images = Image.NewFromFile(Helper.JpegFile).Bandsplit();

            Image[] actualImages;
            using (var gv = new GValue())
            {
                gv.SetType(GValue.ArrayImageType);
                gv.Set(images);
                actualImages = (Image[])gv.Get();
            }

            for (var i = 0; i < actualImages.Length; i++)
            {
                var actual   = actualImages[i];
                var expected = images[i];

                Assert.Equal(expected, actual);
            }
        }