CheckedListBoxEventTest.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // Copyright (c) 2005 Novell, Inc.
  3. //
  4. // Authors:
  5. // Ritvik Mayank ([email protected])
  6. //
  7. using System;
  8. using NUnit.Framework;
  9. using System.Windows.Forms;
  10. using System.Drawing;
  11. namespace MonoTests.System.Windows.Forms
  12. {
  13. [TestFixture]
  14. public class CheckedListBoxItemCheckEvent
  15. {
  16. static bool eventhandled = false;
  17. public void ItemCheck_EventHandler (object sender,ItemCheckEventArgs e)
  18. {
  19. eventhandled = true;
  20. }
  21. [Test]
  22. public void ItemCheckTest ()
  23. {
  24. Form myform = new Form ();
  25. CheckedListBox mychklstbox = new CheckedListBox ();
  26. mychklstbox.Items.Add ("test1");
  27. mychklstbox.Items.Add ("test2");
  28. //Test ItemCheck Event
  29. mychklstbox.ItemCheck += new ItemCheckEventHandler (ItemCheck_EventHandler);
  30. mychklstbox.Items.Add ("test1",CheckState.Checked);
  31. myform.Controls.Add (mychklstbox);
  32. myform.Show ();
  33. Assert.AreEqual (true, eventhandled, "#A1");
  34. eventhandled = false;
  35. mychklstbox.SetItemChecked (1,true);
  36. Assert.AreEqual (true, eventhandled, "#A2");
  37. myform.Dispose ();
  38. }
  39. }
  40. }