Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MessageTest.cs « System.Windows.Forms « Test « Managed.Windows.Forms « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74f287cd0d6e920493c1f25ec4eda2a84a4fe9de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// MessageTest.cs: Test cases for Message
//
// Authors:
//   Rolf Bjarne Kvinge (RKvinge@novell.com)
//
// (C) 2006 Novell, Inc. (http://www.novell.com)
//

using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

using NUnit.Framework;

namespace MonoTests.System.Windows.Forms
{

	[TestFixture]
	public class MessageTest : TestHelper
	{
		[Test]
		public void ToStringTest ()
		{
			Message msg = Message.Create (new IntPtr (123), 2, new IntPtr (234), new IntPtr (345));
			Assert.AreEqual ("msg=0x2 (WM_DESTROY) hwnd=0x7b wparam=0xea lparam=0x159 result=0x0", msg.ToString ());
			msg.Result = new IntPtr (2);
			Assert.AreEqual ("msg=0x2 (WM_DESTROY) hwnd=0x7b wparam=0xea lparam=0x159 result=0x2", msg.ToString ());
		}

		[Test]
		public void Equality ()
		{
			Message msg1 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
			msg1.Result = new IntPtr (1);
			Message msg2 = Message.Create (new IntPtr (1), 3, new IntPtr (4), new IntPtr (5));
			msg2.Result = new IntPtr (2);
			Message msg3 = Message.Create (new IntPtr (1), 2, new IntPtr (4), new IntPtr (5));
			msg3.Result = new IntPtr (3);
			Message msg4 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
			msg4.Result = new IntPtr (4);
			Message msg5 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
			msg5.Result = new IntPtr (1);

			Assert.IsFalse (msg1 == msg2, "A1");
			Assert.IsFalse (msg1 == msg3, "A2");
			Assert.IsFalse (msg1 == msg4, "A3");
			Assert.IsTrue (msg1 == msg5, "A4");
		}

		[Test]
		public void Inequality ()
		{
			Message msg1 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
			msg1.Result = new IntPtr (1);
			Message msg2 = Message.Create (new IntPtr (1), 3, new IntPtr (4), new IntPtr (5));
			msg2.Result = new IntPtr (2);
			Message msg3 = Message.Create (new IntPtr (1), 2, new IntPtr (4), new IntPtr (5));
			msg3.Result = new IntPtr (3);
			Message msg4 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
			msg4.Result = new IntPtr (4);
			Message msg5 = Message.Create (new IntPtr (1), 2, new IntPtr (3), new IntPtr (4));
			msg5.Result = new IntPtr (1);

			Assert.IsTrue (msg1 != msg2, "A1");
			Assert.IsTrue (msg1 != msg3, "A2");
			Assert.IsTrue (msg1 != msg4, "A3");
			Assert.IsFalse (msg1 != msg5, "A4");
		}
	}
}