2 // System.ComponentModel.ToolboxItemAttribute test cases
5 // Gert Driesen (drieseng@users.sourceforge.net)
10 using System
.ComponentModel
;
12 using NUnit
.Framework
;
14 namespace MonoTests
.System
.ComponentModel
17 public class ToolboxItemAttributeTests
19 #if !MOBILE && !MONOMAC
21 public void DefaultType ()
23 ToolboxItemAttribute attr
= new ToolboxItemAttribute (true);
25 Type toolboxItemType
= typeof(global::System
.Drawing
.Design
.ToolboxItem
);
27 Assert
.AreEqual (toolboxItemType
.AssemblyQualifiedName
, attr
.ToolboxItemTypeName
, "#1");
28 Assert
.AreEqual (toolboxItemType
, attr
.ToolboxItemType
, "#2");
29 Assert
.AreEqual (true, attr
.IsDefaultAttribute (), "#3");
30 Assert
.AreEqual (attr
.ToolboxItemTypeName
.GetHashCode (), attr
.GetHashCode (), "#4");
32 Assert
.AreEqual (toolboxItemType
.AssemblyQualifiedName
, ToolboxItemAttribute
.Default
.ToolboxItemTypeName
, "#5");
33 Assert
.AreEqual (toolboxItemType
, ToolboxItemAttribute
.Default
.ToolboxItemType
, "#2");
34 Assert
.AreEqual (true, ToolboxItemAttribute
.Default
.IsDefaultAttribute (), "#3");
35 Assert
.AreEqual (ToolboxItemAttribute
.Default
.ToolboxItemTypeName
.GetHashCode (), attr
.GetHashCode (), "#4");
39 public void NonDefaultType ()
41 ToolboxItemAttribute attr
= new ToolboxItemAttribute (false);
42 Assert
.AreEqual (string.Empty
, attr
.ToolboxItemTypeName
, "#1");
43 Assert
.IsNull (attr
.ToolboxItemType
, "#2");
44 Assert
.AreEqual (false, attr
.IsDefaultAttribute (), "#3");
46 Assert
.AreEqual (string.Empty
, ToolboxItemAttribute
.None
.ToolboxItemTypeName
, "#4");
47 Assert
.IsNull (ToolboxItemAttribute
.None
.ToolboxItemType
, "#5");
48 Assert
.AreEqual (false, ToolboxItemAttribute
.None
.IsDefaultAttribute (), "#6");
52 [ExpectedException (typeof (ArgumentException
))]
53 public void InvalidItemTypeName ()
55 ToolboxItemAttribute attr
= new ToolboxItemAttribute ("typedoesnotexist");
56 // this next statement should fail
57 Type type
= attr
.ToolboxItemType
;