2009-01-16 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / ControlBindingsConverterTest.cs
1 //
2 // Copyright (c) 2006 Novell, Inc.
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7
8 using System;
9 using System.Windows.Forms;
10 using System.Drawing;
11 using System.Threading;
12 using System.ComponentModel;
13 using System.Runtime.Remoting;
14
15 using NUnit.Framework;
16
17 namespace MonoTests.System.Windows.Forms.Design
18 {
19         [TestFixture]
20         public class ControlBindingsConverterTest : TestHelper
21         {
22
23                 [Test]
24                 [NUnit.Framework.Category ("NotWorking")]
25                 public void TestProperties ()
26                 {
27                         Control c = new Control ();
28                         ControlBindingsCollection col = c.DataBindings;
29
30                         TypeConverter cvt = TypeDescriptor.GetConverter (col);
31
32                         Assert.IsNotNull (cvt, "1");
33
34                         Assert.IsTrue (cvt.GetPropertiesSupported (null), "2");
35                         
36                         PropertyDescriptorCollection props = cvt.GetProperties (null, col, null);
37                         
38                         Assert.AreEqual (3, props.Count, "3");
39
40                         Assert.AreEqual ("Tag", props[0].Name, "4");
41                         Console.WriteLine (props[0].GetType());
42                         Console.WriteLine ("tag value = {0}", props[0].GetValue (col));
43                         Console.WriteLine ("tag converter = {0}", props[0].Converter);
44                         Console.WriteLine ("tag localizable = {0}", props[0].IsLocalizable);
45                         Console.WriteLine ("tag readonly = {0}", props[0].IsReadOnly);
46                         Console.WriteLine ("tag type = {0}", props[0].PropertyType);
47                         Console.WriteLine ("tag category = {0}", props[0].Category);
48                         Console.WriteLine ("tag description = {0}", props[0].Description);
49                         Console.WriteLine ("tag displaynem = {0}", props[0].DisplayName);
50                         Console.WriteLine ("tag has {0} attributes", props[0].Attributes.Count);
51
52                         Assert.AreEqual ("Text", props[1].Name, "5");
53                         Console.WriteLine (props[1].GetType());
54                         Console.WriteLine ("text value = {0}", props[1].GetValue (col));
55                         Console.WriteLine ("text converter = {0}", props[1].Converter);
56                         Console.WriteLine ("text localizable = {0}", props[1].IsLocalizable);
57                         Console.WriteLine ("text readonly = {0}", props[1].IsReadOnly);
58                         Console.WriteLine ("text type = {0}", props[1].PropertyType);
59                         Console.WriteLine ("text category = {0}", props[1].Category);
60                         Console.WriteLine ("text description = {0}", props[1].Description);
61                         Console.WriteLine ("text displaynem = {0}", props[1].DisplayName);
62                         Console.WriteLine ("text has {0} attributes", props[1].Attributes.Count);
63
64                         Assert.AreEqual ("(Advanced)", props[2].Name, "6");
65                         Console.WriteLine (props[2].GetType());
66                         Console.WriteLine ("advanced value = {0}", props[2].GetValue (col));
67                         TypeConverter propcvt = props[2].Converter;
68                         Console.WriteLine ("advanced converter = {0}", propcvt.GetType());
69                         Console.WriteLine ("");
70                         if (null == propcvt.GetProperties(props[2].GetValue (col)))
71                                 Console.WriteLine ("null properties");
72                         else
73                                 Console.WriteLine ("  {0} properties", propcvt.GetProperties(props[2].GetValue (col)).Count);
74                         Console.WriteLine ("advanced converter = {0}/{1}/{2}",
75                                            propcvt.GetPropertiesSupported (),
76                                            propcvt.GetStandardValuesSupported (),
77                                            propcvt.GetCreateInstanceSupported ());
78                         Console.WriteLine ("advanced localizable = {0}", props[2].IsLocalizable);
79                         Console.WriteLine ("advanced readonly = {0}", props[2].IsReadOnly);
80                         Console.WriteLine ("advanced type = {0}", props[2].PropertyType);
81                         Console.WriteLine ("advanced category = {0}", props[2].Category);
82                         Console.WriteLine ("advanced description = {0}", props[2].Description);
83                         Console.WriteLine ("advanced displaynem = {0}", props[2].DisplayName);
84                         Console.WriteLine ("advanced has {0} attributes", props[2].Attributes.Count);
85                         foreach (Attribute a in props[2].Attributes) {
86                                 Console.WriteLine ("   attribute =  {0}", a);
87                         }
88                 }
89         }
90 }