// // Unit tests for CGContext // // Authors: // Sebastien Pouliot // // Copyright 2013 Xamarin Inc. All rights reserved. // using System; using System.Drawing; #if XAMCORE_2_0 using Foundation; using CoreGraphics; #else using MonoTouch.CoreGraphics; using MonoTouch.Foundation; #endif using NUnit.Framework; #if XAMCORE_2_0 using RectangleF=CoreGraphics.CGRect; using SizeF=CoreGraphics.CGSize; using PointF=CoreGraphics.CGPoint; #else using nfloat=global::System.Single; using nint=global::System.Int32; using nuint=global::System.UInt32; #endif namespace MonoTouchFixtures.CoreGraphics { [TestFixture] [Preserve (AllMembers = true)] public class ContextTest { CGContext Create () { using (CGColorSpace space = CGColorSpace.CreateDeviceRGB ()) { return new CGBitmapContext (null, 10, 10, 8, 40, space, CGBitmapFlags.PremultipliedLast); } } [Test] public void SetLineDash () { var lengths = new nfloat [] { 1.0f, 2.0f, 3.0f }; using (var c = Create ()) { c.SetLineDash (1.0f, lengths); c.SetLineDash (2.0f, null); c.SetLineDash (3.0f, lengths, 2); c.SetLineDash (4.0f, null, -1); Assert.Throws (delegate { c.SetLineDash (5.0f, lengths, -1); }, "negative"); Assert.Throws (delegate { c.SetLineDash (6.0f, lengths, Int32.MaxValue); }, "max"); } } } }