ToolboxItemAttributeTests.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #if TARGET_JVM
  19. [Ignore ("TD BUG ID: 7215, 7216")]
  20. #endif
  21. public void DefaultType ()
  22. {
  23. ToolboxItemAttribute attr = new ToolboxItemAttribute (true);
  24. Type toolboxItemType = typeof(ToolboxItem);
  25. Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, attr.ToolboxItemTypeName, "#1");
  26. Assert.AreEqual (toolboxItemType, attr.ToolboxItemType, "#2");
  27. Assert.AreEqual (true, attr.IsDefaultAttribute (), "#3");
  28. Assert.AreEqual (attr.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4");
  29. Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, ToolboxItemAttribute.Default.ToolboxItemTypeName, "#5");
  30. Assert.AreEqual (toolboxItemType, ToolboxItemAttribute.Default.ToolboxItemType, "#2");
  31. Assert.AreEqual (true, ToolboxItemAttribute.Default.IsDefaultAttribute (), "#3");
  32. Assert.AreEqual (ToolboxItemAttribute.Default.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4");
  33. }
  34. [Test]
  35. public void NonDefaultType ()
  36. {
  37. ToolboxItemAttribute attr = new ToolboxItemAttribute (false);
  38. Assert.AreEqual (string.Empty, attr.ToolboxItemTypeName, "#1");
  39. Assert.IsNull (attr.ToolboxItemType, "#2");
  40. Assert.AreEqual (false, attr.IsDefaultAttribute (), "#3");
  41. Assert.AreEqual (string.Empty, ToolboxItemAttribute.None.ToolboxItemTypeName, "#4");
  42. Assert.IsNull (ToolboxItemAttribute.None.ToolboxItemType, "#5");
  43. Assert.AreEqual (false, ToolboxItemAttribute.None.IsDefaultAttribute (), "#6");
  44. }
  45. [Test]
  46. [ExpectedException (typeof (ArgumentException))]
  47. public void InvalidItemTypeName ()
  48. {
  49. ToolboxItemAttribute attr = new ToolboxItemAttribute ("typedoesnotexist");
  50. // this next statement should fail
  51. Type type = attr.ToolboxItemType;
  52. }
  53. }
  54. }