Example #1
0
 public void ShouldThrowExceptionWhenStreamIsNotReadable()
 {
     ExceptionAssert.ThrowsArgumentException("stream", () =>
     {
         using (TestStream testStream = new TestStream(false, true, true))
         {
             new MagickImage(testStream);
         }
     });
 }
Example #2
0
 public void ShouldThrowExceptionWhenByteArrayIsEmpty()
 {
     using (IMagickImage image = new MagickImage())
     {
         ExceptionAssert.ThrowsArgumentException("data", () =>
         {
             image.Read(new byte[0]);
         });
     }
 }
Example #3
0
 public void ShouldThrowExceptionWhenWidthIsNegative()
 {
     ExceptionAssert.ThrowsArgumentException("width", () =>
     {
         using (IMagickImage image = new MagickImage())
         {
             image.Read(MagickColors.Red, -1, 1);
         }
     });
 }
Example #4
0
 public void ShouldThrowExceptionWhenHeightIsNegative()
 {
     ExceptionAssert.ThrowsArgumentException("height", () =>
     {
         using (IMagickImage image = new MagickImage())
         {
             image.Read(MagickColors.Red, 1, -1);
         }
     });
 }
Example #5
0
 public void ShouldThrowExceptionWhenCountIsNegative()
 {
     ExceptionAssert.ThrowsArgumentException("count", () =>
     {
         using (IMagickImage image = new MagickImage())
         {
             image.Read(new byte[] { 215 }, 0, -1);
         }
     });
 }
Example #6
0
            public void ShouldThrowExceptionWhenHeightIsNull()
            {
                ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () =>
                {
                    var settings = new PixelStorageSettings(1, 1, StorageType.Char, "RGBA");
                    settings.ReadSettings.Height = null;

                    new MagickImage(Files.CirclePNG, settings);
                }, "Height");
            }
Example #7
0
 public void ShouldThrowExceptionWhenArrayIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("data", () =>
     {
         using (IMagickImage image = new MagickImage())
         {
             image.Ping(new byte[] { });
         }
     });
 }
Example #8
0
 public void ShouldThrowExceptionWhenStreamIsNotReadable()
 {
     using (TestStream stream = new TestStream(false, true, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             StreamWrapper.CreateForReading(stream);
         }, "readable");
     }
 }
Example #9
0
            public void ShouldThrowExceptionWhenMappingIsEmpty()
            {
                ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () =>
                {
                    var settings = new PixelStorageSettings(1, 1, StorageType.Char, string.Empty);

                    MagickFactory factory = new MagickFactory();
                    factory.CreateImage(Files.CirclePNG, settings);
                }, "mapping");
            }
 public void LosslessCompress_StreamCannotSeek_ThrowsException()
 {
     using (TestStream stream = new TestStream(true, true, false))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             Optimizer.LosslessCompress(stream);
         });
     }
 }
Example #11
0
 public void ShouldThrowExceptionWhenFileNameIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("fileName", () =>
     {
         using (IMagickImage image = new MagickImage())
         {
             image.Ping(string.Empty);
         }
     });
 }
Example #12
0
            public void ShouldThrowExceptionWhenByteArrayIsEmptyAndPixelStorageSettingsIsSpecified()
            {
                ExceptionAssert.ThrowsArgumentException("data", () =>
                {
                    var pixelStorageSettings = new PixelStorageSettings();

                    MagickFactory factory = new MagickFactory();
                    factory.CreateImage(new byte[] { }, pixelStorageSettings);
                });
            }
 public void Compress_StreamCannotRead_ThrowsException()
 {
     using (TestStream stream = new TestStream(false, true, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             Optimizer.Compress(stream);
         });
     }
 }
Example #14
0
 public void ShouldThrowExceptionWhenTermsIsEmpty()
 {
     using (IMagickImageCollection images = new MagickImageCollection(Files.Builtin.Logo))
     {
         ExceptionAssert.ThrowsArgumentException("terms", () =>
         {
             images.Polynomial(new double[] { });
         });
     }
 }
Example #15
0
 public void ShouldThrowExceptionWhenImagesIsMagickImageCollection()
 {
     using (var images = new MagickImageCollection(Files.SnakewarePNG))
     {
         ExceptionAssert.ThrowsArgumentException("images", () =>
         {
             new MagickImageCollection(images);
         });
     }
 }
Example #16
0
            public void ShouldThrowExceptionWhenStreamIsEmptyAndPixelStorageSettingsIsSpecified()
            {
                ExceptionAssert.ThrowsArgumentException("stream", () =>
                {
                    var pixelStorageSettings = new PixelStorageSettings();

                    MagickFactory factory = new MagickFactory();
                    factory.CreateImage(new MemoryStream(), pixelStorageSettings);
                });
            }
Example #17
0
 public void ShouldThrowExceptionWhenPercentageHeightIsNegative()
 {
     using (IMagickImage image = new MagickImage(Files.MagickNETIconPNG))
     {
         ExceptionAssert.ThrowsArgumentException("percentageHeight", () =>
         {
             image.LiquidRescale(new Percentage(1), new Percentage(-1), 0.0, 0.0);
         });
     }
 }
