ToolboxItemAttributeTests.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // System.ComponentModel.ToolboxItemAttribute test cases
  3. //
  4. // Authors:
  5. // Gert Driesen ([email protected])
  6. //
  7. // (c) 2005 Novell
  8. using System;
  9. using System.ComponentModel;
  10. using System.Drawing.Design;
  11. using NUnit.Framework;
  12. namespace MonoTests.System.ComponentModel
  13. {
  14. [TestFixture]
  15. public class ToolboxItemAttributeTests
  16. {
  17. [Test]
  18. public void DefaultType ()
  19. {
  20. ToolboxItemAttribute attr = new ToolboxItemAttribute (true);
  21. Type toolboxItemType = typeof(ToolboxItem);
  22. Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, attr.ToolboxItemTypeName, "#1");
  23. Assert.AreEqual (toolboxItemType, attr.ToolboxItemType, "#2");
  24. Assert.AreEqual (true, attr.IsDefaultAttribute (), "#3");
  25. Assert.AreEqual (attr.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4");
  26. Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, ToolboxItemAttribute.Default.ToolboxItemTypeName, "#5");
  27. Assert.AreEqual (toolboxItemType, ToolboxItemAttribute.Default.ToolboxItemType, "#2");
  28. Assert.AreEqual (true, ToolboxItemAttribute.Default.IsDefaultAttribute (), "#3");
  29. Assert.AreEqual (ToolboxItemAttribute.Default.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4");
  30. }
  31. [Test]
  32. public void NonDefaultType ()
  33. {
  34. ToolboxItemAttribute attr = new ToolboxItemAttribute (false);
  35. Assert.AreEqual (string.Empty, attr.ToolboxItemTypeName, "#1");
  36. Assert.IsNull (attr.ToolboxItemType, "#2");
  37. Assert.AreEqual (false, attr.IsDefaultAttribute (), "#3");
  38. Assert.AreEqual (string.Empty, ToolboxItemAttribute.None.ToolboxItemTypeName, "#4");
  39. Assert.IsNull (ToolboxItemAttribute.None.ToolboxItemType, "#5");
  40. Assert.AreEqual (false, ToolboxItemAttribute.None.IsDefaultAttribute (), "#6");
  41. }
  42. [Test]
  43. [ExpectedException (typeof (ArgumentException))]
  44. public void InvalidItemTypeName ()
  45. {
  46. ToolboxItemAttribute attr = new ToolboxItemAttribute ("typedoesnotexist");
  47. // this next statement should fail
  48. Type type = attr.ToolboxItemType;
  49. }
  50. }
  51. }