ApplicationTest.cs 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. ctx = new ApplicationContext (f1);
  31. f1.VisibleChanged += new EventHandler (form_visible_changed);
  32. Application.Run (ctx);
  33. Assert.IsNull (ctx.MainForm, "2");
  34. }
  35. #if NET_2_0
  36. [Test]
  37. [ExpectedException (typeof (NotSupportedException))]
  38. public void RestartNotSupportedExceptionTest ()
  39. {
  40. Application.Restart ();
  41. }
  42. #endif
  43. }
  44. }