CheckedListBoxEventTest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. myform.ShowInTaskbar = false;
  26. CheckedListBox mychklstbox = new CheckedListBox ();
  27. mychklstbox.Items.Add ("test1");
  28. mychklstbox.Items.Add ("test2");
  29. //Test ItemCheck Event
  30. mychklstbox.ItemCheck += new ItemCheckEventHandler (ItemCheck_EventHandler);
  31. mychklstbox.Items.Add ("test1",CheckState.Checked);
  32. myform.Controls.Add (mychklstbox);
  33. myform.Show ();
  34. Assert.AreEqual (true, eventhandled, "#A1");
  35. eventhandled = false;
  36. mychklstbox.SetItemChecked (1,true);
  37. Assert.AreEqual (true, eventhandled, "#A2");
  38. myform.Dispose ();
  39. }
  40. }
  41. }