예제 #1
0
 public void Initialize_WithPathAndConfigurationFilesIsNull_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentNullException("configFiles", () =>
     {
         MagickNET.Initialize(null, Path.GetTempPath());
     });
 }
예제 #2
0
                public void ShouldThrowExceptionWhenXmlFileIsMissing()
                {
                    string path = Files.Root + @"../../src/Magick.Native/resources/Release";

#if Q8
                    path += "Q8";
#elif Q16
                    path += "Q16";
#else
                    path += "Q16-HDRI";
#endif

                    foreach (string fileName in Directory.GetFiles(path, "*.xml"))
                    {
                        string tempFile = fileName + ".tmp";

                        Cleanup.DeleteFile(tempFile);

                        File.Move(fileName, tempFile);

                        try
                        {
                            var exception = Assert.Throws <ArgumentException>("path", () =>
                            {
                                MagickNET.Initialize(path);
                            });

                            Assert.Contains("Unable to find file: " + Path.GetFullPath(fileName), exception.Message);
                        }
                        finally
                        {
                            File.Move(tempFile, fileName);
                        }
                    }
                }
예제 #3
0
 public void ShouldThrowExceptionWhenPathIsInvalid()
 {
     ExceptionAssert.Throws <ArgumentException>("path", () =>
     {
         MagickNET.Initialize(ConfigurationFiles.Default, "invalid");
     }, "Unable to find directory");
 }
예제 #4
0
        public void Initialize_XmlFileIsMissing_ThrowsException()
        {
            string path = Files.Root + @"../../src/Magick.Native/resources/Release";

#if Q8
            path += "Q8";
#elif Q16
            path += "Q16";
#elif Q16HDRI
            path += "Q16-HDRI";
#else
#error Not implemented!
#endif

            foreach (string fileName in Directory.GetFiles(path, "*.xml"))
            {
                string tempFile = fileName + ".tmp";

                Cleanup.DeleteFile(tempFile);

                File.Move(fileName, tempFile);

                try
                {
                    ExceptionAssert.Throws <ArgumentException>("path", () =>
                    {
                        MagickNET.Initialize(path);
                    }, "Unable to find file: " + Path.GetFullPath(fileName));
                }
                finally
                {
                    File.Move(tempFile, fileName);
                }
            }
        }
예제 #5
0
 public void ShouldThrowExceptionWhenConfigurationFilesIsNull()
 {
     ExceptionAssert.Throws <ArgumentNullException>("configFiles", () =>
     {
         MagickNET.Initialize((ConfigurationFiles)null);
     });
 }
예제 #6
0
 public void Initialize_PathIsInvalid_ThrowsException()
 {
     ExceptionAssert.Throws <ArgumentException>(delegate()
     {
         MagickNET.Initialize("Invalid");
     });
 }
예제 #7
0
 public void Initialize_PathIsNull_ThrowsException()
 {
     ExceptionAssert.Throws <ArgumentNullException>(delegate()
     {
         MagickNET.Initialize(null);
     });
 }
예제 #8
0
        public static bool Initialize()
        {
            Ghostscript.Initialize();

            var configFiles = ConfigurationFiles.Default;

            configFiles.Policy.Data = ModifyPolicy(configFiles.Policy.Data);
            configFiles.Type.Data   = CreateTypeData();

            var path = Path.Combine(Path.GetTempPath(), "Magick.NET.Tests");

            Cleanup.DeleteDirectory(path);
            Directory.CreateDirectory(path);

            MagickNET.Initialize(configFiles, path);

            // OpenCL should be disabled by default this is a hack to check that.
            if (OpenCL.IsEnabled)
            {
                return(false);
            }

            OpenCL.IsEnabled = true;

            return(true);
        }
