Fix LinearGradientMode parameter validation to match corefx (#5672)
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing.Drawing2D / LinearGradientBrushTest.cs
1 //
2 // System.Drawing.Drawing2D.LinearGradientBrush unit tests
3 //
4 // Authors:
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // Copyright (C) 2006, 2008 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using System;
30 using System.ComponentModel;
31 using System.Drawing;
32 using System.Drawing.Drawing2D;
33 using System.Security.Permissions;
34 using NUnit.Framework;
35
36 namespace MonoTests.System.Drawing.Drawing2D {
37
38         [TestFixture]
39         [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
40         public class LinearGradientBrushTest {
41
42                 private Point pt1;
43                 private Point pt2;
44                 private Color c1;
45                 private Color c2;
46                 private LinearGradientBrush default_brush;
47                 private Matrix empty_matrix;
48                 private RectangleF rect;
49
50                 [TestFixtureSetUp]
51                 public void FixtureSetUp ()
52                 {
53                         pt1 = new Point (0, 0);
54                         pt2 = new Point (32, 32);
55                         c1 = Color.Blue;
56                         c2 = Color.Red;
57                         default_brush = new LinearGradientBrush (pt1, pt2, c1, c2);
58                         empty_matrix = new Matrix ();
59                         rect = new RectangleF (0, 0, 32, 32);
60                 }
61
62                 private void CheckDefaultRectangle (string msg, RectangleF rect)
63                 {
64                         Assert.AreEqual (pt1.X, rect.X, msg + ".Rectangle.X");
65                         Assert.AreEqual (pt1.Y, rect.Y, msg + ".Rectangle.Y");
66                         Assert.AreEqual (pt2.X, rect.Width, msg + ".Rectangle.Width");
67                         Assert.AreEqual (pt2.Y, rect.Height, msg + ".Rectangle.Height");
68                 }
69
70                 private void CheckDefaultMatrix (Matrix matrix)
71                 {
72                         float[] elements = matrix.Elements;
73                         Assert.AreEqual (1.0f, elements[0], 0.1, "matrix.0");
74                         Assert.AreEqual (1.0f, elements[1], 0.1, "matrix.1");
75                         Assert.AreEqual (-1.0f, elements[2], 0.1, "matrix.2");
76                         Assert.AreEqual (1.0f, elements[3], 0.1, "matrix.3");
77                         Assert.AreEqual (16.0f, elements[4], 0.1, "matrix.4");
78                         Assert.AreEqual (-16.0f, elements[5], 0.1, "matrix.5");
79                 }
80
81                 private void CheckBrushAt45 (LinearGradientBrush lgb)
82                 {
83                         CheckDefaultRectangle ("4", lgb.Rectangle);
84                         Assert.AreEqual (1, lgb.Blend.Factors.Length, "Blend.Factors");
85                         Assert.AreEqual (1, lgb.Blend.Factors[0], "Blend.Factors [0]");
86                         Assert.AreEqual (1, lgb.Blend.Positions.Length, "Blend.Positions");
87                         // lgb.Blend.Positions [0] is always small (e-39) but never quite the same
88                         Assert.IsFalse (lgb.GammaCorrection, "GammaCorrection");
89                         Assert.AreEqual (2, lgb.LinearColors.Length, "LinearColors");
90                         Assert.IsNotNull (lgb.Transform, "Transform");
91                         CheckDefaultMatrix (lgb.Transform);
92                 }
93
94                 private void CheckMatrixAndRect (PointF pt1, PointF pt2, float[] testVals)
95                 {
96                         Matrix m;
97                         RectangleF rect;
98
99                         using (LinearGradientBrush b = new LinearGradientBrush (pt1, pt2, Color.Black, Color.White)) {
100                                 m = b.Transform;
101                                 rect = b.Rectangle;
102                         }
103
104                         Assert.AreEqual (testVals[0], m.Elements[0], 0.0001, "matrix.0");
105                         Assert.AreEqual (testVals[1], m.Elements[1], 0.0001, "matrix.1");
106                         Assert.AreEqual (testVals[2], m.Elements[2], 0.0001, "matrix.2");
107                         Assert.AreEqual (testVals[3], m.Elements[3], 0.0001, "matrix.3");
108                         Assert.AreEqual (testVals[4], m.Elements[4], 0.0001, "matrix.4");
109                         Assert.AreEqual (testVals[5], m.Elements[5], 0.0001, "matrix.5");
110
111                         Assert.AreEqual (testVals[6], rect.X, 0.0001, "rect.X");
112                         Assert.AreEqual (testVals[7], rect.Y, 0.0001, "rect.Y");
113                         Assert.AreEqual (testVals[8], rect.Width, 0.0001, "rect.Width");
114                         Assert.AreEqual (testVals[9], rect.Height, 0.0001, "rect.Height");
115                 }
116
117                 private void CheckMatrixForScalableAngle (RectangleF rect, float angle, float[] testVals)
118                 {
119                         Matrix m;
120
121                         using (LinearGradientBrush b = new LinearGradientBrush (rect, Color.Firebrick, Color.Lavender, angle, true)) {
122                                 m = b.Transform;
123                         }
124
125                         Assert.AreEqual (testVals[0], m.Elements[0], 0.0001, "matrix.0");
126                         Assert.AreEqual (testVals[1], m.Elements[1], 0.0001, "matrix.1");
127                         Assert.AreEqual (testVals[2], m.Elements[2], 0.0001, "matrix.2");
128                         Assert.AreEqual (testVals[3], m.Elements[3], 0.0001, "matrix.3");
129                         Assert.AreEqual (testVals[4], m.Elements[4], 0.0001, "matrix.4");
130                         Assert.AreEqual (testVals[5], m.Elements[5], 0.0001, "matrix.5");
131                 }
132
133                 [Test]
134                 public void Constructor_Point_Point_Color_Color ()
135                 {
136                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
137                         CheckBrushAt45 (lgb);
138
139                         Assert.AreEqual (WrapMode.Tile, lgb.WrapMode, "WrapMode.Tile");
140                         lgb.WrapMode = WrapMode.TileFlipX;
141                         Assert.AreEqual (WrapMode.TileFlipX, lgb.WrapMode, "WrapMode.TileFlipX");
142                         lgb.WrapMode = WrapMode.TileFlipY;
143                         Assert.AreEqual (WrapMode.TileFlipY, lgb.WrapMode, "WrapMode.TileFlipY");
144                         lgb.WrapMode = WrapMode.TileFlipXY;
145                         Assert.AreEqual (WrapMode.TileFlipXY, lgb.WrapMode, "WrapMode.TileFlipXY");
146                         // can't set WrapMode.Clamp
147                 }
148
149                 [Test]
150                 public void Constructor_Point_Point_Color_Color_1 ()
151                 {
152                         PointF pt1 = new Point (100, 200);
153                         PointF pt2 = new Point (200, 200);
154                         CheckMatrixAndRect (pt1, pt2, new float[] { 1, 0, 0, 1, 0, 0, 100, 150, 100, 100 });
155
156                         pt1 = new Point (100, 200);
157                         pt2 = new Point (0, 200);
158                         CheckMatrixAndRect (pt1, pt2, new float[] { -1, 0, 0, -1, 100, 400, 0, 150, 100, 100 });
159
160                         pt1 = new Point (100, 200);
161                         pt2 = new Point (100, 300);
162                         CheckMatrixAndRect (pt1, pt2, new float[] { 0, 1, -1, 0, 350, 150, 50, 200, 100, 100  });
163
164                         pt1 = new Point (100, 200);
165                         pt2 = new Point (100, 100);
166                         CheckMatrixAndRect (pt1, pt2, new float[] { 0, -1, 1, 0, -50, 250, 50, 100, 100, 100 });
167
168                         pt1 = new Point (100, 100);
169                         pt2 = new Point (150, 225);
170                         CheckMatrixAndRect (pt1, pt2, new float[] { 1, 2.5f, -0.6896552f, 0.2758622f, 112.069f, -194.8276f, 100, 100, 50, 125 });
171
172                         pt1 = new Point (100, 100);
173                         pt2 = new Point (55, 200);
174                         CheckMatrixAndRect (pt1, pt2, new float[] { -1, 2.222222f, -0.7484408f, -0.3367983f, 267.2661f, 28.29753f, 55, 100, 45, 100 });
175
176                         pt1 = new Point (100, 100);
177                         pt2 = new Point (150, 60);
178                         CheckMatrixAndRect (pt1, pt2, new float[] { 1, -0.8000001f, 0.9756095f, 1.219512f, -78.04876f, 82.43903f, 100, 60, 50, 40 });
179
180                         pt1 = new Point (100, 100);
181                         pt2 = new Point (27, 59);
182                         CheckMatrixAndRect (pt1, pt2, new float[] { -1, -0.5616435f, 0.8539224f, -1.520399f, 59.11317f, 236.0361f, 27, 59, 73, 41 });
183                 }
184
185                 [Test]
186                 public void Constructor_RectangleF_Color_Color_Single_0 ()
187                 {
188                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
189                         CheckDefaultRectangle ("Original", lgb.Rectangle);
190                         Assert.AreEqual (1, lgb.Blend.Factors.Length, "Blend.Factors");
191                         Assert.AreEqual (1, lgb.Blend.Factors[0], "Blend.Factors[0]");
192                         Assert.AreEqual (1, lgb.Blend.Positions.Length, "Blend.Positions");
193                         // lgb.Blend.Positions [0] is always small (e-39) but never quite the same
194                         Assert.IsFalse (lgb.GammaCorrection, "GammaCorrection");
195                         Assert.AreEqual (c1.ToArgb (), lgb.LinearColors[0].ToArgb (), "LinearColors[0]");
196                         Assert.AreEqual (c2.ToArgb (), lgb.LinearColors[1].ToArgb (), "LinearColors[1]");
197                         Assert.AreEqual (rect, lgb.Rectangle, "Rectangle");
198                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity");
199                         Assert.AreEqual (WrapMode.Tile, lgb.WrapMode, "WrapMode");
200
201                         Matrix matrix = new Matrix (2, -1, 1, 2, 10, 10);
202                         lgb.Transform = matrix;
203                         Assert.AreEqual (matrix, lgb.Transform, "Transform");
204                 }
205
206                 [Test]
207                 public void Constructor_RectangleF_Color_Color_Single_22_5 ()
208                 {
209                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 22.5f);
210                         CheckDefaultRectangle ("Original", lgb.Rectangle);
211                         float[] elements = lgb.Transform.Elements;
212                         Assert.AreEqual (1.207107, elements[0], 0.0001, "matrix.0");
213                         Assert.AreEqual (0.5, elements[1], 0.0001, "matrix.1");
214                         Assert.AreEqual (-0.5, elements[2], 0.0001, "matrix.2");
215                         Assert.AreEqual (1.207107, elements[3], 0.0001, "matrix.3");
216                         Assert.AreEqual (4.686291, elements[4], 0.0001, "matrix.4");
217                         Assert.AreEqual (-11.313709, elements[5], 0.0001, "matrix.5");
218                 }
219
220                 [Test]
221                 public void Constructor_RectangleF_Color_Color_Single_45 ()
222                 {
223                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f);
224                         CheckBrushAt45 (lgb);
225                 }
226
227                 [Test]
228                 public void Constructor_RectangleF_Color_Color_Single_90 ()
229                 {
230                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 90f);
231                         CheckDefaultRectangle ("Original", lgb.Rectangle);
232                         float[] elements = lgb.Transform.Elements;
233                         Assert.AreEqual (0, elements[0], 0.0001, "matrix.0");
234                         Assert.AreEqual (1, elements[1], 0.0001, "matrix.1");
235                         Assert.AreEqual (-1, elements[2], 0.0001, "matrix.2");
236                         Assert.AreEqual (0, elements[3], 0.0001, "matrix.3");
237                         Assert.AreEqual (32, elements[4], 0.0001, "matrix.4");
238                         Assert.AreEqual (0, elements[5], 0.0001, "matrix.5");
239                 }
240
241                 [Test]
242                 public void Constructor_RectangleF_Color_Color_Single_135 ()
243                 {
244                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 135f);
245                         CheckDefaultRectangle ("Original", lgb.Rectangle);
246                         float[] elements = lgb.Transform.Elements;
247                         Assert.AreEqual (-1, elements[0], 0.0001, "matrix.0");
248                         Assert.AreEqual (1, elements[1], 0.0001, "matrix.1");
249                         Assert.AreEqual (-1, elements[2], 0.0001, "matrix.2");
250                         Assert.AreEqual (-1, elements[3], 0.0001, "matrix.3");
251                         Assert.AreEqual (48, elements[4], 0.0001, "matrix.4");
252                         Assert.AreEqual (16, elements[5], 0.0001, "matrix.5");
253                 }
254
255                 [Test]
256                 public void Constructor_RectangleF_Color_Color_Single_180 ()
257                 {
258                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 180f);
259                         CheckDefaultRectangle ("Original", lgb.Rectangle);
260                         float[] elements = lgb.Transform.Elements;
261                         Assert.AreEqual (-1, elements[0], 0.0001, "matrix.0");
262                         Assert.AreEqual (0, elements[1], 0.0001, "matrix.1");
263                         Assert.AreEqual (0, elements[2], 0.0001, "matrix.2");
264                         Assert.AreEqual (-1, elements[3], 0.0001, "matrix.3");
265                         Assert.AreEqual (32, elements[4], 0.0001, "matrix.4");
266                         Assert.AreEqual (32, elements[5], 0.0001, "matrix.5");
267                 }
268
269                 [Test]
270                 public void Constructor_RectangleF_Color_Color_Single_270 ()
271                 {
272                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 270f);
273                         CheckDefaultRectangle ("Original", lgb.Rectangle);
274                         float[] elements = lgb.Transform.Elements;
275                         Assert.AreEqual (0, elements[0], 0.0001, "matrix.0");
276                         Assert.AreEqual (-1, elements[1], 0.0001, "matrix.1");
277                         Assert.AreEqual (1, elements[2], 0.0001, "matrix.2");
278                         Assert.AreEqual (0, elements[3], 0.0001, "matrix.3");
279                         Assert.AreEqual (0, elements[4], 0.0001, "matrix.4");
280                         Assert.AreEqual (32, elements[5], 0.0001, "matrix.5");
281                 }
282
283                 [Test]
284                 public void Constructor_RectangleF_Color_Color_Single_315 ()
285                 {
286                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 315f);
287                         CheckDefaultRectangle ("Original", lgb.Rectangle);
288                         float[] elements = lgb.Transform.Elements;
289                         Assert.AreEqual (1, elements[0], 0.0001, "matrix.0");
290                         Assert.AreEqual (-1, elements[1], 0.0001, "matrix.1");
291                         Assert.AreEqual (1, elements[2], 0.0001, "matrix.2");
292                         Assert.AreEqual (1, elements[3], 0.0001, "matrix.3");
293                         Assert.AreEqual (-16, elements[4], 0.0001, "matrix.4");
294                         Assert.AreEqual (16, elements[5], 0.0001, "matrix.5");
295                 }
296
297                 [Test]
298                 public void Constructor_RectangleF_Color_Color_Single_360()
299                 {
300                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 360f);
301                         CheckDefaultRectangle ("Original", lgb.Rectangle);
302                         float[] elements = lgb.Transform.Elements;
303                         // just like 0'
304                         Assert.AreEqual (1, elements[0], 0.0001, "matrix.0");
305                         Assert.AreEqual (0, elements[1], 0.0001, "matrix.1");
306                         Assert.AreEqual (0, elements[2], 0.0001, "matrix.2");
307                         Assert.AreEqual (1, elements[3], 0.0001, "matrix.3");
308                         Assert.AreEqual (0, elements[4], 0.0001, "matrix.4");
309                         Assert.AreEqual (0, elements[5], 0.0001, "matrix.5");
310                 }
311
312                 [Test]
313                 public void Constructor_RectangleF_Color_Color_Single_540 ()
314                 {
315                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 540f);
316                         CheckDefaultRectangle ("Original", lgb.Rectangle);
317                         float[] elements = lgb.Transform.Elements;
318                         // just like 180'
319                         Assert.AreEqual (-1, elements[0], 0.0001, "matrix.0");
320                         Assert.AreEqual (0, elements[1], 0.0001, "matrix.1");
321                         Assert.AreEqual (0, elements[2], 0.0001, "matrix.2");
322                         Assert.AreEqual (-1, elements[3], 0.0001, "matrix.3");
323                         Assert.AreEqual (32, elements[4], 0.0001, "matrix.4");
324                         Assert.AreEqual (32, elements[5], 0.0001, "matrix.5");
325                 }
326
327                 [Test]
328                 public void Constructor_Rectangle_InvalidWidthHeight ()
329                 {
330                         var emptyWidth = new Rectangle (0, 0, 0, 1);
331                         var emptyHeight = new Rectangle (0, 0, 0, 1);
332
333                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyWidth, Color.Empty, Color.Empty, 1));
334                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyHeight, Color.Empty, Color.Empty, 1));
335                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyWidth, Color.Empty, Color.Empty, LinearGradientMode.BackwardDiagonal));
336                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyHeight, Color.Empty, Color.Empty, LinearGradientMode.BackwardDiagonal));
337                 }
338
339                 [Test]
340                 public void Constructor_RectangleF_InvalidWidthHeight ()
341                 {
342                         var emptyWidth = new RectangleF (0, 0, 0, 1);
343                         var emptyHeight = new RectangleF (0, 0, 0, 1);
344
345                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyWidth, Color.Empty, Color.Empty, 1));
346                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyHeight, Color.Empty, Color.Empty, 1));
347                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyWidth, Color.Empty, Color.Empty, LinearGradientMode.BackwardDiagonal));
348                         Assert.Throws<ArgumentException>(() => new LinearGradientBrush (emptyHeight, Color.Empty, Color.Empty, LinearGradientMode.BackwardDiagonal));
349                 }
350
351                 [Test]
352                 public void Constructor_LinearGradientMode_InvalidMode ()
353                 {
354                         var rect = new Rectangle (0, 0, 1, 1);
355                         var rectf = new RectangleF (0, 0, 1, 1);
356
357                         Assert.Throws<InvalidEnumArgumentException>(() => new LinearGradientBrush (rect, Color.Empty, Color.Empty, LinearGradientMode.Horizontal - 1));
358                         Assert.Throws<InvalidEnumArgumentException>(() => new LinearGradientBrush (rectf, Color.Empty, Color.Empty, LinearGradientMode.Horizontal - 1));
359                         Assert.Throws<InvalidEnumArgumentException>(() => new LinearGradientBrush (rect, Color.Empty, Color.Empty, LinearGradientMode.BackwardDiagonal + 1));
360                         Assert.Throws<InvalidEnumArgumentException>(() => new LinearGradientBrush (rectf, Color.Empty, Color.Empty, LinearGradientMode.BackwardDiagonal + 1));
361                 }
362
363                 [Test]
364                 public void InterpolationColors_Colors_InvalidBlend ()
365                 {
366                         // default Blend doesn't allow getting this property
367                         Assert.Throws<ArgumentException> (() => { var x = default_brush.InterpolationColors.Colors; });
368                 }
369
370                 [Test]
371                 public void InterpolationColors_Positions_InvalidBlend ()
372                 {
373                         // default Blend doesn't allow getting this property
374                         Assert.Throws<ArgumentException> (() => { var x = default_brush.InterpolationColors.Positions; });
375                 }
376
377                 [Test]
378                 public void LinearColors_Empty ()
379                 {
380                         Assert.Throws<IndexOutOfRangeException> (() => default_brush.LinearColors = new Color[0]);
381                 }
382
383                 [Test]
384                 public void LinearColors_One ()
385                 {
386                         Assert.Throws<IndexOutOfRangeException> (() => default_brush.LinearColors = new Color[1]);
387                 }
388
389                 [Test]
390                 public void LinearColors_Two ()
391                 {
392                         Assert.AreEqual (Color.FromArgb (255, 0, 0, 255), default_brush.LinearColors[0], "0");
393                         Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), default_brush.LinearColors[1], "1");
394
395                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
396                         lgb.LinearColors = new Color[2] { Color.Black, Color.White };
397                         // not the same, the alpha is changed to 255 so they can't compare
398                         Assert.AreEqual (Color.FromArgb (255, 0, 0, 0), lgb.LinearColors[0], "0");
399                         Assert.AreEqual (Color.FromArgb (255, 255, 255, 255), lgb.LinearColors[1], "1");
400                 }
401
402                 [Test]
403                 public void LinearColors_Three ()
404                 {
405                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
406                         lgb.LinearColors = new Color[3] { Color.Red, Color.Green, Color.Blue };
407                         // not the same, the alpha is changed to 255 so they can't compare
408                         Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), lgb.LinearColors[0], "0");
409                         Assert.AreEqual (Color.FromArgb (255, 0, 128, 0), lgb.LinearColors[1], "1");
410                 }
411
412                 [Test]
413                 public void Rectangle ()
414                 {
415                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
416                         CheckDefaultRectangle ("Original", lgb.Rectangle);
417                         lgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2));
418                         CheckDefaultRectangle ("Multiply", lgb.Rectangle);
419                         lgb.ResetTransform ();
420                         CheckDefaultRectangle ("Reset", lgb.Rectangle);
421                         lgb.RotateTransform (90);
422                         CheckDefaultRectangle ("Rotate", lgb.Rectangle);
423                         lgb.ScaleTransform (4, 0.25f);
424                         CheckDefaultRectangle ("Scale", lgb.Rectangle);
425                         lgb.TranslateTransform (-10, -20);
426                         CheckDefaultRectangle ("Translate", lgb.Rectangle);
427
428                         lgb.SetBlendTriangularShape (0.5f);
429                         CheckDefaultRectangle ("SetBlendTriangularShape", lgb.Rectangle);
430                         lgb.SetSigmaBellShape (0.5f);
431                         CheckDefaultRectangle ("SetSigmaBellShape", lgb.Rectangle);
432                 }
433
434                 [Test]
435                 public void Transform_Null ()
436                 {
437                         Assert.Throws<ArgumentNullException> (() => default_brush.Transform = null);
438                 }
439
440                 [Test]
441                 public void Transform_Empty ()
442                 {
443                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
444                         lgb.Transform = new Matrix ();
445                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity");
446                 }
447
448                 [Test]
449                 public void Transform_NonInvertible ()
450                 {
451                         Assert.Throws<ArgumentException> (() => default_brush.Transform = new Matrix (123, 24, 82, 16, 47, 30));
452                 }
453
454                 [Test]
455                 public void WrapMode_AllValid ()
456                 {
457                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
458                         lgb.WrapMode = WrapMode.Tile;
459                         Assert.AreEqual (WrapMode.Tile, lgb.WrapMode, "WrapMode.Tile");
460                         lgb.WrapMode = WrapMode.TileFlipX;
461                         Assert.AreEqual (WrapMode.TileFlipX, lgb.WrapMode, "WrapMode.TileFlipX");
462                         lgb.WrapMode = WrapMode.TileFlipY;
463                         Assert.AreEqual (WrapMode.TileFlipY, lgb.WrapMode, "WrapMode.TileFlipY");
464                         lgb.WrapMode = WrapMode.TileFlipXY;
465                         Assert.AreEqual (WrapMode.TileFlipXY, lgb.WrapMode, "WrapMode.TileFlipXY");
466                 }
467
468                 [Test]
469                 public void WrapMode_Clamp ()
470                 {
471                         Assert.Throws<ArgumentException> (() => default_brush.WrapMode = WrapMode.Clamp);
472                 }
473
474                 [Test]
475                 public void WrapMode_Invalid ()
476                 {
477                         Assert.Throws<InvalidEnumArgumentException> (() => default_brush.WrapMode = (WrapMode) Int32.MinValue);
478                 }
479
480
481                 [Test]
482                 public void Clone ()
483                 {
484                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
485                         LinearGradientBrush clone = (LinearGradientBrush) lgb.Clone ();
486                         Assert.AreEqual (lgb.Blend.Factors.Length, clone.Blend.Factors.Length, "Blend.Factors.Length");
487                         Assert.AreEqual (lgb.Blend.Positions.Length, clone.Blend.Positions.Length, "Blend.Positions.Length");
488                         Assert.AreEqual (lgb.GammaCorrection, clone.GammaCorrection, "GammaCorrection");
489                         Assert.AreEqual (lgb.LinearColors.Length, clone.LinearColors.Length, "LinearColors.Length");
490                         Assert.AreEqual (lgb.LinearColors.Length, clone.LinearColors.Length, "LinearColors.Length");
491                         Assert.AreEqual (lgb.Rectangle, clone.Rectangle, "Rectangle");
492                         Assert.AreEqual (lgb.Transform, clone.Transform, "Transform");
493                         Assert.AreEqual (lgb.WrapMode, clone.WrapMode, "WrapMode");
494                 }
495
496                 [Test]
497                 public void MultiplyTransform1_Null ()
498                 {
499                         Assert.Throws<ArgumentNullException> (() => default_brush.MultiplyTransform (null));
500                 }
501
502                 [Test]
503                 public void MultiplyTransform2_Null ()
504                 {
505                         Assert.Throws<ArgumentNullException> (() => default_brush.MultiplyTransform (null, MatrixOrder.Append));
506                 }
507
508                 [Test]
509                 public void MultiplyTransform2_Invalid ()
510                 {
511                         default_brush.MultiplyTransform (empty_matrix, (MatrixOrder) Int32.MinValue);
512                 }
513
514                 [Test]
515                 public void MultiplyTransform_NonInvertible ()
516                 {
517                         Matrix noninvertible = new Matrix (123, 24, 82, 16, 47, 30);
518                         Assert.Throws<ArgumentException> (() => default_brush.MultiplyTransform (noninvertible));
519                 }
520
521                 [Test]
522                 public void ResetTransform ()
523                 {
524                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
525                         Assert.IsFalse (lgb.Transform.IsIdentity, "Transform.IsIdentity");
526                         lgb.ResetTransform ();
527                         Assert.IsTrue (lgb.Transform.IsIdentity, "Reset.IsIdentity");
528                 }
529
530                 [Test]
531                 public void RotateTransform ()
532                 {
533                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
534                         lgb.RotateTransform (90);
535                         float[] elements = lgb.Transform.Elements;
536                         Assert.AreEqual (0, elements[0], 0.1, "matrix.0");
537                         Assert.AreEqual (1, elements[1], 0.1, "matrix.1");
538                         Assert.AreEqual (-1, elements[2], 0.1, "matrix.2");
539                         Assert.AreEqual (0, elements[3], 0.1, "matrix.3");
540                         Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
541                         Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
542
543                         lgb.RotateTransform (270);
544                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity");
545                 }
546
547                 [Test]
548                 [NUnit.Framework.Category ("NotWorking")]
549                 public void RotateTransform_Max ()
550                 {
551                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
552                         lgb.RotateTransform (Single.MaxValue);
553                         float[] elements = lgb.Transform.Elements;
554                         Assert.AreEqual (5.93904E+36, elements[0], 1e32, "matrix.0");
555                         Assert.AreEqual (5.93904E+36, elements[1], 1e32, "matrix.1");
556                         Assert.AreEqual (-5.93904E+36, elements[2], 1e32, "matrix.2");
557                         Assert.AreEqual (5.93904E+36, elements[3], 1e32, "matrix.3");
558                         Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
559                         Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
560                 }
561
562                 [Test]
563                 [NUnit.Framework.Category ("NotWorking")]
564                 public void RotateTransform_Min ()
565                 {
566                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
567                         lgb.RotateTransform (Single.MinValue);
568                         float[] elements = lgb.Transform.Elements;
569                         Assert.AreEqual (-5.93904E+36, elements[0], 1e32, "matrix.0");
570                         Assert.AreEqual (-5.93904E+36, elements[1], 1e32, "matrix.1");
571                         Assert.AreEqual (5.93904E+36, elements[2], 1e32, "matrix.2");
572                         Assert.AreEqual (-5.93904E+36, elements[3], 1e32, "matrix.3");
573                         Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
574                         Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
575                 }
576
577                 [Test]
578                 public void RotateTransform_InvalidOrder ()
579                 {
580                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
581                         Assert.Throws<ArgumentException> (() => lgb.RotateTransform (720, (MatrixOrder) Int32.MinValue));
582                 }
583
584                 [Test]
585                 public void ScaleTransform ()
586                 {
587                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
588                         lgb.ScaleTransform (2, 4);
589                         float[] elements = lgb.Transform.Elements;
590                         Assert.AreEqual (2, elements[0], 0.1, "matrix.0");
591                         Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
592                         Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
593                         Assert.AreEqual (4, elements[3], 0.1, "matrix.3");
594                         Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
595                         Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
596
597                         lgb.ScaleTransform (0.5f, 0.25f);
598                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity");
599                 }
600
601                 [Test]
602                 public void ScaleTransform_45 ()
603                 {
604                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f);
605                         lgb.ScaleTransform (3, 3);
606                         float[] elements = lgb.Transform.Elements;
607                         Assert.AreEqual (3, elements[0], 0.1, "matrix.0");
608                         Assert.AreEqual (3, elements[1], 0.1, "matrix.1");
609                         Assert.AreEqual (-3, elements[2], 0.1, "matrix.2");
610                         Assert.AreEqual (3, elements[3], 0.1, "matrix.3");
611                         Assert.AreEqual (16, elements[4], 0.1, "matrix.4");
612                         Assert.AreEqual (-16, elements[5], 0.1, "matrix.5");
613                 }
614
615                 [Test]
616                 public void ScaleTransform_MaxMin ()
617                 {
618                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
619                         lgb.ScaleTransform (Single.MaxValue, Single.MinValue);
620                         float[] elements = lgb.Transform.Elements;
621                         Assert.AreEqual (Single.MaxValue, elements[0], 1e33, "matrix.0");
622                         Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
623                         Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
624                         Assert.AreEqual (Single.MinValue, elements[3], 1e33, "matrix.3");
625                         Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
626                         Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
627                 }
628
629                 [Test]
630                 public void ScaleTransform_InvalidOrder ()
631                 {
632                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
633                         Assert.Throws<ArgumentException> (() => lgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue));
634                 }
635
636                 [Test]
637                 public void SetBlendTriangularShape_Focus ()
638                 {
639                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
640                         // max valid
641                         lgb.SetBlendTriangularShape (1);
642                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
643                         // min valid
644                         lgb.SetBlendTriangularShape (0);
645                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
646                         // middle
647                         lgb.SetBlendTriangularShape (0.5f);
648                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
649                         // no impact on matrix
650                 }
651
652                 [Test]
653                 public void SetBlendTriangularShape_Scale ()
654                 {
655                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
656                         // max valid
657                         lgb.SetBlendTriangularShape (0, 1);
658                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
659                         // min valid
660                         lgb.SetBlendTriangularShape (1, 0);
661                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
662                         // middle
663                         lgb.SetBlendTriangularShape (0.5f, 0.5f);
664                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
665                         // no impact on matrix
666                 }
667
668                 [Test]
669                 public void SetBlendTriangularShape_FocusTooSmall ()
670                 {
671                         Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (-1));
672                 }
673
674                 [Test]
675                 public void SetBlendTriangularShape_FocusTooBig ()
676                 {
677                         Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (1.01f));
678                 }
679
680                 [Test]
681                 public void SetBlendTriangularShape_ScaleTooSmall ()
682                 {
683                         Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (1, -1));
684                 }
685
686                 [Test]
687                 public void SetBlendTriangularShape_ScaleTooBig ()
688                 {
689                         Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (1, 1.01f));
690                 }
691
692                 [Test]
693                 public void SetSigmaBellShape_Focus ()
694                 {
695                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
696                         // max valid
697                         lgb.SetSigmaBellShape (1);
698                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
699                         // min valid
700                         lgb.SetSigmaBellShape (0);
701                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
702                         // middle
703                         lgb.SetSigmaBellShape (0.5f);
704                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
705                         // no impact on matrix
706                 }
707
708                 [Test]
709                 public void SetSigmaBellShape_Scale ()
710                 {
711                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
712                         // max valid
713                         lgb.SetSigmaBellShape (0, 1);
714                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
715                         // min valid
716                         lgb.SetSigmaBellShape (1, 0);
717                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-2");
718                         // middle
719                         lgb.SetSigmaBellShape (0.5f, 0.5f);
720                         Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-3");
721                         // no impact on matrix
722                 }
723
724                 [Test]
725                 public void SetSigmaBellShape_FocusTooSmall ()
726                 {
727                         Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (-1));
728                 }
729
730                 [Test]
731                 public void SetSigmaBellShape_FocusTooBig ()
732                 {
733                         Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (1.01f));
734                 }
735
736                 [Test]
737                 public void SetSigmaBellShape_ScaleTooSmall ()
738                 {
739                         Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (1, -1));
740                 }
741
742                 [Test]
743                 public void SetSigmaBellShape_ScaleTooBig ()
744                 {
745                         Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (1, 1.01f));
746                 }
747
748                 [Test]
749                 public void TranslateTransform ()
750                 {
751                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
752                         lgb.TranslateTransform (1, 1);
753                         float[] elements = lgb.Transform.Elements;
754                         Assert.AreEqual (1, elements[0], 0.1, "matrix.0");
755                         Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
756                         Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
757                         Assert.AreEqual (1, elements[3], 0.1, "matrix.3");
758                         Assert.AreEqual (1, elements[4], 0.1, "matrix.4");
759                         Assert.AreEqual (1, elements[5], 0.1, "matrix.5");
760
761                         lgb.TranslateTransform (-1, -1);
762                         // strangely lgb.Transform.IsIdentity is false
763                         elements = lgb.Transform.Elements;
764                         Assert.AreEqual (1, elements[0], 0.1, "revert.matrix.0");
765                         Assert.AreEqual (0, elements[1], 0.1, "revert.matrix.1");
766                         Assert.AreEqual (0, elements[2], 0.1, "revert.matrix.2");
767                         Assert.AreEqual (1, elements[3], 0.1, "revert.matrix.3");
768                         Assert.AreEqual (0, elements[4], 0.1, "revert.matrix.4");
769                         Assert.AreEqual (0, elements[5], 0.1, "revert.matrix.5");
770                 }
771
772                 [Test]
773                 public void TranslateTransform_InvalidOrder ()
774                 {
775                         LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
776                         Assert.Throws<ArgumentException> (() => lgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue));
777                 }
778
779                 [Test]
780                 public void Transform_Operations ()
781                 {
782                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f);
783                         Matrix clone = lgb.Transform.Clone ();
784                         Matrix mul = clone.Clone ();
785
786                         clone.Multiply (mul, MatrixOrder.Append);
787                         lgb.MultiplyTransform (mul, MatrixOrder.Append);
788                         Assert.AreEqual (lgb.Transform, clone, "Multiply/Append");
789
790                         clone.Multiply (mul, MatrixOrder.Prepend);
791                         lgb.MultiplyTransform (mul, MatrixOrder.Prepend);
792                         Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend");
793
794                         clone.Rotate (45, MatrixOrder.Append);
795                         lgb.RotateTransform (45, MatrixOrder.Append);
796                         Assert.AreEqual (lgb.Transform, clone, "Rotate/Append");
797
798                         clone.Rotate (45, MatrixOrder.Prepend);
799                         lgb.RotateTransform (45, MatrixOrder.Prepend);
800                         Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend");
801
802                         clone.Scale (0.25f, 2, MatrixOrder.Append);
803                         lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
804                         Assert.AreEqual (lgb.Transform, clone, "Scale/Append");
805
806                         clone.Scale (0.25f, 2, MatrixOrder.Prepend);
807                         lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
808                         Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend");
809
810                         clone.Translate (10, 20, MatrixOrder.Append);
811                         lgb.TranslateTransform (10, 20, MatrixOrder.Append);
812                         Assert.AreEqual (lgb.Transform, clone, "Translate/Append");
813
814                         clone.Translate (30, 40, MatrixOrder.Prepend);
815                         lgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
816                         Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend");
817
818                         clone.Reset ();
819                         lgb.ResetTransform ();
820                         Assert.AreEqual (lgb.Transform, clone, "Reset");
821                 }
822
823                 [Test]
824                 public void Transform_Operations_OnScalableAngle ()
825                 {
826                         LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 360f, true);
827                         Matrix clone = lgb.Transform.Clone ();
828                         Matrix mul = clone.Clone ();
829                         Matrix m = new Matrix ();
830                         m.Scale (2, 1);
831                         m.Translate (rect.Width, rect.Height);
832                         m.Rotate (30f);
833
834                         clone.Multiply (mul, MatrixOrder.Append);
835                         lgb.MultiplyTransform (mul, MatrixOrder.Append);
836                         Assert.AreEqual (lgb.Transform, clone, "Multiply/Append");
837
838                         clone.Multiply (mul, MatrixOrder.Prepend);
839                         lgb.MultiplyTransform (mul, MatrixOrder.Prepend);
840                         Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend");
841
842                         clone.Rotate (45, MatrixOrder.Append);
843                         lgb.RotateTransform (45, MatrixOrder.Append);
844                         Assert.AreEqual (lgb.Transform, clone, "Rotate/Append");
845
846                         clone.Rotate (45, MatrixOrder.Prepend);
847                         lgb.RotateTransform (45, MatrixOrder.Prepend);
848                         Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend");
849
850                         clone.Scale (0.25f, 2, MatrixOrder.Append);
851                         lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
852                         Assert.AreEqual (lgb.Transform, clone, "Scale/Append");
853
854                         clone.Scale (0.25f, 2, MatrixOrder.Prepend);
855                         lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
856                         Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend");
857
858                         clone.Translate (10, 20, MatrixOrder.Append);
859                         lgb.TranslateTransform (10, 20, MatrixOrder.Append);
860                         Assert.AreEqual (lgb.Transform, clone, "Translate/Append");
861
862                         clone.Translate (30, 40, MatrixOrder.Prepend);
863                         lgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
864                         Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend");
865
866                         clone.Reset ();
867                         lgb.ResetTransform ();
868                         Assert.AreEqual (lgb.Transform, clone, "Reset");
869                 }
870
871                 [Test]
872                 public void Constructor_Rectangle_Angle_Scalable ()
873                 {
874                         CheckMatrixForScalableAngle (new RectangleF (0, 0, 10, 10), 15, new float[] { 1.183013f, 0.3169873f, -0.3169873f, 1.183012f, 0.6698728f, -2.5f });
875
876                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 50), 15, new float[] { 1.183012f, 0.176104f, -0.5705772f, 1.183012f, 34.77311f, -28.76387f });
877                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 50), 75, new float[] { 0.3169872f, 0.6572293f, -2.129423f, 0.3169873f, 232.2269f, 8.763878f });
878                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 50), 95, new float[] { -0.09442029f, 0.599571f, -1.942611f, -0.09442017f, 247.2034f, 48.05788f });
879                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 50), 150, new float[] { -1.183013f, 0.3794515f, -1.229423f, -1.183013f, 268.2269f, 157.0972f });
880                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 50), 215, new float[] { -1.140856f, -0.4437979f, 1.437905f, -1.140856f, 38.34229f, 215.2576f });
881                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 50), 300, new float[] { 0.6830127f, -0.6572294f, 2.129422f, 0.6830124f, -157.2269f, 76.23613f });
882
883                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 150), 15, new float[] { 1.183012f, 0.5283121f, -0.1901924f, 1.183012f, 11.95002f, -64.33012f });
884                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 150), 75, new float[] { 0.3169872f, 1.971688f, -0.7098077f, 0.3169872f, 147.05f, -55.66987f });
885                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 150), 95, new float[] { -0.09442029f, 1.798713f, -0.6475369f, -0.09442022f, 169.499f, 12.84323f });
886                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 150), 150, new float[] { -1.183013f, 1.138354f, -0.4098077f, -1.183013f, 219.05f, 209.3301f });
887                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 150), 215, new float[] { -1.140856f, -1.331394f, 0.4793016f, -1.140856f, 95.85849f, 388.8701f });
888                         CheckMatrixForScalableAngle (new RectangleF (30, 60, 90, 150), 300, new float[] { 0.6830127f, -1.971688f, 0.7098075f, 0.6830125f, -72.04998f, 190.6699f });
889                 }
890
891                 [Test]
892                 public void LinearColors_Null ()
893                 {
894                         Assert.Throws<NullReferenceException> (() => default_brush.LinearColors = null);
895                 }
896
897                 [Test]
898                 public void InterpolationColors_Null ()
899                 {
900                         Assert.Throws<ArgumentException> (() => default_brush.InterpolationColors = null);
901                 }
902
903                 [Test]
904                 public void Blend_Null ()
905                 {
906                         Assert.Throws<NullReferenceException> (() => default_brush.Blend = null);
907                 }
908
909                 [Test]
910                 public void ZeroWidthRectangle ()
911                 {
912                         Rectangle r = new Rectangle (10, 10, 0, 10);
913                         Assert.AreEqual (0, r.Width, "Width");
914                         Assert.Throws<ArgumentException> (() => new LinearGradientBrush (r, Color.Red, Color.Blue, LinearGradientMode.Vertical));
915                 }
916
917                 [Test]
918                 public void ZeroHeightRectangleF ()
919                 {
920                         RectangleF r = new RectangleF (10.0f, 10.0f, 10.0f, 0.0f);
921                         Assert.AreEqual (0.0f, r.Height, "Height");
922                         Assert.Throws<ArgumentException> (() => new LinearGradientBrush (r, Color.Red, Color.Blue, LinearGradientMode.Vertical));
923                 }
924         }
925 }