CheckBoxEventTest.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.Visible = true;
  26. CheckBox chkbox = new CheckBox ();
  27. chkbox.Visible = true;
  28. myform.Controls.Add (chkbox);
  29. chkbox.AppearanceChanged += new EventHandler (CheckBox_EventHandler);
  30. chkbox.Appearance = Appearance.Button;
  31. Assert.AreEqual (true, eventhandled, "#A1");
  32. }
  33. [Test]
  34. public void CheckedChangedEventTest ()
  35. {
  36. eventhandled = false;
  37. Form myform = new Form ();
  38. myform.Visible = true;
  39. CheckBox chkbox = new CheckBox ();
  40. chkbox.Visible = true;
  41. myform.Controls.Add (chkbox);
  42. chkbox.CheckedChanged += new EventHandler (CheckBox_EventHandler);
  43. chkbox.CheckState = CheckState.Indeterminate;
  44. Assert.AreEqual (true, eventhandled, "#A2");
  45. }
  46. [Test]
  47. public void CheckStateChangedEventTest ()
  48. {
  49. eventhandled = false;
  50. Form myform = new Form ();
  51. myform.Visible = true;
  52. CheckBox chkbox = new CheckBox ();
  53. chkbox.Visible = true;
  54. myform.Controls.Add (chkbox);
  55. chkbox.CheckStateChanged += new EventHandler (CheckBox_EventHandler);
  56. chkbox.CheckState = CheckState.Checked;
  57. Assert.AreEqual (true, eventhandled, "#A3");
  58. }
  59. }
  60. }