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); } } } } }
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); } }
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); }