PictureBoxTest.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // PictureBoxTest.cs: Test cases for PictureBox.
  3. //
  4. // Author:
  5. // Ritvik Mayank ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc. (http://www.novell.com)
  8. //
  9. using System;
  10. using System.Windows.Forms;
  11. using System.Drawing;
  12. using System.Reflection;
  13. using NUnit.Framework;
  14. using System.Threading;
  15. namespace MonoTests.System.Windows.Forms
  16. {
  17. [TestFixture]
  18. public class PictureBoxTest
  19. {
  20. [Test]
  21. public void PictureBoxPropertyTest ()
  22. {
  23. Form myForm = new Form ();
  24. PictureBox myPicBox = new PictureBox ();
  25. myForm.Controls.Add (myPicBox);
  26. // B
  27. Assert.AreEqual (BorderStyle.None, myPicBox.BorderStyle, "#B1");
  28. myPicBox.BorderStyle = BorderStyle.Fixed3D;
  29. Assert.AreEqual (BorderStyle.Fixed3D, myPicBox.BorderStyle, "#B2");
  30. // I
  31. Assert.AreEqual (null, myPicBox.Image, "#I1");
  32. Image myImage = Image.FromFile("M.gif");
  33. myPicBox.Image = myImage;
  34. Assert.AreEqual (60, myPicBox.Image.Height, "#I2");
  35. Assert.AreEqual (150, myPicBox.Image.Width, "#I3");
  36. // P
  37. Assert.AreEqual (PictureBoxSizeMode.Normal, myPicBox.SizeMode, "#P1");
  38. myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
  39. Assert.AreEqual (PictureBoxSizeMode.AutoSize, myPicBox.SizeMode, "#P2");
  40. }
  41. [Test, Ignore ("This seems to fail.")]
  42. public void ToStringMethodTest ()
  43. {
  44. PictureBox myPicBox = new PictureBox ();
  45. Assert.AreEqual ("System.Windows.Forms.PictureBox, SizeMode: Normal", myPicBox.ToString (), "#T1");
  46. }
  47. [TestFixture]
  48. public class PictureBoxSizeModeEventClass
  49. {
  50. static bool eventhandled = false;
  51. public static void SizeMode_EventHandler (object sender, EventArgs e)
  52. {
  53. eventhandled = true;
  54. }
  55. [Test]
  56. public void PictureBoxEvenTest ()
  57. {
  58. Form myForm = new Form ();
  59. PictureBox myPicBox = new PictureBox ();
  60. myForm.Controls.Add (myPicBox);
  61. myPicBox.SizeModeChanged += new EventHandler (SizeMode_EventHandler);
  62. myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
  63. Assert.AreEqual (true, eventhandled, "#SM1");
  64. eventhandled = false;
  65. myPicBox.SizeMode = PictureBoxSizeMode.CenterImage;
  66. Assert.AreEqual (true, eventhandled, "#SM2");
  67. eventhandled = false;
  68. myPicBox.SizeMode = PictureBoxSizeMode.StretchImage;
  69. Assert.AreEqual (true, eventhandled, "#SM3");
  70. }
  71. }
  72. }
  73. }