PictureBoxTest.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. // P
  31. Assert.AreEqual (PictureBoxSizeMode.Normal, myPicBox.SizeMode, "#P1");
  32. myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
  33. Assert.AreEqual (PictureBoxSizeMode.AutoSize, myPicBox.SizeMode, "#P2");
  34. myForm.Dispose ();
  35. }
  36. [Test]
  37. [Category ("NotWorking")]
  38. public void ImagePropertyTest ()
  39. {
  40. PictureBox myPicBox = new PictureBox ();
  41. // I
  42. Assert.AreEqual (null, myPicBox.Image, "#I1");
  43. Image myImage = Image.FromFile("M.gif");
  44. myPicBox.Image = myImage;
  45. Assert.AreEqual (60, myPicBox.Image.Height, "#I2");
  46. Assert.AreEqual (150, myPicBox.Image.Width, "#I3");
  47. }
  48. [Test]
  49. public void ToStringMethodTest ()
  50. {
  51. PictureBox myPicBox = new PictureBox ();
  52. Assert.AreEqual ("System.Windows.Forms.PictureBox, SizeMode: Normal", myPicBox.ToString (), "#T1");
  53. }
  54. [TestFixture]
  55. public class PictureBoxSizeModeEventClass
  56. {
  57. static bool eventhandled = false;
  58. public static void SizeMode_EventHandler (object sender, EventArgs e)
  59. {
  60. eventhandled = true;
  61. }
  62. [Test]
  63. public void PictureBoxEvenTest ()
  64. {
  65. Form myForm = new Form ();
  66. PictureBox myPicBox = new PictureBox ();
  67. myForm.Controls.Add (myPicBox);
  68. myPicBox.SizeModeChanged += new EventHandler (SizeMode_EventHandler);
  69. myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
  70. Assert.AreEqual (true, eventhandled, "#SM1");
  71. eventhandled = false;
  72. myPicBox.SizeMode = PictureBoxSizeMode.CenterImage;
  73. Assert.AreEqual (true, eventhandled, "#SM2");
  74. eventhandled = false;
  75. myPicBox.SizeMode = PictureBoxSizeMode.StretchImage;
  76. Assert.AreEqual (true, eventhandled, "#SM3");
  77. myForm.Dispose ();
  78. }
  79. }
  80. }
  81. }