Test class that implements sequencing of messages, but simulates no recursion. This is a good model for what a class needs to do to get messages sequentially.
Inheritance: TestControlBase, IReceiveSequentialMessages
Ejemplo n.º 1
0
		public void NormalOperation()
		{
			// need to create a dummy form because PaintEventArgs wants a Graphics object
			using (DummyForm dummy = new DummyForm())
			{
				dummy.Create();
				using (TestControl1 tc1 = new TestControl1())
				{
					Message m1 = Message.Create(IntPtr.Zero, 10, new IntPtr(101), new IntPtr(1001));
					tc1.CallWndProc(ref m1);
					Message m2 = Message.Create(IntPtr.Zero, 20, new IntPtr(201), new IntPtr(2001));
					tc1.CallWndProc(ref m2);
					using (var g = dummy.CreateGraphics())
					{
						using (var pe1 = new PaintEventArgs(g, new System.Drawing.Rectangle(0, 1, 2, 3)))
						{
							tc1.CallOnPaint(pe1);
							Message m3 = Message.Create(IntPtr.Zero, 30, new IntPtr(301), new IntPtr(3001));
							tc1.CallWndProc(ref m3);
							object[] expected = { m1, m1, m2, m2, pe1, pe1, m3, m3 };
							VerifyArray(expected, tc1);
						}
					}
				}
			}
		}
Ejemplo n.º 2
0
 public void NormalOperation()
 {
     // need to create a dummy form because PaintEventArgs wants a Graphics object
     using (DummyForm dummy = new DummyForm())
     {
         dummy.Create();
         using (TestControl1 tc1 = new TestControl1())
         {
             Message m1 = Message.Create(IntPtr.Zero, 10, new IntPtr(101), new IntPtr(1001));
             tc1.CallWndProc(ref m1);
             Message m2 = Message.Create(IntPtr.Zero, 20, new IntPtr(201), new IntPtr(2001));
             tc1.CallWndProc(ref m2);
             using (var g = dummy.CreateGraphics())
             {
                 using (var pe1 = new PaintEventArgs(g, new System.Drawing.Rectangle(0, 1, 2, 3)))
                 {
                     tc1.CallOnPaint(pe1);
                     Message m3 = Message.Create(IntPtr.Zero, 30, new IntPtr(301), new IntPtr(3001));
                     tc1.CallWndProc(ref m3);
                     object[] expected = { m1, m1, m2, m2, pe1, pe1, m3, m3 };
                     VerifyArray(expected, tc1);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void VerifyArray(object[] expected, TestControl1 tc1)
 {
     Assert.AreEqual(expected.Length, tc1.m_messages.Count);
     for (int i = 0; i < expected.Length; i++)
     {
         Assert.AreEqual(expected[i], tc1.m_messages[i], "unexpected object at " + i);
     }
 }
Ejemplo n.º 4
0
		private void VerifyArray(object[] expected, TestControl1 tc1)
		{
			Assert.AreEqual(expected.Length, tc1.m_messages.Count);
			for (int i = 0; i < expected.Length; i++)
				Assert.AreEqual(expected[i], tc1.m_messages[i], "unexpected object at " + i);
		}