예제 #9
0
        public ImageMagickConfiguration()
        {
            ConfigurationFiles configFiles = ConfigurationFiles.Default;

            configFiles.Policy.Data = @"
           <policymap>
              <policy domain=""resource"" name=""temporary-path"" value=""/tmp""/>
              <policy domain=""resource"" name=""memory"" value=""2GiB""/> 
              <policy domain=""resource"" name=""map"" value=""4GiB""/> 
              <policy domain=""resource"" name=""area"" value=""1GB""/>
              <policy domain=""resource"" name=""disk"" value=""16EB""/>
              <policy domain=""resource"" name=""file"" value=""768""/>
              <policy domain=""resource"" name=""thread"" value=""4""/>
              <policy domain=""resource"" name=""throttle"" value=""0""/>
              <policy domain=""resource"" name=""time"" value=""unlimited""/> 
              <policy domain=""system"" name=""precision"" value=""6""/>
              <policy domain=""cache"" name=""shared-secret"" value=""passphrase""/>
              <policy domain=""coder"" rights=""none"" pattern=""EPHEMERAL"" />
              <policy domain=""coder"" rights=""none"" pattern=""URL"" />
              <policy domain=""coder"" rights=""none"" pattern=""HTTPS"" />
              <policy domain=""coder"" rights=""none"" pattern=""MVG"" />
              <policy domain=""coder"" rights=""none"" pattern=""MSL"" />
              <policy domain=""coder"" rights=""none"" pattern=""TEXT"" />
              <policy domain=""coder"" rights=""none"" pattern=""SHOW"" />
              <policy domain=""coder"" rights=""none"" pattern=""WIN"" />
              <policy domain=""coder"" rights=""none"" pattern=""PLT"" />
              <policy domain=""path"" rights=""none"" pattern=""@*"" />
            </policymap>
            ";
            MagickNET.Initialize(configFiles, TemporaryImagesFilePath);
        }
예제 #10
0
 public void Initialize_WithPathAndPathIsNull_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentNullException("path", () =>
     {
         MagickNET.Initialize(ConfigurationFiles.Default, null);
     });
 }
예제 #11
0
 public void Initialize_ConfigurationFilesIsNull_ThrowsException()
 {
     ExceptionAssert.Throws <ArgumentNullException>(delegate()
     {
         MagickNET.Initialize((ConfigurationFiles)null);
     });
 }
예제 #12
0
 public void ShouldThrowExceptionWhenConfigurationFilesIsNull()
 {
     Assert.Throws <ArgumentNullException>("configFiles", () =>
     {
         MagickNET.Initialize(null, Path.GetTempPath());
     });
 }
예제 #13
0
 public void Initialize_PathIsNull_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentNullException("path", () =>
     {
         MagickNET.Initialize((string)null);
     });
 }
예제 #14
0
 public void Initialize_PathIsInvalid_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentException("path", () =>
     {
         MagickNET.Initialize("Invalid");
     });
 }
예제 #15
0
 public void ShouldThrowExceptionWhenPathIsNull()
 {
     Assert.Throws <ArgumentNullException>("path", () =>
     {
         MagickNET.Initialize(ConfigurationFiles.Default, null);
     });
 }
예제 #16
0
 public void Initialize_WithPathAndPathIsInvalid_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentException("path", () =>
     {
         MagickNET.Initialize(ConfigurationFiles.Default, "invalid");
     }, "Unable to find directory");
 }
예제 #17
0
 public void ShouldThrowExceptionWhenPathIsNull()
 {
     Assert.Throws <ArgumentNullException>("path", () =>
     {
         MagickNET.Initialize((string)null);
     });
 }
예제 #18
0
 public void ShouldThrowExceptionWhenPathIsInvalid()
 {
     Assert.Throws <ArgumentException>("path", () =>
     {
         MagickNET.Initialize("Invalid");
     });
 }
예제 #19
0
        public void Test_Initialize()
        {
            ExceptionAssert.Throws <ArgumentNullException>(delegate()
            {
                MagickNET.Initialize(null);
            });

            ExceptionAssert.Throws <ArgumentException>(delegate()
            {
                MagickNET.Initialize("Invalid");
            });

            string path = Files.Root + @"..\..\Source\Magick.NET.Native\Resources\xml";

            foreach (string fileName in Directory.GetFiles(path, "*.xml"))
            {
                string tempFile = fileName + ".tmp";

                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }

                File.Move(fileName, tempFile);

                ExceptionAssert.Throws <ArgumentException>(delegate()
                {
                    MagickNET.Initialize(path);
                }, "MagickNET._ImageMagickFiles does not contain: " + Path.GetFileName(fileName));

                File.Move(tempFile, fileName);
            }
        }
