CheckBoxEventTest.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 CheckBoxEventTest
  15. {
  16. static bool eventhandled = false;
  17. public void CheckBox_EventHandler (object sender,EventArgs e)
  18. {
  19. eventhandled = true;
  20. }
  21. [Test]
  22. public void ApperanceEventTest ()
  23. {
  24. Form myform = new Form ();
  25. myform.ShowInTaskbar = false;
  26. myform.Visible = true;
  27. CheckBox chkbox = new CheckBox ();
  28. chkbox.Visible = true;
  29. myform.Controls.Add (chkbox);
  30. chkbox.AppearanceChanged += new EventHandler (CheckBox_EventHandler);
  31. chkbox.Appearance = Appearance.Button;
  32. Assert.AreEqual (true, eventhandled, "#A1");
  33. myform.Dispose ();
  34. }
  35. [Test]
  36. public void CheckedChangedEventTest ()
  37. {
  38. Form myform = new Form ();
  39. myform.ShowInTaskbar = false;
  40. eventhandled = false;
  41. myform.Visible = true;
  42. CheckBox chkbox = new CheckBox ();
  43. chkbox.Visible = true;
  44. myform.Controls.Add (chkbox);
  45. chkbox.CheckedChanged += new EventHandler (CheckBox_EventHandler);
  46. chkbox.CheckState = CheckState.Indeterminate;
  47. Assert.AreEqual (true, eventhandled, "#A2");
  48. myform.Dispose ();
  49. }
  50. [Test]
  51. public void CheckStateChangedEventTest ()
  52. {
  53. Form myform = new Form ();
  54. myform.ShowInTaskbar = false;
  55. eventhandled = false;
  56. myform.Visible = true;
  57. CheckBox chkbox = new CheckBox ();
  58. chkbox.Visible = true;
  59. myform.Controls.Add (chkbox);
  60. chkbox.CheckStateChanged += new EventHandler (CheckBox_EventHandler);
  61. chkbox.CheckState = CheckState.Checked;
  62. Assert.AreEqual (true, eventhandled, "#A3");
  63. myform.Dispose ();
  64. }
  65. }
  66. }