StatusBarPanelTest.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // StatusBarPanelTest.cs: Test cases for StatusBar.
  3. //
  4. // (C) 2006 Novell, Inc. (http://www.novell.com)
  5. //
  6. using System;
  7. using NUnit.Framework;
  8. using System.Windows.Forms;
  9. using System.Drawing;
  10. using System.Runtime.Remoting;
  11. namespace MonoTests.System.Windows.Forms
  12. {
  13. [TestFixture]
  14. public class StatusBarPanelTest
  15. {
  16. [Test]
  17. public void MinimumWidth1 ()
  18. {
  19. StatusBarPanel p = new StatusBarPanel ();
  20. Assert.AreEqual (10, p.MinWidth, "1");
  21. }
  22. [Test]
  23. public void MinimumWidth2 ()
  24. {
  25. StatusBarPanel p = new StatusBarPanel ();
  26. p.Width = 50;
  27. p.MinWidth = 100;
  28. Assert.AreEqual (100, p.Width, "1");
  29. }
  30. [Test]
  31. public void MinimumWidth3 ()
  32. {
  33. StatusBarPanel p = new StatusBarPanel ();
  34. p.Width = 50;
  35. p.MinWidth = 200;
  36. p.MinWidth = 25;
  37. Assert.AreEqual (200, p.Width, "#1");
  38. p = new StatusBarPanel ();
  39. p.Width = 50;
  40. p.MinWidth = 25;
  41. Assert.AreEqual (50, p.Width, "#2");
  42. p = new StatusBarPanel ();
  43. p.Width = 50;
  44. p.MinWidth = 100;
  45. Assert.AreEqual (100, p.Width, "#3");
  46. p = new StatusBarPanel ();
  47. p.MinWidth = 200;
  48. Assert.AreEqual (200, p.Width, "#4");
  49. }
  50. [Test]
  51. #if NET_2_0
  52. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  53. #else
  54. [ExpectedException(typeof(ArgumentException))]
  55. #endif
  56. public void MinimumWidth4 ()
  57. {
  58. StatusBarPanel p = new StatusBarPanel ();
  59. p.MinWidth = -50;
  60. }
  61. [Test]
  62. public void MinWidth_AutoSize_None ()
  63. {
  64. StatusBarPanel p = new StatusBarPanel ();
  65. p.Width = 50;
  66. Assert.AreEqual (10, p.MinWidth, "#1");
  67. }
  68. [Test]
  69. public void ToStringTest ()
  70. {
  71. StatusBarPanel p = new StatusBarPanel ();
  72. Assert.AreEqual ("StatusBarPanel: {}", p.ToString(), "1");
  73. p.Text = "Hello";
  74. Assert.AreEqual ("StatusBarPanel: {Hello}", p.ToString(), "2");
  75. p.Text = "}";
  76. Assert.AreEqual ("StatusBarPanel: {}}", p.ToString(), "3");
  77. }
  78. [Test]
  79. public void DefaultPropertiesTest ()
  80. {
  81. StatusBarPanel p = new StatusBarPanel ();
  82. Assert.AreEqual (100, p.Width, "#1");
  83. Assert.AreEqual (10, p.MinWidth, "#2");
  84. Assert.AreEqual (String.Empty, p.Text, "#3");
  85. Assert.AreEqual (HorizontalAlignment.Left, p.Alignment, "#4");
  86. Assert.AreEqual (StatusBarPanelAutoSize.None, p.AutoSize, "#5");
  87. Assert.AreEqual (StatusBarPanelBorderStyle.Sunken, p.BorderStyle, "#6");
  88. Assert.AreEqual (StatusBarPanelStyle.Text, p.Style, "#7");
  89. Assert.AreEqual (String.Empty, p.ToolTipText, "#8");
  90. }
  91. #if NET_2_0
  92. [Test]
  93. public void TagTest ()
  94. {
  95. StatusBarPanel p = new StatusBarPanel ();
  96. Assert.AreEqual (null, p.Tag, "#1");
  97. p.Tag = "a";
  98. Assert.AreEqual ("a", p.Tag, "#2");
  99. p.Tag = null;
  100. Assert.AreEqual (null, p.Tag, "#3");
  101. }
  102. [Test]
  103. public void NameTest ()
  104. {
  105. StatusBarPanel p = new StatusBarPanel ();
  106. Assert.AreEqual ("", p.Name, "#1");
  107. p.Name = "a";
  108. Assert.AreEqual ("a", p.Name, "#2");
  109. p.Name = null;
  110. Assert.AreEqual ("", p.Name, "#3");
  111. }
  112. #endif
  113. }
  114. }