Example #18
0
 public void ShouldThrowExceptionWhenByteArrayIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("data", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange(new byte[0]);
         }
     });
 }
 public void ShouldThrowExceptionWhenArgumentsIsEmpty()
 {
     using (IMagickImage image = new MagickImage())
     {
         ExceptionAssert.ThrowsArgumentException("arguments", () =>
         {
             image.Evaluate(Channels.Red, EvaluateFunction.Arcsin, new double[] { });
         });
     }
 }
Example #20
0
 public void ShouldThrowAnExceptionWhenArgumentsIsEmptyAndSettingsIsNot()
 {
     using (IMagickImage image = new MagickImage())
     {
         ExceptionAssert.ThrowsArgumentException("arguments", () =>
         {
             image.Distort(DistortMethod.Perspective, new DistortSettings(), new double[] { });
         });
     }
 }
Example #21
0
 public void ShouldThrowExceptionWhenOffsetIsNegative()
 {
     ExceptionAssert.ThrowsArgumentException("offset", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.Read(new byte[] { 215 }, -1, 0);
         }
     });
 }
Example #22
0
            public void ShouldThrowExceptionWhenNameToSetIsInvalid()
            {
                var document        = new XmlDocument();
                var scriptVariables = new ScriptVariables(document);

                ExceptionAssert.ThrowsArgumentException("name", () =>
                {
                    scriptVariables.Set("invalid", "42");
                }, "Invalid variable name: invalid");
            }
Example #23
0
 public void ShouldThrowExceptionWhenArrayIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("data", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.Read(new byte[] { }, 0, 0);
         }
     });
 }
Example #24
0
 public void ShouldThrowExceptionWhenFileNameIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("fileName", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.Read(string.Empty);
         }
     });
 }
Example #25
0
 public void ShouldThrowExceptionWhenCountIsZero()
 {
     ExceptionAssert.ThrowsArgumentException("count", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.Read(new byte[] { 215 }, 0, 0);
         }
     });
 }
Example #26
0
 public void Constructor_StreamCannotRead_ThrowsException()
 {
     using (TestStream stream = new TestStream(false, true, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             new Bytes(stream);
         });
     }
 }
Example #27
0
                public void ShouldThrowExceptionWhenCountIsNegative()
                {
                    ExceptionAssert.ThrowsArgumentException("count", () =>
                    {
                        var settings = new MagickReadSettings();

                        using (IMagickImageCollection images = new MagickImageCollection(new byte[] { 215 }, 0, -1, settings))
                        {
                        }
                    });
                }
 public void Test_Image_Exceptions()
 {
     ExceptionAssert.ThrowsArgumentException("readSettings", () =>
     {
         MagickReadSettings settings = new MagickReadSettings
         {
             FrameCount = 2,
         };
         new MagickImage(Files.RoseSparkleGIF, settings);
     });
 }
Example #29
0
        public void Test_Read()
        {
            IMagickImageInfo imageInfo = new MagickImageInfo();

            ExceptionAssert.ThrowsArgumentException("data", () =>
            {
                imageInfo.Read(new byte[0]);
            });

            ExceptionAssert.ThrowsArgumentNullException("data", () =>
            {
                imageInfo.Read((byte[])null);
            });

            ExceptionAssert.ThrowsArgumentNullException("file", () =>
            {
                imageInfo.Read((FileInfo)null);
            });

            ExceptionAssert.ThrowsArgumentNullException("stream", () =>
            {
                imageInfo.Read((Stream)null);
            });

            ExceptionAssert.ThrowsArgumentNullException("fileName", () =>
            {
                imageInfo.Read((string)null);
            });

            ExceptionAssert.Throws <MagickBlobErrorException>(() =>
            {
                imageInfo.Read(Files.Missing);
            }, "error/blob.c/OpenBlob");

            imageInfo.Read(File.ReadAllBytes(Files.SnakewarePNG));

            using (FileStream fs = File.OpenRead(Files.SnakewarePNG))
            {
                imageInfo.Read(fs);
            }

            imageInfo.Read(Files.ImageMagickJPG);

            Assert.AreEqual(ColorSpace.sRGB, imageInfo.ColorSpace);
            Assert.AreEqual(CompressionMethod.JPEG, imageInfo.Compression);
            Assert.AreEqual(MagickFormat.Jpeg, imageInfo.Format);
            Assert.AreEqual(118, imageInfo.Height);
            Assert.AreEqual(72, imageInfo.Density.X);
            Assert.AreEqual(72, imageInfo.Density.Y);
            Assert.AreEqual(DensityUnit.PixelsPerInch, imageInfo.Density.Units);
            Assert.AreEqual(Interlace.NoInterlace, imageInfo.Interlace);
            Assert.AreEqual(100, imageInfo.Quality);
            Assert.AreEqual(123, imageInfo.Width);
        }
Example #30
0
            public void ShouldThrowExceptionWhenWidthIsNull()
            {
                ExceptionAssert.ThrowsArgumentException("pixelStorageSettings", () =>
                {
                    var settings = new PixelStorageSettings(1, 1, StorageType.Char, "RGBA");
                    settings.ReadSettings.Width = null;

                    MagickFactory factory = new MagickFactory();
                    factory.CreateImage(Files.CirclePNG, settings);
                }, "Width");
            }