ButtonTest.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // Copyright (c) 2005 Novell, Inc.
  3. //
  4. // Authors:
  5. // Ritvik Mayank ([email protected])
  6. //
  7. using System;
  8. using System.Windows.Forms;
  9. using System.Drawing;
  10. using NUnit.Framework;
  11. namespace MonoTests.System.Windows.Forms
  12. {
  13. [TestFixture]
  14. [Ignore ("This test has to be completly reviewed")]
  15. public class ButtonTest
  16. {
  17. [Test]
  18. public void FlatStyleTest ()
  19. {
  20. Button B1 = new Button ();
  21. Assert.AreEqual (FlatStyle.Standard, B1.FlatStyle, "#1");
  22. }
  23. [Test]
  24. public void ImageTest ()
  25. {
  26. Button B1 = new Button ();
  27. B1.Visible = true;
  28. B1.Image = Image.FromFile ("M.gif");
  29. Assert.AreEqual (ContentAlignment.MiddleCenter, B1.ImageAlign, "#2");
  30. }
  31. [Test]
  32. public void ImageListTest ()
  33. {
  34. Button B1 = new Button ();
  35. B1.Image = Image.FromFile ("M.gif");
  36. Assert.AreEqual (null, B1.ImageList, "#3a");
  37. ImageList ImageList1 = new ImageList ();
  38. ImageList1.Images.Add(Image.FromFile ("M.gif"));
  39. B1.ImageList = ImageList1;
  40. Assert.AreEqual (-1, B1.ImageIndex, "#3b");
  41. B1.ImageIndex = 0;
  42. Assert.AreEqual (1, B1.ImageList.Images.Count, "#3c");
  43. Assert.AreEqual (16, B1.ImageList.ImageSize.Height, "#3d");
  44. Assert.AreEqual (16, B1.ImageList.ImageSize.Width, "#3e");
  45. }
  46. [Test]
  47. public void IMeModeTest ()
  48. {
  49. Button B1 = new Button ();
  50. Assert.AreEqual (ImeMode.Disable, B1.ImeMode, "#4");
  51. }
  52. [Test]
  53. public void TextAlignTest ()
  54. {
  55. Button B1 = new Button ();
  56. Assert.AreEqual (ContentAlignment.MiddleCenter, B1.TextAlign, "#5");
  57. }
  58. [Test]
  59. public void DialogResultTest ()
  60. {
  61. Form f = new Form ();
  62. Button B1 = new Button ();
  63. B1.Text = "DialogResult";
  64. B1.DialogResult = DialogResult.No;
  65. B1.TextAlign = ContentAlignment.BottomRight;
  66. B1.Visible = true;
  67. f.Controls.Add (B1);
  68. Assert.AreEqual (DialogResult.No, B1.DialogResult, "#6");
  69. }
  70. [Test]
  71. public void PerformClickTest ()
  72. {
  73. Form f = new Form ();
  74. Button B1 = new Button ();
  75. B1.Text = "DialogResult";
  76. B1.Visible = true;
  77. f.Controls.Add (B1);
  78. B1.PerformClick ();
  79. Assert.AreEqual (DialogResult.None, B1.DialogResult, "#7");
  80. }
  81. [Test]
  82. public void NotifyDefaultTest ()
  83. {
  84. Button B1 = new Button ();
  85. Assert.AreEqual ("System.Windows.Forms.Button, Text: ", B1.ToString (), "#8");
  86. }
  87. [Test]
  88. public void ToStringTest ()
  89. {
  90. Button B1 = new Button ();
  91. Assert.AreEqual ("System.Windows.Forms.Button, Text: " , B1.ToString (), "#9");
  92. }
  93. }
  94. }