public void Test_Log() { using (MagickImage image = new MagickImage(Files.SnakewarePNG)) { int count = 0; EventHandler <LogEventArgs> logDelegate = delegate(object sender, LogEventArgs arguments) { Assert.IsNull(sender); Assert.IsNotNull(arguments); Assert.AreNotEqual(ExceptionTypes.Undefined, arguments.EventType); Assert.IsNotNull(arguments.Message); Assert.AreNotEqual(0, arguments.Message.Length); count++; }; GraphicsMagickNET.Log += logDelegate; image.Flip(); Assert.AreEqual(0, count); GraphicsMagickNET.SetLogEvents(ExceptionTypes.All); image.Flip(); Assert.AreNotEqual(0, count); GraphicsMagickNET.Log -= logDelegate; count = 0; image.Flip(); Assert.AreEqual(0, count); } }
public void Test_Initialize() { ExceptionAssert.Throws <ArgumentNullException>(delegate() { GraphicsMagickNET.Initialize(null); }); ExceptionAssert.Throws <ArgumentException>(delegate() { GraphicsMagickNET.Initialize("Invalid"); }); string path = Files.Root + @"..\GraphicsMagick.NET\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() { GraphicsMagickNET.Initialize(path); }, "MagickNET._ImageMagickFiles does not contain: " + Path.GetFileName(fileName)); File.Move(tempFile, fileName); } }
public void Test_SetTempDirectory() { ExceptionAssert.Throws <ArgumentNullException>(delegate() { GraphicsMagickNET.SetTempDirectory(null); }); ExceptionAssert.Throws <ArgumentException>(delegate() { GraphicsMagickNET.SetTempDirectory("Invalid"); }); GraphicsMagickNET.SetTempDirectory(Path.GetTempPath()); }
public void Test_GetFormatInfo() { List <string> missingFormats = new List <string>(); foreach (MagickFormat format in Enum.GetValues(typeof(MagickFormat))) { if (format == MagickFormat.Unknown) { continue; } MagickFormatInfo formatInfo = GraphicsMagickNET.GetFormatInformation(format); if (formatInfo == null) { missingFormats.Add(format.ToString()); } } if (missingFormats.Count > 0) { Assert.Fail("Cannot find MagickFormatInfo for: " + string.Join(", ", missingFormats.ToArray())); } }