2 // Tests for System.Drawing.Drawing2D.ColorBlend.cs
5 // Ravindra (rkumar@novell.com)
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using NUnit.Framework;
33 using System.Drawing.Drawing2D;
34 using System.Security.Permissions;
36 namespace MonoTests.System.Drawing.Drawing2D
39 [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
40 public class ColorBlendTest {
43 public void TestConstructors ()
45 ColorBlend cb1 = new ColorBlend (1);
46 Assert.AreEqual (1, cb1.Colors.Length, "Colors");
47 Assert.AreEqual (1, cb1.Positions.Length, "Positions");
51 public void TestProperties ()
53 ColorBlend cb1 = new ColorBlend (1);
54 float[] positions = {0.0F, 0.5F, 1.0F};
55 Color[] colors = {Color.Red, Color.White, Color.Black};
57 cb1.Positions = positions;
60 Assert.AreEqual (colors[0], cb1.Colors[0], "c0");
61 Assert.AreEqual (colors[1], cb1.Colors[1], "c1");
62 Assert.AreEqual (colors[2], cb1.Colors[2], "c2");
63 Assert.AreEqual (positions[0], cb1.Positions[0], "p0");
64 Assert.AreEqual (positions[1], cb1.Positions[1], "p1");
65 Assert.AreEqual (positions[2], cb1.Positions[2], "p2");
69 public void ColorBlend_Empty ()
71 ColorBlend cb = new ColorBlend ();
72 Assert.AreEqual (1, cb.Colors.Length, "Colors");
73 Assert.IsTrue (cb.Colors[0].IsEmpty, "C0");
74 Assert.AreEqual (1, cb.Positions.Length, "Positions");
75 Assert.AreEqual (0f, cb.Positions[0], "P0");
79 public void ColorBlend_Zero ()
81 ColorBlend cb = new ColorBlend (0);
82 Assert.AreEqual (0, cb.Colors.Length, "Colors");
83 Assert.AreEqual (0, cb.Positions.Length, "Positions");
87 public void MismatchSizes ()
89 ColorBlend cb = new ColorBlend ();
91 cb.Colors = new Color[16];
92 Assert.AreEqual (16, cb.Colors.Length, "Colors");
94 cb.Positions = new float[1];
95 Assert.AreEqual (1, cb.Positions.Length, "Positions");
99 [ExpectedException (typeof (OverflowException))]
100 public void ColorBlend_Negative ()
102 ColorBlend cb = new ColorBlend (-1);
106 public void ColorBlend_Lots ()
108 ColorBlend cb = new ColorBlend (1000);
109 Assert.AreEqual (1000, cb.Colors.Length, "Colors");
110 Assert.AreEqual (1000, cb.Positions.Length, "Positions");