예제 #20
0
 public void Initialize_ConfigurationFilesIsNull_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentNullException("configFiles", () =>
     {
         MagickNET.Initialize((ConfigurationFiles)null);
     });
 }
예제 #21
0
        public void Initialize_XmlFileIsMissing_ThrowsException()
        {
            string path = Files.Root + @"../../Source/Magick.NET.Native/Resources/xml";

            foreach (string fileName in Directory.GetFiles(path, "*.xml"))
            {
                string tempFile = fileName + ".tmp";

                Cleanup.DeleteFile(tempFile);

                File.Move(fileName, tempFile);

                try
                {
                    ExceptionAssert.ThrowsArgumentException("path", () =>
                    {
                        MagickNET.Initialize(path);
                    }, "Unable to find file: " + Path.GetFullPath(fileName));
                }
                finally
                {
                    File.Move(tempFile, fileName);
                }
            }
        }
예제 #22
0
        public ImageMagickConfiguration(string policyMap, string temporaryImagesFilePath)
        {
            ConfigurationFiles configFiles = ConfigurationFiles.Default;

            configFiles.Policy.Data = policyMap;
            TemporaryImagesFilePath = temporaryImagesFilePath;
            MagickNET.Initialize(configFiles, TemporaryImagesFilePath);
        }
예제 #23
0
        public void Initialize_WithPathAndPathIsNull_ThrowsException()
        {
            ArgumentNullException exception = ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                MagickNET.Initialize(ConfigurationFiles.Default, null);
            });

            Assert.AreEqual("path", exception.ParamName);
        }
예제 #24
0
        public void Initialize_WithPathAndConfigurationFilesIsNull_ThrowsException()
        {
            ArgumentNullException exception = ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                MagickNET.Initialize(null, Path.GetTempPath());
            });

            Assert.AreEqual("configFiles", exception.ParamName);
        }
예제 #25
0
                public void ShouldThrowExceptionWhenPathIsInvalid()
                {
                    var exception = Assert.Throws <ArgumentException>("path", () =>
                    {
                        MagickNET.Initialize(ConfigurationFiles.Default, "invalid");
                    });

                    Assert.Contains("Unable to find directory", exception.Message);
                }
        public MainWindow()
        {
            InitializeComponent();

            OpenCL.IsEnabled = false;

            MagickNET.Initialize();
            ImageManager.Initialize();
        }
예제 #27
0
        public void OpenPsdUsingImageMagick()
        {
            MagickNET.Initialize();

            MagickImage img = new MagickImage(_file);

            img.Resize(new MagickGeometry(100, 100));

            img.Write("newFile.png");
        }
예제 #28
0
                public void CanBeCalledTwice()
                {
                    using (var directory = new TemporaryDirectory())
                    {
                        string path = directory.FullName;

                        MagickNET.Initialize(ConfigurationFiles.Default, path);
                        MagickNET.Initialize(ConfigurationFiles.Default, path);
                    }
                }
예제 #29
0
        public void Initialize_WithPathAndPathIsInvalid_ThrowsException()
        {
            ArgumentException exception = ExceptionAssert.Throws <ArgumentException>(() =>
            {
                MagickNET.Initialize(ConfigurationFiles.Default, "invalid");
            });

            Assert.AreEqual("path", exception.ParamName);
            Assert.IsTrue(exception.Message.Contains("Unable to find directory"));
        }
예제 #30
0
                public void ShouldWriteAllFilesInTheReturnedPath()
                {
                    using (var directory = new TemporaryDirectory())
                    {
                        string path = directory.FullName;

                        MagickNET.Initialize(ConfigurationFiles.Default, path);

                        AssertConfigFiles(path);
                    }
                }