Merge branch 'patch-1' of https://github.com/ReubenBond/mono into ReubenBond-patch-1
[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                 public void DefaultType ()
22                 {
23                         ToolboxItemAttribute attr = new ToolboxItemAttribute (true);
24                         
25                         Type toolboxItemType = typeof(global::System.Drawing.Design.ToolboxItem);
26
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");
31
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");
36                 }
37 #endif
38                 [Test]
39                 public void NonDefaultType ()
40                 {
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");
45
46                         Assert.AreEqual (string.Empty, ToolboxItemAttribute.None.ToolboxItemTypeName, "#4");
47                         Assert.IsNull (ToolboxItemAttribute.None.ToolboxItemType, "#5");
48                         Assert.AreEqual (false, ToolboxItemAttribute.None.IsDefaultAttribute (), "#6");
49                 }
50
51                 [Test]
52                 [ExpectedException (typeof (ArgumentException))]
53                 public void InvalidItemTypeName ()
54                 {
55                         ToolboxItemAttribute attr = new ToolboxItemAttribute ("typedoesnotexist");
56                         // this next statement should fail
57                         Type type = attr.ToolboxItemType;
58                 }
59         }
60 }