2 using System.Drawing;
\r
3 using System.Drawing.Drawing2D;
\r
4 using NUnit.Framework;
\r
5 using DrawingTestHelper;
\r
6 using System.Reflection;
\r
8 namespace Test.Sys.Drawing
\r
11 /// Summary description for Pens.
\r
15 public class PensFixture
\r
19 public void SetUp ()
\r
24 private string [] ar_pens = {
\r
92 "LightGoldenrodYellow",
\r
107 "MediumAquamarine",
\r
113 "MediumSpringGreen",
\r
167 string [] ar_system_pens = {
\r
168 "ActiveCaptionText",
\r
174 "ControlLightLight",
\r
178 "InactiveCaptionText",
\r
187 public void PensPropertyCount()
\r
189 Type t = typeof(Pens);
\r
190 PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
\r
193 foreach (PropertyInfo p in pi)
\r
195 if (p.PropertyType == typeof(Pen))
\r
200 Assert.AreEqual(ar_pens.Length, i, "Number of Pens");
\r
204 public void SystemPensPropertyCount()
\r
206 Type t = typeof(SystemPens);
\r
207 PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
\r
210 foreach (PropertyInfo p in pi)
\r
212 if (p.PropertyType == typeof(Pen))
\r
217 Assert.AreEqual(ar_system_pens.Length, i, "Number of System Pens");
\r
221 public void PensProperties ()
\r
223 Type t = typeof(Pens);
\r
224 foreach (string s in ar_pens)
\r
226 MemberInfo [] mi = t.GetMember(s);
\r
228 if (mi.Length == 1)
\r
230 if (mi[0].MemberType == MemberTypes.Property)
\r
232 PropertyInfo p = (PropertyInfo)mi[0];
\r
233 Pen pen = (Pen)p.GetValue(null, null);
\r
234 Assert.AreEqual("Color [" + s + "]", pen.Color.ToString());
\r
238 Assert.Fail(s + " is not property of Pens class");
\r
243 Assert.Fail("Property " + s + " not found in Pens class");
\r
249 public void SystemPensProperties ()
\r
251 Type t = typeof(SystemPens);
\r
252 foreach (string s in ar_system_pens)
\r
254 MemberInfo [] mi = t.GetMember(s);
\r
256 if (mi.Length == 1)
\r
258 if (mi[0].MemberType == MemberTypes.Property)
\r
260 PropertyInfo p = (PropertyInfo)mi[0];
\r
261 Pen pen = (Pen)p.GetValue(null, null);
\r
262 Assert.AreEqual("Color [" + s + "]", pen.Color.ToString());
\r
266 Assert.Fail(s + " is not property of SystemPens class");
\r
271 Assert.Fail("Property " + s + " not found in SystemPens class");
\r
277 public void PenAssignValue ()
\r
279 Type t = typeof(Pens);
\r
280 foreach (string s in ar_pens)
\r
282 MemberInfo [] mi = t.GetMember(s);
\r
284 if (mi.Length == 1)
\r
286 if (mi[0].MemberType == MemberTypes.Property)
\r
288 PropertyInfo p = (PropertyInfo)mi[0];
\r
289 Pen pen = (Pen)p.GetValue(null, null);
\r
293 pen.Color = Color.AliceBlue;
\r
294 Assert.Fail("Pen.Color must throw exception");
\r
296 catch(ArgumentException)
\r
298 Assert.IsTrue(true);
\r
303 Assert.Fail(s + " is not property of Pens class");
\r
308 Assert.Fail("Property " + s + " not found in Pens class");
\r
314 public void SystemPenAssignValue ()
\r
316 Type t = typeof(SystemPens);
\r
317 foreach (string s in ar_system_pens)
\r
319 MemberInfo [] mi = t.GetMember(s);
\r
321 if (mi.Length == 1)
\r
323 if (mi[0].MemberType == MemberTypes.Property)
\r
325 PropertyInfo p = (PropertyInfo)mi[0];
\r
326 Pen pen = (Pen)p.GetValue(null, null);
\r
330 pen.Color = Color.AliceBlue;
\r
331 Assert.Fail("SystemPen.Color must throw exception");
\r
333 catch(ArgumentException)
\r
335 Assert.IsTrue(true);
\r
340 Assert.Fail(s + " is not property of SystemPen class");
\r
345 Assert.Fail("Property " + s + " not found in SystemPen class");
\r