TestToolboxItem.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. // Authors:
  24. //
  25. // Jordi Mas i Hernandez, [email protected]
  26. //
  27. using System;
  28. using System.Collections;
  29. using System.Reflection;
  30. using System.Drawing;
  31. using System.Drawing.Design;
  32. using NUnit.Framework;
  33. namespace MonoTests.System.Drawing.Design
  34. {
  35. [TestFixture]
  36. public class TestToolboxItem
  37. {
  38. class OurToolboxItem: ToolboxItem
  39. {
  40. public OurToolboxItem () {}
  41. public void _CheckUnlocked ()
  42. {
  43. CheckUnlocked ();
  44. }
  45. }
  46. [Test]
  47. public void TestProperties ()
  48. {
  49. ToolboxItem item = new ToolboxItem ();
  50. AssemblyName name = new AssemblyName ();
  51. name.Name = "OurAssembly";
  52. item.AssemblyName = name;
  53. Assert.AreEqual (name.Name.ToString (), "OurAssembly", "TP#1");
  54. item.TypeName = "TypeName1";
  55. Assert.AreEqual ("TypeName1", item.TypeName, "TP#2");
  56. item.DisplayName = "ShowName";
  57. Assert.AreEqual (item.DisplayName, "ShowName", "TP#3");
  58. item.TypeName = "TypeNameSt";
  59. Assert.AreEqual (item.TypeName, "TypeNameSt", "TP#4");
  60. Bitmap bmp = new Bitmap (200, 200);
  61. item.Bitmap = bmp;
  62. Assert.AreEqual (bmp, item.Bitmap, "TP#5");
  63. }
  64. [Test]
  65. [ExpectedException (typeof (InvalidOperationException))]
  66. public void TestCheckUnlocked1 ()
  67. {
  68. OurToolboxItem item = new OurToolboxItem ();
  69. item.Lock ();
  70. item._CheckUnlocked ();
  71. }
  72. [Test]
  73. public void TestCheckUnlocked2 ()
  74. {
  75. OurToolboxItem item = new OurToolboxItem ();
  76. item._CheckUnlocked ();
  77. }
  78. #if NET_2_0
  79. [Test]
  80. public void TestNewProperties ()
  81. {
  82. ToolboxItem item = new ToolboxItem ();
  83. item.Company = "OurCompany";
  84. Assert.AreEqual ("OurCompany", item.Company, "TNP#1");
  85. Assert.AreEqual (".NET Component", item.ComponentType, "TNP#2");
  86. item.Description = "Description";
  87. Assert.AreEqual ("Description", item.Description, "TNP#3");
  88. item.IsTransient = true;
  89. Assert.AreEqual (true, item.IsTransient, "TNP#4");
  90. }
  91. #endif
  92. }
  93. }