MessageTest.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // MessageTest.cs: Test cases for Message
  3. //
  4. // Authors:
  5. // Rolf Bjarne Kvinge ([email protected])
  6. //
  7. // (C) 2006 Novell, Inc. (http://www.novell.com)
  8. //
  9. using System;
  10. using System.Drawing;
  11. using System.Reflection;
  12. using System.Windows.Forms;
  13. using NUnit.Framework;
  14. namespace MonoTests.System.Windows.Forms
  15. {
  16. [TestFixture]
  17. public class MessageTest : TestHelper
  18. {
  19. [Test]
  20. public void ToStringTest ()
  21. {
  22. Message msg = Message.Create (new IntPtr (123), 2, new IntPtr (234), new IntPtr (345));
  23. Assert.AreEqual ("msg=0x2 (WM_DESTROY) hwnd=0x7b wparam=0xea lparam=0x159 result=0x0", msg.ToString ());
  24. msg.Result = new IntPtr (2);
  25. Assert.AreEqual ("msg=0x2 (WM_DESTROY) hwnd=0x7b wparam=0xea lparam=0x159 result=0x2", msg.ToString ());
  26. }
  27. #if NET_2_0
  28. [Test]
  29. public void Equality ()
  30. {
  31. Message msg1 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
  32. msg1.Result = new IntPtr (1);
  33. Message msg2 = Message.Create (new IntPtr (1), 3, new IntPtr (4), new IntPtr (5));
  34. msg2.Result = new IntPtr (2);
  35. Message msg3 = Message.Create (new IntPtr (1), 2, new IntPtr (4), new IntPtr (5));
  36. msg3.Result = new IntPtr (3);
  37. Message msg4 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
  38. msg4.Result = new IntPtr (4);
  39. Message msg5 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
  40. msg5.Result = new IntPtr (1);
  41. Assert.IsFalse (msg1 == msg2, "A1");
  42. Assert.IsFalse (msg1 == msg3, "A2");
  43. Assert.IsFalse (msg1 == msg4, "A3");
  44. Assert.IsTrue (msg1 == msg5, "A4");
  45. }
  46. [Test]
  47. public void Inequality ()
  48. {
  49. Message msg1 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
  50. msg1.Result = new IntPtr (1);
  51. Message msg2 = Message.Create (new IntPtr (1), 3, new IntPtr (4), new IntPtr (5));
  52. msg2.Result = new IntPtr (2);
  53. Message msg3 = Message.Create (new IntPtr (1), 2, new IntPtr (4), new IntPtr (5));
  54. msg3.Result = new IntPtr (3);
  55. Message msg4 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
  56. msg4.Result = new IntPtr (4);
  57. Message msg5 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
  58. msg5.Result = new IntPtr (1);
  59. Assert.IsTrue (msg1 != msg2, "A1");
  60. Assert.IsTrue (msg1 != msg3, "A2");
  61. Assert.IsTrue (msg1 != msg4, "A3");
  62. Assert.IsFalse (msg1 != msg5, "A4");
  63. }
  64. #endif
  65. }
  66. }