public void Test_Execute_Variables() { MagickScript script = new MagickScript(Files.VariablesScript); string[] names = script.Variables.Names.ToArray(); Assert.AreEqual(2, names.Length); Assert.AreEqual("width", names[0]); Assert.AreEqual("height", names[1]); using (MagickImage image = new MagickImage(Files.GraphicsMagickNETIconPNG)) { ExceptionAssert.Throws<ArgumentException>(delegate() { script.Execute(image); }); script.Variables["width"] = "test"; ExceptionAssert.Throws<FormatException>(delegate() { script.Execute(image); }); script.Variables.Set("width", 100); ExceptionAssert.Throws<ArgumentException>(delegate() { script.Execute(image); }); script.Variables["height"] = "100"; Assert.AreEqual("100", script.Variables.Get("height")); script.Execute(image); Assert.AreEqual(100, image.Width); Assert.AreEqual(100, image.Height); } }
public void Test_Execute_Scale() { MagickScript script = new MagickScript(Files.ScaleScript); using (MagickImage image = new MagickImage(Files.ImageMagickJPG)) { script.Execute(image); TestScriptScaleResult(image); script.Read += ScaleScriptRead; using (MagickImage result = script.Execute()) { TestScriptScaleResult(result); } } }
public void Test_Execute_ImageProfile() { MagickScript script = new MagickScript(Files.ImageProfileScript); using (MagickImage image = new MagickImage(Files.GraphicsMagickNETIconPNG)) { ColorProfile colorProfile = image.GetColorProfile(); Assert.IsNull(colorProfile); script.Execute(image); colorProfile = image.GetColorProfile(); Assert.IsNotNull(colorProfile); Assert.AreEqual(colorProfile.ToByteArray().Length, ColorProfile.SRGB.ToByteArray().Length); } }
public void Test_Execute_Events() { MagickScript script = new MagickScript(Files.EventsScript); ExceptionAssert.Throws<InvalidOperationException>(delegate() { script.Execute(); }); script.Read += Script_ReadNothing; ExceptionAssert.Throws<InvalidOperationException>(delegate() { script.Execute(); }); script.Read -= Script_ReadNothing; ExceptionAssert.Throws<InvalidOperationException>(delegate() { script.Read += EventsScriptRead; script.Read -= EventsScriptRead; script.Execute(); }); script.Read += EventsScriptRead; ExceptionAssert.Throws<InvalidOperationException>(delegate() { script.Execute(); }); ExceptionAssert.Throws<InvalidOperationException>(delegate() { script.Write += EventsScriptWrite; script.Write -= EventsScriptWrite; script.Execute(); }); script.Write += EventsScriptWrite; script.Execute(); }
public void Test_Execute_Draw() { XmlDocument doc = new XmlDocument(); doc.Load(Files.DrawScript); MagickScript script = new MagickScript(doc); using (MagickImage image = new MagickImage(Files.ImageMagickJPG)) { script.Execute(image); } }
public void Test_Execute_Collection() { MagickScript script = new MagickScript(Files.CollectionScript); script.Read += CollectionScriptRead; MagickImage image = script.Execute(); Assert.IsNotNull(image); Assert.AreEqual(MagickFormat.Png, image.Format); Assert.AreEqual(128, image.Width); Assert.AreEqual(30, image.Height); }