5910489b474e0f0b04b9f646027e5257fb1b485d
[mono.git] / mcs / class / System / Test / System.ComponentModel / ToolboxItemAttributeTests.cs
1 //
2 // System.ComponentModel.ToolboxItemAttribute test cases
3 //
4 // Authors:
5 //      Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // (c) 2005 Novell
8
9 using System;
10 using System.ComponentModel;
11
12 using NUnit.Framework;
13
14 namespace MonoTests.System.ComponentModel 
15 {
16         [TestFixture]
17         public class ToolboxItemAttributeTests
18         {
19 #if !MOBILE
20                 [Test]
21 #if TARGET_JVM
22                 [Ignore ("TD BUG ID: 7215, 7216")]
23 #endif
24                 public void DefaultType ()
25                 {
26                         ToolboxItemAttribute attr = new ToolboxItemAttribute (true);
27                         
28                         Type toolboxItemType = typeof(global::System.Drawing.Design.ToolboxItem);
29
30                         Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, attr.ToolboxItemTypeName, "#1");
31                         Assert.AreEqual (toolboxItemType, attr.ToolboxItemType, "#2");
32                         Assert.AreEqual (true, attr.IsDefaultAttribute (), "#3");
33                         Assert.AreEqual (attr.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4");
34
35                         Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, ToolboxItemAttribute.Default.ToolboxItemTypeName, "#5");
36                         Assert.AreEqual (toolboxItemType, ToolboxItemAttribute.Default.ToolboxItemType, "#2");
37                         Assert.AreEqual (true, ToolboxItemAttribute.Default.IsDefaultAttribute (), "#3");
38                         Assert.AreEqual (ToolboxItemAttribute.Default.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4");
39                 }
40 #endif
41                 [Test]
42                 public void NonDefaultType ()
43                 {
44                         ToolboxItemAttribute attr = new ToolboxItemAttribute (false);
45                         Assert.AreEqual (string.Empty, attr.ToolboxItemTypeName, "#1");
46                         Assert.IsNull (attr.ToolboxItemType, "#2");
47                         Assert.AreEqual (false, attr.IsDefaultAttribute (), "#3");
48
49                         Assert.AreEqual (string.Empty, ToolboxItemAttribute.None.ToolboxItemTypeName, "#4");
50                         Assert.IsNull (ToolboxItemAttribute.None.ToolboxItemType, "#5");
51                         Assert.AreEqual (false, ToolboxItemAttribute.None.IsDefaultAttribute (), "#6");
52                 }
53
54                 [Test]
55                 [ExpectedException (typeof (ArgumentException))]
56                 public void InvalidItemTypeName ()
57                 {
58                         ToolboxItemAttribute attr = new ToolboxItemAttribute ("typedoesnotexist");
59                         // this next statement should fail
60                         Type type = attr.ToolboxItemType;
61                 }
62         }
63 }