ApplicationTest.cs 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // ApplicationContextTest.cs
  3. //
  4. // Author:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2006 Novell, Inc. (http://www.novell.com)
  8. //
  9. using System;
  10. using System.ComponentModel;
  11. using System.Windows.Forms;
  12. using System.Drawing;
  13. using System.Reflection;
  14. using NUnit.Framework;
  15. namespace MonoTests.System.Windows.Forms
  16. {
  17. [TestFixture]
  18. public class ApplicationTest
  19. {
  20. ApplicationContext ctx;
  21. void form_visible_changed (object sender, EventArgs e)
  22. {
  23. Assert.AreEqual (sender, ctx.MainForm, "1");
  24. ((Form)sender).Close();
  25. }
  26. [Test]
  27. public void ContextMainFormTest ()
  28. {
  29. Form f1 = new Form ();
  30. f1.ShowInTaskbar = false;
  31. ctx = new ApplicationContext (f1);
  32. f1.VisibleChanged += new EventHandler (form_visible_changed);
  33. Application.Run (ctx);
  34. Assert.IsNull (ctx.MainForm, "2");
  35. f1.Dispose ();
  36. }
  37. #if NET_2_0
  38. [Test]
  39. [ExpectedException (typeof (NotSupportedException))]
  40. public void RestartNotSupportedExceptionTest ()
  41. {
  42. Application.Restart ();
  43. }
  44. #endif
  45. }
  46. }