TestToolboxItem.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. [TearDown]
  47. public void Clean() {}
  48. [SetUp]
  49. public void GetReady()
  50. {
  51. }
  52. [Test]
  53. public void TestProperties ()
  54. {
  55. ToolboxItem item = new ToolboxItem ();
  56. AssemblyName name = new AssemblyName ();
  57. name.Name = "OurAssembly";
  58. item.AssemblyName = name;
  59. Assert.AreEqual (name.Name.ToString (), "OurAssembly", "TP#1");
  60. item.TypeName = "TypeName1";
  61. Assert.AreEqual ("TypeName1", item.TypeName, "TP#2");
  62. item.DisplayName = "ShowName";
  63. Assert.AreEqual (item.DisplayName, "ShowName", "TP#3");
  64. item.TypeName = "TypeNameSt";
  65. Assert.AreEqual (item.TypeName, "TypeNameSt", "TP#4");
  66. Bitmap bmp = new Bitmap (200, 200);
  67. item.Bitmap = bmp;
  68. Assert.AreEqual (bmp, item.Bitmap, "TP#5");
  69. }
  70. [Test]
  71. [ExpectedException (typeof (InvalidOperationException))]
  72. public void TestCheckUnlocked1 ()
  73. {
  74. OurToolboxItem item = new OurToolboxItem ();
  75. item.Lock ();
  76. item._CheckUnlocked ();
  77. }
  78. [Test]
  79. public void TestCheckUnlocked2 ()
  80. {
  81. OurToolboxItem item = new OurToolboxItem ();
  82. item._CheckUnlocked ();
  83. }
  84. #if NET_2_0
  85. [Test]
  86. public void TestNewProperties ()
  87. {
  88. ToolboxItem item = new ToolboxItem ();
  89. item.Company = "OurCompany";
  90. Assert.AreEqual ("OurCompany", item.Company, "TNP#1");
  91. Assert.AreEqual ("DotNET_ComponentType", item.ComponentType, "TNP#2");
  92. item.Description = "Description";
  93. Assert.AreEqual ("Description", item.Description, "TNP#3");
  94. item.IsTransient = true;
  95. Assert.AreEqual (true, item.IsTransient, "TNP#4");
  96. }
  97. #endif
  98. }
  99. }