Provides testing control over the mouse.
For a list of all members of this type, see MouseController Members.
System.Object
MouseController
MouseController allows you to control the mouse position and buttons and simulate dragging and clicking during a test. It can be used to test the behavior of a control. For testing the behavior of an application in reponse to a control's events, it is not necessary to use the MouseControl. I suggest you directly fire the appropriate events instead. (You probably aren't using this class unless you are writing some custom control and need to see its response to actual low level mouse movement, etc..)
The mouse Position can be relative to a Form or a Control on a Form. The Position can be specified in pixels, inches or millimetres
The mouse buttons are controlled with the Press and Release methods. Both
methods allow a bitwise combination of the MouseButtons, for example
Press(MouseButtons.Left | MouseButtons.Center)
.
Button modifiers, the Alt, Shift and Ctrl keys, are also controlled with the two methods.
The XButtons (XButton1 and XButton2) can only be simulated when a mouse with 5 buttons is installed. The Press and Release methods will throw NotSupportedException if the XButtons are used when a mouse does not have 4 or 5 button support.
[TestFixture] public class ATest : NUnitFormTest { // Gets the Form used for testing. public override Type FormType { get {return typeof(MyTestForm);} } [Test] public void Selecting() { ControlTester myControl = new ControlTester("myControl", CurrentForm); using (MouseController mouse = myControl.MouseController()) { mouse.Drag (10,10, 20,20); AssertEquals (1, myControl.Properties.SelectedObjects.Count); } }
Namespace: NUnit.Extensions.Forms
Assembly: NUnitForms (in NUnitForms.dll)
MouseController Members | NUnit.Extensions.Forms Namespace