ButtonTest.cs 2.4 KB

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