public void Test_Drawables_Exceptions() { ExceptionAssert.ThrowsArgumentException("coordinates", () => { new DrawableBezier(); }); ExceptionAssert.ThrowsArgumentNullException("coordinates", () => { new DrawableBezier(null); }); ExceptionAssert.ThrowsArgumentException("coordinates", () => { new DrawableBezier(new PointD[] { }); }); ExceptionAssert.ThrowsArgumentNullException("clipPath", () => { new DrawableClipPath(null); }); ExceptionAssert.ThrowsArgumentException("clipPath", () => { new DrawableClipPath(string.Empty); }); ExceptionAssert.ThrowsArgumentNullException("offset", () => { new DrawableComposite(null, new MagickImage(Files.Builtin.Logo)); }); ExceptionAssert.ThrowsArgumentNullException("image", () => { new DrawableComposite(new MagickGeometry(), null); }); ExceptionAssert.ThrowsArgumentNullException("color", () => { new DrawableFillColor(null); }); ExceptionAssert.ThrowsArgumentNullException("family", () => { new DrawableFont(null); }); ExceptionAssert.ThrowsArgumentException("family", () => { new DrawableFont(string.Empty); }); ExceptionAssert.Throws <MagickDrawErrorException>(() => { using (IMagickImage image = new MagickImage(Files.Builtin.Wizard)) { image.Draw(new DrawableFillPatternUrl("#fail")); } }); ExceptionAssert.ThrowsArgumentException("coordinates", () => { new DrawablePolygon(new PointD[] { new PointD(0, 0) }); }); ExceptionAssert.ThrowsArgumentException("coordinates", () => { new DrawablePolyline(new PointD[] { new PointD(0, 0), new PointD(0, 0) }); }); ExceptionAssert.ThrowsArgumentNullException("color", () => { new DrawableStrokeColor(null); }); ExceptionAssert.ThrowsArgumentNullException("value", () => { new DrawableText(0, 0, null); }); ExceptionAssert.ThrowsArgumentException("value", () => { new DrawableText(0, 0, string.Empty); }); ExceptionAssert.ThrowsArgumentNullException("encoding", () => { new DrawableTextEncoding(null); }); }
public void Test_Constructor() { ExceptionAssert.Throws <ArgumentNullException>(() => { new MagickGeometry(null); }); ExceptionAssert.Throws <ArgumentException>(() => { new MagickGeometry(string.Empty); }); MagickGeometry geometry = new MagickGeometry("5x10!"); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(5, geometry.Width); Assert.AreEqual(10, geometry.Height); Assert.AreEqual(true, geometry.IgnoreAspectRatio); geometry = new MagickGeometry("10x5+2+1<"); Assert.AreEqual(2, geometry.X); Assert.AreEqual(1, geometry.Y); Assert.AreEqual(10, geometry.Width); Assert.AreEqual(5, geometry.Height); Assert.AreEqual(true, geometry.Less); geometry = new MagickGeometry("5x10>"); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(5, geometry.Width); Assert.AreEqual(10, geometry.Height); Assert.AreEqual(true, geometry.Greater); geometry = new MagickGeometry("10x15^"); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(10, geometry.Width); Assert.AreEqual(15, geometry.Height); Assert.AreEqual(true, geometry.FillArea); geometry = new MagickGeometry("10@"); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(10, geometry.Width); Assert.AreEqual(0, geometry.Height); Assert.AreEqual(true, geometry.LimitPixels); geometry = new MagickGeometry("50%x0>"); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(50, geometry.Width); Assert.AreEqual(0, geometry.Height); Assert.AreEqual(true, geometry.IsPercentage); Assert.AreEqual(true, geometry.Greater); geometry = new MagickGeometry(5, 10); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(5, geometry.Width); Assert.AreEqual(10, geometry.Height); geometry = new MagickGeometry(5, 10, 15, 20); Assert.AreEqual(5, geometry.X); Assert.AreEqual(10, geometry.Y); Assert.AreEqual(15, geometry.Width); Assert.AreEqual(20, geometry.Height); geometry = new MagickGeometry(new Percentage(50.0), new Percentage(10.0)); Assert.AreEqual(0, geometry.X); Assert.AreEqual(0, geometry.Y); Assert.AreEqual(50, geometry.Width); Assert.AreEqual(10, geometry.Height); Assert.AreEqual(true, geometry.IsPercentage); geometry = new MagickGeometry(5, 10, (Percentage)15.0, (Percentage)20.0); Assert.AreEqual(5, geometry.X); Assert.AreEqual(10, geometry.Y); Assert.AreEqual(15, geometry.Width); Assert.AreEqual(20, geometry.Height); Assert.AreEqual(true, geometry.IsPercentage); }
public void ShouldThrowExceptionWhenValueIsEmpty() { ExceptionAssert.Throws <ArgumentException>("value", () => { new Density(string.Empty); }); }
public void Test_Path_Exceptions() { ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathArcAbs(); }); ExceptionAssert.Throws <ArgumentNullException>("coordinates", () => { new PathArcAbs(null); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathArcAbs(new PathArc[] { }); }); ExceptionAssert.Throws <ArgumentNullException>("coordinates", () => { new PathArcAbs(new PathArc[] { null }); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathArcRel(); }); ExceptionAssert.Throws <ArgumentNullException>("coordinates", () => { new PathArcRel(null); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathArcRel(new PathArc[] { }); }); ExceptionAssert.Throws <ArgumentNullException>("coordinates", () => { new PathArcRel(new PathArc[] { null }); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathLineToAbs(); }); ExceptionAssert.Throws <ArgumentNullException>("coordinates", () => { new PathLineToAbs(null); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathLineToAbs(new PointD[] { }); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathLineToRel(); }); ExceptionAssert.Throws <ArgumentNullException>("coordinates", () => { new PathLineToRel(null); }); ExceptionAssert.Throws <ArgumentException>("coordinates", () => { new PathLineToRel(new PointD[] { }); }); }
public void Test_Channel() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { PerceptualHash phash = image.PerceptualHash(); ChannelPerceptualHash channel = phash.GetChannel(PixelChannel.Red); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => { channel.HclpHuPhash(7); }); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => { channel.SrgbHuPhash(7); }); #if Q8 TestChannel(channel, 0, 0.6980, 0.6980, 0.0959, 0.0993); TestChannel(channel, 1, 3.4390, 3.4390, 0.6548, 0.6673); TestChannel(channel, 2, 3.9123, 3.9123, 0.9158, 0.9181); TestChannel(channel, 3, 4.2921, 4.2920, 2.3586, 2.3443); TestChannel(channel, 4, 8.7567, 8.7573, 4.8847, 4.9039); TestChannel(channel, 5, 8.2505, 8.2147, 2.8316, 2.8253); TestChannel(channel, 6, 8.4397, 8.4394, 3.9994, 3.9786); #elif Q16 TestChannel(channel, 0, 0.6979, 0.6979, 0.2578, 0.2574); TestChannel(channel, 1, 3.4385, 3.4385, 1.0557, 1.0507); TestChannel(channel, 2, 3.9123, 3.9123, 1.3807, 1.3834); TestChannel(channel, 3, 4.2920, 4.2920, 2.8468, 2.8517); TestChannel(channel, 4, 8.7555, 8.7555, 5.2021, 5.1835); TestChannel(channel, 5, 8.2995, 8.2995, 3.5194, 3.5093); TestChannel(channel, 6, 8.4397, 8.4397, 5.0471, 5.0707); #elif Q16HDRI TestChannel(channel, 0, 0.6979, 0.6979, 0.2928, 0.2932); TestChannel(channel, 1, 3.4385, 3.4385, 1.1752, 1.1743); TestChannel(channel, 2, 3.9123, 3.9123, 1.5002, 1.5016); TestChannel(channel, 3, 4.2920, 4.2920, 3.0739, 3.0682); TestChannel(channel, 4, 8.7556, 8.7555, 5.4484, 5.4357); TestChannel(channel, 5, 8.2997, 8.2994, 3.7144, 3.7052); TestChannel(channel, 6, 8.4398, 8.4397, 5.6010, 5.6031); #else #error Not implemented! #endif channel = phash.GetChannel(PixelChannel.Green); #if Q8 TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601); TestChannel(channel, 1, 3.3992, 3.3994, 0.3088, 0.3090); TestChannel(channel, 2, 4.1171, 4.1171, 0.6081, 0.6081); TestChannel(channel, 3, 4.4847, 4.4847, 0.7557, 0.7561); TestChannel(channel, 4, 8.8179, 8.8181, 1.7217, 1.7225); TestChannel(channel, 5, 6.4828, 6.4830, 0.9410, 0.9414); TestChannel(channel, 6, 9.2143, 9.2141, 1.5061, 1.5066); #elif Q16 TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601); TestChannel(channel, 1, 3.3988, 3.3988, 0.3089, 0.3089); TestChannel(channel, 2, 4.1168, 4.1168, 0.6083, 0.6083); TestChannel(channel, 3, 4.4844, 4.4844, 0.7555, 0.7555); TestChannel(channel, 4, 8.8174, 8.8174, 1.7219, 1.7219); TestChannel(channel, 5, 6.4821, 6.4821, 0.9408, 0.9408); TestChannel(channel, 6, 9.2147, 9.2147, 1.5058, 1.5058); #elif Q16HDRI TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601); TestChannel(channel, 1, 3.3988, 3.3988, 0.3089, 0.3089); TestChannel(channel, 2, 4.1168, 4.1168, 0.6083, 0.6083); TestChannel(channel, 3, 4.4844, 4.4844, 0.7555, 0.7555); TestChannel(channel, 4, 8.8174, 8.8174, 1.7219, 1.7219); TestChannel(channel, 5, 6.4821, 6.4821, 0.9408, 0.9408); TestChannel(channel, 6, 9.2148, 9.2147, 1.5058, 1.5058); #else #error Not implemented! #endif channel = phash.GetChannel(PixelChannel.Blue); #if Q8 TestChannel(channel, 0, 0.7223, 0.7223, 0.6984, 0.6984); TestChannel(channel, 1, 3.8298, 3.8298, 3.4611, 3.4611); TestChannel(channel, 2, 5.1307, 5.1306, 4.1312, 4.1311); TestChannel(channel, 3, 5.0216, 5.0218, 4.4867, 4.4867); TestChannel(channel, 4, 10.4775, 10.4768, 8.8669, 8.8668); TestChannel(channel, 5, 6.9452, 6.9454, 6.6106, 6.6108); TestChannel(channel, 6, 10.1394, 10.1398, 9.0727, 9.0722); #elif Q16 TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984); TestChannel(channel, 1, 3.8295, 3.8295, 3.4608, 3.4608); TestChannel(channel, 2, 5.1309, 5.1309, 4.1314, 4.1314); TestChannel(channel, 3, 5.0213, 5.0213, 4.4866, 4.4866); TestChannel(channel, 4, 10.4778, 10.4778, 8.8663, 8.8663); TestChannel(channel, 5, 6.9448, 6.9448, 6.6093, 6.6093); TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737); #elif Q16HDRI TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984); TestChannel(channel, 1, 3.8295, 3.8295, 3.4609, 3.4608); TestChannel(channel, 2, 5.1309, 5.1309, 4.1314, 4.1314); TestChannel(channel, 3, 5.0213, 5.0213, 4.4866, 4.4866); TestChannel(channel, 4, 10.4778, 10.4778, 8.8663, 8.8663); TestChannel(channel, 5, 6.9448, 6.9448, 6.6094, 6.6093); TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737); #else #error Not implemented! #endif } }
public void ShouldThrowExceptionWhenValueIsNull() { ExceptionAssert.Throws <ArgumentNullException>("value", () => { new Density(null); }); }
public void ShouldThrowExceptionWhenFileNameIsEmpty() { ExceptionAssert.Throws <ArgumentException>("fileName", () => Optimizer.LosslessCompress(string.Empty)); }
public void ShouldThrowExceptionWhenValueIsEmpty() { var factory = new MagickGeometryFactory(); ExceptionAssert.Throws <ArgumentException>("value", () => factory.Create(string.Empty)); }
public void ShouldThrowExceptionWhenStreamIsNull() { ExceptionAssert.Throws <ArgumentNullException>("stream", () => Optimizer.LosslessCompress((Stream)null)); }
public void ShouldThrowExceptionWhenFileNameIsNull() { ExceptionAssert.Throws <ArgumentNullException>("fileName", () => Optimizer.LosslessCompress((string)null)); }
public void Test_ColorCMYK() { ColorCMYK first = new ColorCMYK(0, 0, 0, 0); MagickColor second = new MagickColor("cmyk(0,0,0,0)"); Assert.AreEqual(second, first.ToMagickColor()); second = new MagickColor("#fff"); Assert.AreNotEqual(second, first.ToMagickColor()); second = new MagickColor("white"); Assert.AreNotEqual(second, first.ToMagickColor()); first = new ColorCMYK(0, 0, Quantum.Max, 0); second = new MagickColor("cmyk(0,0,100%,0)"); Assert.AreEqual(second, first.ToMagickColor()); first = new ColorCMYK(0, 0, Quantum.Max, 0, 0); second = new MagickColor("cmyka(0,0,100%,0,0)"); Assert.AreEqual(second, first.ToMagickColor()); first = new ColorCMYK((Percentage)0, (Percentage)100, (Percentage)0, (Percentage)100); Assert.AreEqual(0, first.C); Assert.AreEqual(Quantum.Max, first.M); Assert.AreEqual(0, first.Y); Assert.AreEqual(Quantum.Max, first.K); Assert.AreEqual(Quantum.Max, first.A); first = new ColorCMYK((Percentage)100, (Percentage)0, (Percentage)100, (Percentage)0, (Percentage)100); Assert.AreEqual(Quantum.Max, first.C); Assert.AreEqual(0, first.M); Assert.AreEqual(Quantum.Max, first.Y); Assert.AreEqual(0, first.K); Assert.AreEqual(Quantum.Max, first.A); first = new ColorCMYK("#0ff0"); Assert.AreEqual(0, first.C); Assert.AreEqual(Quantum.Max, first.M); Assert.AreEqual(Quantum.Max, first.Y); Assert.AreEqual(0, first.K); Assert.AreEqual(Quantum.Max, first.A); first = new ColorCMYK("#ff00ff00"); Assert.AreEqual(Quantum.Max, first.C); Assert.AreEqual(0, first.M); Assert.AreEqual(Quantum.Max, first.Y); Assert.AreEqual(0, first.K); Assert.AreEqual(Quantum.Max, first.A); first = new ColorCMYK("#0000ffff0000ffff"); Assert.AreEqual(0, first.C); Assert.AreEqual(Quantum.Max, first.M); Assert.AreEqual(0, first.Y); Assert.AreEqual(Quantum.Max, first.K); Assert.AreEqual(Quantum.Max, first.A); ExceptionAssert.Throws <ArgumentException>(() => { new ColorCMYK("#fff"); }); ExceptionAssert.Throws <ArgumentException>(() => { new ColorCMYK("#ff00ff"); }); ExceptionAssert.Throws <ArgumentException>(() => { new ColorCMYK("#ffff0000fffff"); }); ExceptionAssert.Throws <ArgumentException>(() => { new ColorCMYK("#ffff0000fffff0000fffff"); }); }
public void Test_Constructor() { Density density = new Density(5); Assert.AreEqual(5.0, density.X); Assert.AreEqual(5.0, density.Y); Assert.AreEqual(DensityUnit.PixelsPerInch, density.Units); density = new Density(8.5, DensityUnit.PixelsPerCentimeter); Assert.AreEqual(8.5, density.X); Assert.AreEqual(8.5, density.Y); Assert.AreEqual(DensityUnit.PixelsPerCentimeter, density.Units); density = new Density(2, 3); Assert.AreEqual(2.0, density.X); Assert.AreEqual(3.0, density.Y); Assert.AreEqual(DensityUnit.PixelsPerInch, density.Units); density = new Density(2.2, 3.3, DensityUnit.Undefined); Assert.AreEqual(2.2, density.X); Assert.AreEqual(3.3, density.Y); Assert.AreEqual(DensityUnit.Undefined, density.Units); ExceptionAssert.Throws <ArgumentNullException>(delegate() { new Density(null); }); ExceptionAssert.Throws <ArgumentException>(delegate() { new Density(""); }); ExceptionAssert.Throws <ArgumentException>(delegate() { new Density("1.0x"); }); ExceptionAssert.Throws <ArgumentException>(delegate() { new Density("x1.0"); }); ExceptionAssert.Throws <ArgumentException>(delegate() { new Density("ax1.0"); }); ExceptionAssert.Throws <ArgumentException>(delegate() { new Density("1.0xb"); }); ExceptionAssert.Throws <ArgumentException>(delegate() { new Density("1.0x6 magick"); }); density = new Density("1.0x2.5"); Assert.AreEqual(1.0, density.X); Assert.AreEqual(2.5, density.Y); Assert.AreEqual(DensityUnit.Undefined, density.Units); Assert.AreEqual("1x2.5", density.ToString()); density = new Density("2.5x1.0 cm"); Assert.AreEqual(2.5, density.X); Assert.AreEqual(1.0, density.Y); Assert.AreEqual(DensityUnit.PixelsPerCentimeter, density.Units); Assert.AreEqual("2.5x1 cm", density.ToString()); density = new Density("2.5x1.0 inch"); Assert.AreEqual(2.5, density.X); Assert.AreEqual(1.0, density.Y); Assert.AreEqual(DensityUnit.PixelsPerInch, density.Units); Assert.AreEqual("2.5x1 inch", density.ToString()); }
public void ShouldThrowExceptionWhenFileIsNull() { ExceptionAssert.Throws <ArgumentNullException>("file", () => Optimizer.Compress((FileInfo)null)); }
public void Test_Set() { using (IMagickImage image = new MagickImage(MagickColors.Red, 5, 10)) { using (PixelCollection pixels = image.GetPixels()) { ExceptionAssert.Throws <ArgumentNullException>(delegate() { pixels.Set((QuantumType[])null); }); ExceptionAssert.Throws <ArgumentNullException>(delegate() { pixels.Set((Pixel)null); }); ExceptionAssert.Throws <ArgumentNullException>(delegate() { pixels.Set((Pixel[])null); }); Assert.AreEqual(3, pixels.Channels); Test_Set(pixels, new QuantumType[] { }); Test_Set(pixels, new QuantumType[] { 0 }); Test_Set(pixels, new QuantumType[] { 0, 0 }); pixels.Set(new QuantumType[] { 0, 0, 0 }); Test_PixelColor(pixels, MagickColors.Black); } using (PixelCollection pixels = image.GetPixels()) { Test_PixelColor(pixels, MagickColors.Black); } using (PixelCollection pixels = image.GetPixels()) { pixels.Set(new int[] { 100000, 0, 0 }); Test_PixelColor(pixels, MagickColors.Red); pixels.Set(new byte[] { 0, 255, 0 }); Test_PixelColor(pixels, MagickColors.Lime); } using (PixelCollection pixels = image.GetPixels()) { pixels.SetArea(3, 3, 1, 1, new int[] { 100000, 0, 0 }); Test_PixelColor(pixels, 3, 3, MagickColors.Red); pixels.SetArea(3, 3, 1, 1, new byte[] { 0, 255, 0 }); Test_PixelColor(pixels, 3, 3, MagickColors.Lime); } using (PixelCollection pixels = image.GetPixels()) { for (int x = 0; x < image.Width; x++) { for (int y = 0; y < image.Height; y++) { pixels.Set(x, y, new QuantumType[] { 0, 0, 0 }); } } } } }
public void Test_Channel() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { PerceptualHash phash = image.PerceptualHash(); ChannelPerceptualHash channel = phash.GetChannel(PixelChannel.Red); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => { channel.HclpHuPhash(7); }); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => { channel.SrgbHuPhash(7); }); #if Q8 TestChannel(channel, 0, 0.6980, 0.6980, 0.0974, 0.0993); TestChannel(channel, 1, 3.4388, 3.4390, 0.6582, 0.6685); TestChannel(channel, 2, 3.9123, 3.9123, 0.9238, 0.9195); TestChannel(channel, 3, 4.2922, 4.2920, 2.3627, 2.3354); TestChannel(channel, 4, 8.7570, 8.7574, 4.9574, 5.2273); TestChannel(channel, 5, 8.2422, 8.2149, 2.8422, 2.8360); TestChannel(channel, 6, 8.4397, 8.4394, 4.0087, 3.9636); #elif Q16 TestChannel(channel, 0, 0.6979, 0.6979, 0.2575, 0.2570); TestChannel(channel, 1, 3.4385, 3.4385, 1.0621, 1.0552); TestChannel(channel, 2, 3.9123, 3.9123, 1.3756, 1.3800); TestChannel(channel, 3, 4.2920, 4.2920, 2.8341, 2.8360); TestChannel(channel, 4, 8.7557, 8.7557, 5.1134, 5.1087); TestChannel(channel, 5, 8.3019, 8.3018, 3.4791, 3.4733); TestChannel(channel, 6, 8.4398, 8.4398, 5.0679, 5.0815); #elif Q16HDRI TestChannel(channel, 0, 0.6979, 0.6979, 0.2944, 0.2945); TestChannel(channel, 1, 3.4385, 3.4385, 1.1850, 1.1834); TestChannel(channel, 2, 3.9123, 3.9123, 1.5006, 1.5009); TestChannel(channel, 3, 4.2920, 4.2920, 3.0480, 3.0419); TestChannel(channel, 4, 8.7557, 8.7557, 5.3844, 5.3651); TestChannel(channel, 5, 8.3018, 8.3018, 3.6804, 3.6675); TestChannel(channel, 6, 8.4398, 8.4398, 5.6247, 5.6501); #else #error Not implemented! #endif channel = phash.GetChannel(PixelChannel.Green); #if Q8 TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601); TestChannel(channel, 1, 3.3993, 3.3995, 0.3090, 0.3093); TestChannel(channel, 2, 4.1171, 4.1172, 0.6084, 0.6083); TestChannel(channel, 3, 4.4847, 4.4847, 0.7559, 0.7566); TestChannel(channel, 4, 8.8180, 8.8183, 1.7224, 1.7237); TestChannel(channel, 5, 6.4829, 6.4832, 0.9413, 0.9421); TestChannel(channel, 6, 9.2143, 9.2141, 1.5065, 1.5074); #elif Q16 TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601); TestChannel(channel, 1, 3.3989, 3.3989, 0.3092, 0.3092); TestChannel(channel, 2, 4.1169, 4.1169, 0.6084, 0.6084); TestChannel(channel, 3, 4.4844, 4.4844, 0.7559, 0.7559); TestChannel(channel, 4, 8.8174, 8.8174, 1.7230, 1.7230); TestChannel(channel, 5, 6.4821, 6.4821, 0.9413, 0.9413); TestChannel(channel, 6, 9.2148, 9.2148, 1.5063, 1.5063); #elif Q16HDRI TestChannel(channel, 0, 0.6942, 0.6942, -0.0601, -0.0601); TestChannel(channel, 1, 3.3989, 3.3989, 0.3092, 0.3092); TestChannel(channel, 2, 4.1169, 4.1169, 0.6084, 0.6084); TestChannel(channel, 3, 4.4844, 4.4844, 0.7559, 0.7559); TestChannel(channel, 4, 8.8174, 8.8174, 1.7230, 1.7230); TestChannel(channel, 5, 6.4821, 6.4821, 0.9413, 0.9413); TestChannel(channel, 6, 9.2148, 9.2148, 1.5063, 1.5063); #else #error Not implemented! #endif channel = phash.GetChannel(PixelChannel.Blue); #if Q8 TestChannel(channel, 0, 0.7223, 0.7223, 0.6984, 0.6984); TestChannel(channel, 1, 3.8298, 3.8298, 3.4611, 3.4612); TestChannel(channel, 2, 5.1301, 5.1301, 4.1312, 4.1312); TestChannel(channel, 3, 5.0217, 5.0218, 4.4867, 4.4867); TestChannel(channel, 4, 10.4769, 10.4761, 8.8669, 8.8670); TestChannel(channel, 5, 6.9453, 6.9454, 6.6108, 6.6110); TestChannel(channel, 6, 10.1394, 10.1396, 9.0725, 9.0722); #elif Q16 TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984); TestChannel(channel, 1, 3.8295, 3.8295, 3.4609, 3.4609); TestChannel(channel, 2, 5.1304, 5.1304, 4.1314, 4.1314); TestChannel(channel, 3, 5.0214, 5.0214, 4.4866, 4.4866); TestChannel(channel, 4, 10.4771, 10.4772, 8.8663, 8.8663); TestChannel(channel, 5, 6.9448, 6.9448, 6.6094, 6.6094); TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737); #elif Q16HDRI TestChannel(channel, 0, 0.7222, 0.7222, 0.6984, 0.6984); TestChannel(channel, 1, 3.8295, 3.8295, 3.4609, 3.4609); TestChannel(channel, 2, 5.1304, 5.1304, 4.1314, 4.1314); TestChannel(channel, 3, 5.0214, 5.0214, 4.4866, 4.4866); TestChannel(channel, 4, 10.4772, 10.4772, 8.8663, 8.8663); TestChannel(channel, 5, 6.9448, 6.9448, 6.6094, 6.6094); TestChannel(channel, 6, 10.1388, 10.1388, 9.0737, 9.0737); #else #error Not implemented! #endif } }
public void Test_SetValue() { using (MemoryStream memStream = new MemoryStream()) { string credit = null; for (int i = 0; i < 255; i++) { credit += i.ToString() + "."; } using (IMagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG)) { IptcProfile profile = image.GetIptcProfile(); TestProfileValues(profile); IptcValue value = profile.GetValue(IptcTag.Title); TestValue(value, "Communications"); profile.SetValue(IptcTag.Title, "Magick.NET Title"); TestValue(value, "Magick.NET Title"); value = profile.GetValue(IptcTag.Title); TestValue(value, "Magick.NET Title"); value = profile.Values.FirstOrDefault(val => val.Tag == IptcTag.ReferenceNumber); Assert.IsNull(value); profile.SetValue(IptcTag.ReferenceNumber, "Magick.NET ReferenceNümber"); value = profile.GetValue(IptcTag.ReferenceNumber); TestValue(value, "Magick.NET ReferenceNümber"); profile.SetValue(IptcTag.Credit, credit); value = profile.GetValue(IptcTag.Credit); TestValue(value, credit); // Remove the 8bim profile so we can overwrite the iptc profile. image.RemoveProfile("8bim"); image.AddProfile(profile); image.Write(memStream); memStream.Position = 0; } using (IMagickImage image = new MagickImage(memStream)) { IptcProfile profile = image.GetIptcProfile(); TestProfileValues(profile, 19); IptcValue value = profile.GetValue(IptcTag.Title); TestValue(value, "Magick.NET Title"); value = profile.GetValue(IptcTag.ReferenceNumber); TestValue(value, "Magick.NET ReferenceNümber"); value = profile.GetValue(IptcTag.Credit); TestValue(value, credit); ExceptionAssert.Throws <ArgumentNullException>(delegate() { profile.SetValue(IptcTag.Caption, null, "Test"); }); profile.SetValue(IptcTag.Caption, "Test"); value = profile.Values.ElementAt(1); Assert.AreEqual("Test", value.Value); profile.SetValue(IptcTag.Caption, Encoding.UTF32, "Test"); Assert.AreEqual(Encoding.UTF32, value.Encoding); Assert.AreEqual("Test", value.Value); Assert.IsTrue(profile.RemoveValue(IptcTag.Caption)); Assert.IsFalse(profile.RemoveValue(IptcTag.Caption)); Assert.IsNull(profile.GetValue(IptcTag.Caption)); } } }
public void ShouldThrowExceptionWhenValueIsNull() { var factory = new MagickGeometryFactory(); ExceptionAssert.Throws <ArgumentNullException>("value", () => factory.Create(null)); }