2 // Tests for System.Web.UI.MinimizableAttributeTypeConvert.cs
5 // Chris Toshok (toshok@ximian.com)
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.ComponentModel;
33 using System.ComponentModel.Design.Serialization;
36 using System.Web.UI.HtmlControls;
37 using System.Reflection;
38 using NUnit.Framework;
41 namespace MonoTests.System.Web.UI {
44 public class MinimizableAttributeTypeConverterTest {
45 private TypeConverter GetTypeConverter ()
47 Type t = typeof (HtmlTableCell);
49 PropertyInfo pi = null;
52 props = t.GetProperties();
54 foreach (PropertyInfo p in props) {
55 if (p.Name == "NoWrap") {
61 object[] attrs = pi.GetCustomAttributes (typeof (TypeConverterAttribute), false);
62 TypeConverterAttribute tca = (TypeConverterAttribute)attrs[0];
64 Type tct = Type.GetType (tca.ConverterTypeName);
65 tc = (TypeConverter)Activator.CreateInstance (tct);
72 [NUnit.Framework.Category ("NotWorking")]
\r
74 public void CanConvertFrom ()
76 TypeConverter tc = GetTypeConverter ();
78 Assert.IsFalse (tc.CanConvertFrom (typeof (bool)), "A1");
79 Assert.IsTrue (tc.CanConvertFrom (typeof (string)), "A2");
80 Assert.IsTrue (tc.CanConvertFrom (typeof (InstanceDescriptor)), "A3");
84 public void CanConvertTo ()
86 TypeConverter tc = GetTypeConverter ();
88 Assert.IsFalse (tc.CanConvertTo (typeof (bool)), "A1");
89 Assert.IsTrue (tc.CanConvertTo (typeof (string)), "A2");
90 Assert.IsFalse (tc.CanConvertTo (typeof (InstanceDescriptor)), "A3");
94 public void ConvertFrom ()
96 TypeConverter tc = GetTypeConverter ();
98 Assert.AreEqual ("hi", tc.ConvertTo ("hi", typeof (string)), "A1");
99 Assert.AreEqual ("", tc.ConvertTo ("", typeof (string)), "A2");
103 [ExpectedException (typeof (NotSupportedException))]
104 public void ConvertFromNull ()
106 TypeConverter tc = GetTypeConverter ();
108 tc.ConvertFrom (null);
113 public void ConvertTo ()
115 TypeConverter tc = GetTypeConverter ();
117 Assert.AreEqual ("hi", tc.ConvertTo ("hi", typeof (string)), "A1");
118 Assert.AreEqual ("", tc.ConvertTo ("", typeof (string)), "A2");
119 Assert.AreEqual ("", tc.ConvertTo (null, typeof (string)), "A3");
120 Assert.AreEqual ("False", tc.ConvertTo (false, typeof (string)), "A4");
121 Assert.AreEqual ("True", tc.ConvertTo (true, typeof (string)), "A5");