NUnitForms
Exception is thrown when there is more than one control with the specified name.
You should qualify the name according to the name property of the parent control in
a dot-delimited string.
If you have multiple dynamic controls with the same name, consider giving them unique
names or else access them using the indexer property on each ControlTester.
grandparent.parent.child is a valid name string.. You can use the shortest name string
that uniquely identifies a control.
Creates an AmbiguousNameException.
The message string can be specified.
The messasge for the exception.
A ControlTester for testing Buttons.
This has no convenience methods beyond those provided
by ControlTester, but does provide a typed Properties
property.
A ControlTester for any type of control. It is the base class for all
ControlTesters in the API. It can also serve as a generic tester for all
Controls with no specifically implemented support.
If you want to make your own ControlTester for a custom or unsupported
control, you should implement a version of each of the four constructors.
I plan to separate out (and generate) this code once we get partial class
support in c#.
You should also implement a Property named Properties that returns the
underlying control.
You should hide the indexer (new) and implement one that returns the
appropriate type.
The ButtonTester class is a good place to look for an example (or cut and
paste starting point) if you are making your own tester.
The name of the underlying control.
Creates a ControlTester that will test controls with the specified name
on a form with the specified name.
If the name is unique, you can operate on the tester directly, otherwise
you should use the indexer or Enumerator properties to access each separate
control.
The name of the control to test.
The name of the form to test.
Should call this method after editing something in order to trigger any
databinding done with the Databindings collection. (ie text box to a data
set)
Creates a ControlTester that will test controls with the specified name
on the specified form.
If the name is unique, you can operate on the tester directly, otherwise
you should use the indexer or Enumerator properties to access each separate
control.
The name of the control to test.
The form to test.
Creates a ControlTester that will test controls with the specified name.
If the name is unique, you can operate on the tester directly, otherwise
you should use the indexer or Enumerator properties to access each separate
control.
The name of the control to test.
Returns uniquely qualified ControlTesters for each of the controls
associated with this tester as an IEnumerator. This allows use of a
foreach loop.
IEnumerator of ControlTesters (typed correctly)
Convenience method "Clicks" on the control being tested if it is visible
ControlNotVisibleException is thrown if the Control is not Visible.
Simulates firing of an event by the control being tested.
The name of the event to fire.
The optional arguments required to construct the EventArgs for the specified event.
Simulates firing of an event by the control being tested.
The name of the event to fire.
The EventArgs object to pass as a parameter on the event.
Convenience method invoker for any nonsupported method on a control to test
the name of the method to invoke
the arguments to pass into the method
Returns a that
can be used with the control under test.
It would be better to use the MouseController on the base test class so
that you don't have to worry about disposing it after your test. I think
this may be marked obsolete soon.
A .
MouseController returns a new instance of a
that can be used with the control under test.
All mouse positions are relative
the control.
The returned MouseController must be disposed
to restore the mouse settings prior to the testing; which can be accomplished with the using
statement.
TextBoxTester textBox = new TextBoxTester("myTextBox");
using (MouseController mouse = textBox.MouseController())
{
mouse.Position = new PointF(1,1);
mouse.Drag(30,1);
}
Allows you to find a ControlTester by index where the name is not unique.
When a control is not uniquely identified by its name property, you can
access it according to an index. This should only be used when you have
dynamic controls and it is inconvenient to set the Name property uniquely.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the ControlTester.
Returns the number of controls associated with this tester.
Convenience method retrieves the Text property of the tested control.
Convenience accessor / mutator for any nonsupported property on a control
to test.
ControlTester t = new ControlTester("t");
t["Text"] = "a";
AssertEqual("a", t["Text"]);
The underlying control for this tester.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Allows you to find a ButtonTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the ButtonTester.
Provides access to all of the Properties of the button.
Allows typed access to all of the properties of the underlying control.
The underlying control.
A ControlTester for testing CheckBoxes.
Has convenience methods for Check and Uncheck as well as the Checked Property.
Fully supported by the recorder application
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Sets the Checked property to the specified value.
Pass a boolean to indicate checked (true) or unchecked (false)
Should the box be checked or not checked.
Sets the Checked property of the CheckBox to true
Equivalent to Check(true)
Sets the Checked property of the CheckBox to false
Equivalent to Check(false)
Allows you to find a CheckBoxTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the CheckBoxTester.
Provides access to all of the Properties of the CheckBox.
Allows typed access to all of the properties of the underlying control.
The underlying control.
Retrieves the Checked property of the CheckBox
Just returns the checked property of the underlying checkbox.
A boolean to indicate whether the CheckBox is checked.
A ControlTester for testing ComboBoxes.
Has convenience methods for Selecting items and Entering text.
Fully supported by the recorder application
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Sets the text property of the ComboBox to the specified value.
Also calls EndCurrentEdit() so that databinding will happen.
The specified value for the text property.
Selects an entry in the ComboBox according to its index.
Sets the SelectedIndex property on the underlying control.
The index of the ComboBox entry to select.
Selects an entry in the ComboBox according to its string value.
Sets the Selected Index property on the underlying control after calling
FindStringExact
The string value of the entry to select.
Allows you to find a ComboBoxTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the ComboBoxTester.
Provides access to all of the Properties of the ComboBox.
Allows typed access to all of the properties of the underlying control.
The underlying control.
Internal use only. Represents a collection of controls.
NUnitForms users should not have a need for this class. When C# supports
generics, this should be replaced.
Add a Control to the collection.
Will not add a duplicate control. In this way, the collection acts like a Set.
The control to add.
Add one ControlCollection to another. Combines them into one collection.
The collection to merge with this one.
Returns an IEnumerator of the Controls in this collection.
An enumerator of controls.
Returns the number of Controls in this ControlCollection.
Delegates to the Count property of the underlying collection.
How many controls are in the collection.
Returns a Control from this collection according to its index.
delegates to the Item indexer of an underlying collection.
The control at the index.
the index
Internal use only. Finds controls according to their name property.
It is also used by the recorder application.
the recorder application.
Internal use only. Base class for ControlFinder and MenuItemFinder.
It is also used by the recorder application to determine names of Controls.
Finds the parent of a Control or MenuItem.
Necessary only because Control and MenuItem don't have a shared base class.
the Control or MenuItem
The parent of the Control or MenuItem
Finds the name of a Control or MenuItem.
Necessary only because Control and MenuItem don't have a shared base class.
the Control or MenuItem
The name of the Control or MenuItem
Creates a ControlFinder that will find controls on a specific Form according to their name.
The name of the Control to find.
The form to search for the control.
Creates a ControlFinder that will find controls according to their name.
The name of the Control to find.
Finds a control.
If there is more than one with the specified name, it will
throw an AmbiguousNameException. If the Control does not exist, it will throw
a NoSuchControlException.
The control if one is found.
Exception is thrown when you attempt an action on a Control that is not
visible.
Creates a ControlNotVisibleException.
The message string can be specified.
The messasge for the exception.
Internal use only. Represents a collection of controls.
NUnitForms users should not have a need for this class. When C# supports
generics, this should be replaced.
Add a Form to the collection.
Will not add a duplicate form. In this way, the collection acts like a Set.
The form to add.
Returns a boolean to indicate whether the supplied form exists in this collection.
The form to check for existence.
true if the form is in the collection, false otherwise.
Add one FormCollection to another. Combines them into one collection.
The collection to merge with this one.
Returns an IEnumerator of the Forms in this collection.
Returns the number of forms in this FormCollection.
Returns a Form from this collection according to its index.
A class to help find a form according to its name. NUnitForms users should not need to use
this class. Consider it as internal.
It is also used by the recorder application.
Finds all of the forms with a specified name and returns them in a FormCollection.
The name of the form to search for.
the FormCollection of all found forms.
Finds one form with the specified name.
The name of the form to search for.
The form it finds.
Thrown if there are no forms with the specified name.
Thrown if there is more than one form with the specified name.
Finds all of the forms.
FormCollection with all of the forms regardless of name.
A ControlTester for testing forms.
This class implements a Close() helper method to close a form that you find.
This class does not have all of the constructors because they don't make
sense in this context.
Provides access to all of the Properties of the Form.
Allows typed access to all of the properties of the underlying control.
Constant values for use with KeyboardController.
Provides testing control of the keyboard.
KeyboardController lets you send key presses to your application. You can
click, press, or release any key. The UseOn() method allows you to assert
focus on a specific control before sending the keys. It also initializes
the Keyboard controller for use by blocking user input.
[Test]
public void TextBox()
{
new TextBoxTestForm().Show();
TextBoxTester box = new TextBoxTester( "myTextBox", CurrentForm );
Assert.AreEqual( "default", box.Text );
Keyboard.UseOn( box );
Keyboard.Click( Key.A );
Keyboard.Click( Key.B );
Keyboard.Press( Key.SHIFT );
Keyboard.Click( Key.C );
Keyboard.Release( Key.SHIFT );
Assert.AreEqual( "abC", box.Text );
}
Creates a keyboard controller and sets the focus on the control
indicated by the supplied ControlTester.
The ControlTester to use the keyboard
on.
Initializes the KeyboardController, blocks user input, and sets
the focus on the specified control.
The ControlTester to use the keyboard on.
Overloaded. Allows you to specify the control by name.
You should probably use this one if you are not sure.
The name of the control.
Overloaded. Allows you to specify the control by name and
qualified by a form name.
The name of the control.
The name of the form.
Overloaded. Allows you to specify the control by name and
qualified by a form instance. This should be obsolete soon.
Do not use it unless necessary.
The name of the control.
The form instance to test on.
Implements the IDisposable interface. This restores user input.
It should eventually return the keyboard to its pre-test state.
If you are using the Keyboard controller through the base NUnitFormTest
class, then you should not need to call this method or use finally or using
blocks. The base class handles this for you.
Press and release a key.
these constants.
Use the Key class (in Key.cs) to find these constants.
The key to click.
Press a key.
Use the Key class (in Key.cs) to find these constants.
The key to press.
Release a key.
Use the Key class (in Key.cs) to find these constants.
The key to release.
A ControlTester for testing Labels.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Allows you to find a LabelTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the LabelTester.
Provides access to all of the Properties of the Label.
Allows typed access to all of the properties of the underlying control.
The underlying control.
A ControlTester for testing LinkLabels.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Allows you to find a LinkLabelTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the LinkLabelTester.
Provides access to all of the Properties of the LinkLabel.
Allows typed access to all of the properties of the underlying control.
The underlying control.
A ControlTester for testing ListBoxes.
It includes helper methods for selecting items from the list
and for clearing those selections.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Clears the selections from the list box.
Selects an item in the ListBox according to its index.
the index to select.
Selects an item in the list according to its string value.
The item to select.
Sets the selected property of an item at an index.
the index to select (or clear)
true if you want to select, false to clear.
Sets the selected property of an item with a specified string value.
the item to select (or clear)
true if you want to select, false to clear.
Allows you to find a ListBoxTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the ListBoxTester.
Provides access to all of the Properties of the ListBox.
Allows typed access to all of the properties of the underlying control.
The underlying control.
Internal use only. Represents a collection of MenuItems.
NUnitForms users should not have a need for this class. When C# supports
generics, this should be replaced.
Add a MenuItem to the collection.
Will not add a duplicate MenuItem. In this way, the collection acts like a Set.
The menu item to add.
Add one MenuItemCollection to another. Combines them into one collection.
The collection to merge with this one.
Returns an IEnumerator of the MenuItems in this collection.
Returns the number of Controls in this MenuItemCollection.
Returns a MenuItem from this collection according to its index.
Internal use only. This class finds MenuItems according to a name.
It is also used by the recorder application to determine names of Controls.
Creates a MenuItemFinder that will find MenuItems according to their name
and qualified by a form instance.
The MenuItem name.
The form instance.
Creates a MenuItemFinder that will find a MenuItem according to its name.
Finds the MenuItem.
the MenuItem found by this MenuItemFinder.
Thrown if this MenuItem is not found.
Thrown if multiple MenuItems are found with the same name.
A ControlTester for MenuItems.
It does not extend ControlTester because MenuItems are not Controls. (sadly)
Clicks the MenuItem (activates it)
Pops up a menu.
Gets the text of this MenuItem.
Allows you to access any properties of this MenuItem.
A ControlTester for MessageBoxes.
Allows you to handle and test MessageBoxes by pressing any of the
buttons that ordinarily appear on them.
It does not extend ControlTester because MessageBoxes are not controls.
public void MessageBoxHandler
{
MessageBoxTester messageBox = new MessageBoxTester( "MessageBoxName" );
Assert.AreEqual( "MessageBoxText", messageBox.Text );
Assert.AreEqual( "MessageBoxTitle", messageBox.Title );
messageBox.SendCommand( MessageBoxTester.Command.OK );
}
Creates a MessageBoxTester with the specified handle. NUnitForms
users probably won't use this directly. Use the other constructor.
The handle of the MessageBox to test.
Creates a MessageBoxTester that finds MessageBoxes with the
specified name.
The name of the MessageBox to test.
Sends a command to the MessageBox.
The command to send.. (ok, cancel, yes, abort, etc..)
Clicks the Ok button of a MessageBox.
Clicks the cancel button of a MessageBox.
Returns the caption on the message box we are testing.
Returns the text of the message box we are testing.
Available commands you can send to the MessageBox.
There are convenience methods for OK and Cancel, so you should not need
those.
Used to specify a handler for a Modal form that is displayed during testing.
Translation between mouse position and screen position.
A mouse coordinate relative to
the origin control and specified in PositionUnit.
The scale to convert by.
A mouse coordinate relative to
the screen and specified in pixels.
Provides testing control over the mouse.
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 or a
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 , for example
Press(MouseButtons.Left | MouseButtons.Center).
Button modifiers, the Alt, Shift and Ctrl keys, are also controlled with the two methods.
The XButtons ( and )
can only be simulated when a mouse with 5 buttons is installed.
The Press and Release methods will throw 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);
}
}
Creates and initialises a new instance of the class.
Creates and initialises a new instance of the class for the specified .
A .
The mouse position is relative to the managed by
the .
While the MouseController is active, user keyboard and mouse input is disabled. For this
reason the MouseController should be disposed of when the testing is concluded.
using (MouseController mouse = new MouseControler(myTestControl))
{
mouse.Position = new PointF(1,1);
mouse.Press(MouseButtons.Middle);
}
Specify which control or form we should use for the relative position.
A .
Overloaded. Specifies control by name.
The name of the control
Overloaded. Specifies control by name and form name
The name of the control.
The name of the form.
Overloaded. Specifies control by name and form instance.
The name of the control.
The form instance.
Releases the resources used by the .
Dispose releases any pressed mouse keys, restores the
mouse and enables user input.
Simulate hovering over the control under test.
Hover positions the mouse over the control under test for the
system defined mouse hover time and then processes the events.
Simulate hovering over the control under test at the specified x and y-coordinate.
The x-coordinate,
relative to the control under test,
to move the mouse to.
The y-coordinate,
relative to the control under test,
to move the mouse to.
Hover positions the mouse over the control under test
at the specified point (, ) for the system defined mouse hover
time and then processes the events.
Simulate hovering over the control under test at the specified .
A , relative to the control under test,
to move the mouse to.
Hover positions the mouse over the control under test
at the specified for the system defined mouse hover
time and then processes the events.
Simulate clicking on the control under test.
Click positions the mouse over the control under test
and then presses and releases the left mouse button.
Simulate clicking at the specified x and y-coordinate.
The x-coordinate,
relative to the control under test,
to move the mouse to.
The y-coordinate,
relative to the control under test,
to move the mouse to.
Click positions the mouse over the control under test
at the specified point (, )
and then presses and releases the left mouse button.
Simulate clicking at the specified .
A , relative to the control under test,
to move the mouse to.
Click positions the mouse over the control under test
at the specified
and then presses and releases the left mouse button.
Simulate double clicking on the control under test.
Click positions the mouse over the control under test
and then presses and releases the left mouse button twice.
Simulate double clicking at the specified x and y-coordinate.
The x-coordinate,
relative to the control under test,
to move the mouse to.
The y-coordinate,
relative to the control under test,
to move the mouse to.
Click positions the mouse over the control under test
at the specified point (, )
and then presses and releases the left mouse button twice.
Simulate double clicking at the specified .
A , relative to the control under test,
to move the mouse to.
Click positions the mouse over the control under test
at the specified
and then presses and releases the left mouse button twice.
Simulate pressing the mouse button(s).
A bitwise combination of the enumeration values.
Press positions the mouse over the control under test
and then simulates pressing the specified .
When contains MouseButtons.XButton1
or MouseButtons.XButton2 and the installed mouse does have 4
or 5 buttons, respectively.
Simulate pressing the mouse button(s) at the specified x and y-coordinate.
A bitwise combination of the enumeration values.
The x-coordinate,
relative to the control under test,
to move the mouse to.
The y-coordinate,
relative to the control under test,
to move the mouse to.
Press positions the mouse over the control under test
at the specified point (, )
and then simulates pressing the specified .
When contains MouseButtons.XButton1
or MouseButtons.XButton2 and the installed mouse does have 4
or 5 buttons, respectively.
Simulate pressing the mouse button(s) at the specified .
A bitwise combination of the enumeration values.
A , relative to the control under test,
to move the mouse to.
Press positions the mouse over the control under test
at the specified
and then simulates pressing the specified .
When contains MouseButtons.XButton1
or MouseButtons.XButton2 and the installed mouse does have 4
or 5 buttons, respectively.
Simulates pressing the or modifier .
Simulate pressing the mouse modifier key(s) (Alt, Shift and Control).
A bitwise combination of the enumeration values. Only Alt, Shift
and Control are allowed.
Press simulates pressing the specified .
When contains a value that is not
Alt, Shift or Control.
The following example performs a "shift drag" and verifies that
two objects are selected.
[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);
mouse.Press(Keys.Shift);
mouse.Drag(100,100, 200,200);
mouse.Release(Keys.Shift);
AssertEquals (2, myControl.Properties.SelectedObjects.Count);
}
}
Simulate releasing the mouse button(s).
A bitwise combination of the enumeration values.
Release positions the mouse over the control under test
and then simulates releasing the specified .
When contains MouseButtons.XButton1
or MouseButtons.XButton2 and the installed mouse does have 4
or 5 buttons, respectively.
Simulate release the mouse button(s) at the specified x and y-coordinate.
A bitwise combination of the enumeration values.
The x-coordinate,
relative to the control under test,
to move the mouse to.
The y-coordinate,
relative to the control under test,
to move the mouse to.
Release positions the mouse over the control under test
at the specified point (, )
and then simulates releasing the specified .
When contains MouseButtons.XButton1
or MouseButtons.XButton2 and the installed mouse does have 4
or 5 buttons, respectively.
Simulate releasing the mouse button(s) at the specified .
A bitwise combination of the enumeration values.
A , relative to the control under test,
to move the mouse to.
Release positions the mouse over the control under test
at the specified
and then simulates releasing the specified .
When contains MouseButtons.XButton1
or MouseButtons.XButton2 and the installed mouse does have 4
or 5 buttons, respectively.
Simulates releasing the or modifier .
Simulate releasing the mouse modifier key(s) (Alt, Shift and Control).
A bitwise combination of the enumeration values. Only Alt, Shift
and Control are allowed.
Release simulates releasing the specified .
When contains a value that is not
Alt, Shift or Control.
The following example performs a "shift drag" and verifies that
two objects are selected.
[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);
mouse.Press(Keys.Shift);
mouse.Drag(100,100, 200,200);
mouse.Release(Keys.Shift);
AssertEquals (2, myControl.Properties.SelectedObjects.Count);
}
}
Simulate dragging the mouse.
A to start the drag operation at.
Array of structures that represent the points to move>
the mouse to.
When is null.
When does not contain any elements.
Drag positions the mouse over the control under test
at the specified and then presses the
left mouse button. It then moves the mouse to each point specified in the
array. Finally the left button is released.
using (MouseController mouse = new MouseControler(myTestControl))
{
mouse.Drag(new PointF(0,0), new Point(100, 100));
}
Simulate dragging the mouse.
A x-coordinate to start the drag operation at.
A y-coordinate to start the drag operation at.
Array of values that represent the x and y coordinates to move>
the mouse to.
When is null.
When does not contain at lease two values,
Or, the number of elements is odd.
Drag positions the mouse over the control under test
at the specified (, )
and then presses the left mouse button. It then moves the mouse
to each point specified in the array. Finally the left button is released.
using (MouseController mouse = new MouseControler(myTestControl))
{
mouse.Drag(0,0, 100,100);
}
Gets or sets the mouse position.
A representing the mouse position in the space.
Position is the position of the mouse, relative to the control under test
and specified in position units.
Gets or sets the unit of measure used for mouse coordinates.
A member of the enumeration. The default
is GraphicsUnit.Pixel.
PositionUnit specifies how the mouse coordinates
are interpreted.
When value is GraphicsUnit.World.
When value is not a valid enumeration value.
Exception is thrown when a control can not be found
by its specified name.
Creates a NoSuchControlException.
The message string can be specified.
The messasge for the exception.
One of three base classes for your NUnitForms tests. This one can be
used by people who want "built-in" Assertion functionality and prefer
the older style "Assertion" syntax.
One of three base classes for your NUnitForms tests. This one can be
used by people who do not need or want "built-in" Assert functionality.
This is the recommended base class for all unit tests that use NUnitForms.
You should probably extend this class to create all of your test fixtures. The benefit is that
this class implements setup and teardown methods that clean up after your test. Any forms that
are created and displayed during your test are cleaned up by the tear down method. This base
class also provides easy access to keyboard and mouse controllers. It has a method that allows
you to set up a handler for modal dialog boxes. It allows your tests to run on a separate
(usually hidden) desktop so that they are faster and do not interfere with your normal desktop
activity. If you want custom setup and teardown behavior, you should override the virtual
Setup and TearDown methods. Do not use the setup and teardown attributes in your child class.
This is the base classes setup method. It will be called by NUnit before each test.
You should not have anything to do with it.
This is the method that is called to handled unexpected modal dialogs. It is called automatically
by the NUnitForms framework when such a dialog appears. You should not need to call it.
One of four overloaded methods to set up a modal dialog handler. If you expect a modal
dialog to appear and can handle it during the test, use this method to set up the handler.
The caption on the dialog you expect.
The method to call when that dialog appears.
One of four overloaded methods to set up a modal dialog handler. If you expect a modal
dialog to appear and can handle it during the test, use this method to set up the handler.
Because "expected" is usually (always) true if you are calling this, I don't expect it will
be used externally.
The caption on the dialog you expect.
The method to call when that dialog appears.
A boolean to indicate whether you expect this modal dialog to appear.
One of four overloaded methods to set up a modal dialog handler. If you expect a modal
dialog to appear and can handle it during the test, use this method to set up the handler.
Because "expected" is usually (always) true if you are calling this, I don't expect it will
be used externally.
The caption on the dialog you expect.
The name of the method to call when that dialog appears.
A boolean to indicate whether you expect this modal dialog to appear.
One of four overloaded methods to set up a modal dialog handler. If you are not sure which
to use, use this one. If you expect a modal dialog to appear and can handle it during the
test, use this method to set up the handler. Because "expected" is usually (always) true
if you are calling this, I don't expect it will be used externally.
The caption on the dialog you expect.
The name of the method to call when that dialog appears.
Obsolete soon. In your test class, you used to have the choice to override this
method, or implement the FormType property. Now neither is necessary. It is still
here for compatibility with tests written to use the CurrentForm property.
Override this Setup method if you have custom behavior to execute before each test
in your fixture.
This will be marked obsolete soon. This method is called before each test in order
to set the CurrentForm property (also obsolete) You can override this method as an
alternative to setting the FormType property if you want to test the old way.
This method is called by NUnit after each test runs. If you have custom
behavior to run after each test, then override the TearDown method and do
it there. That method is called at the beginning of this one.
You should not need to do anything with it. Do not call it.
If you do call it, call it as the last thing you do in your test.
This method is called after each test. Put code here to clean up anything
you need to between tests. NUnitForms cleans up most everything you need
related to the framework (closes extra windows, etc..) but you might need
custom behavior beyond this. Put it here.
This property controls whether the separate hidden desktop is displayed for the duration of
this test. You will need to override and return true from this property if your test makes
use of the keyboard or mouse controllers. (The hidden desktop cannot accept user input.) For
tests that do not use the keyboard and mouse controller (most should not) you don't need to do
anything with this. The default behavior is fine.
This property controls whether a separate desktop is used at all. I highly recommend that you
leave this as returning true. Tests on the separate desktop are faster and safer. (There is
no danger of keyboard or mouse input going to your own separate running applications.) However
I have heard report of operating systems or environments where the separate desktop does not work.
In that case there are 2 options. You can override this method from your test class to return false.
Or you can set an environment variable called "UseHiddenDesktop" and set that to "false" Either will
cause the tests to run on your original, standard desktop.
This should be marked obsolete. It is used only in combination with the FormType property.
If you override the FormType property, then CurrentForm will be initialized (on setup) to
an instance of the form whose type you specify. None of the testers require a reference
to the active form anymore, so this should not be necessary. It will be marked obsolete
soon.
Returns a reference to the current MouseController for doing Mouse tests. I recommend
this only when you are writing your own custom controls and need to respond to actual
mouse input to test them properly. In most other cases there is a better way to test
the form's logic.
Returns a reference to the current KeyboardController for doing Keyboard tests. I recommend
this only when you are writing your own custom controls and need to respond to actual
keyboard input to test them properly. In most other cases there is a better way to test
for the form's logic.
Soon to be marked obsolete. This property specifies the type of form to instantiate
before each test. Do not use it anymore.
One of three base classes for your NUnitForms tests. This one can be
used by people who want "built-in" Assert functionality and prefer
the newer style "Assert" syntax.
A ControlTester for testing RadioButtons.
This class provides a convenience property for determining
whether a RadioButton is checked.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Allows you to find a RadioButtonTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the RadioButtonTester.
Provides access to all of the Properties of the RadioButton.
Allows typed access to all of the properties of the underlying control.
The underlying control.
A ControlTester for testing TabControls.
There is a convenience method for selecting a specified tab.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Selects the tab at the specified index.
The tab to select.
Allows you to find a TabControlTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the TabControlTester.
Provides access to all of the Properties of the TabControl.
Allows typed access to all of the properties of the underlying control.
The underlying control.
A ControlTester for testing TextBoxes.
There is a convenience method for entering text into a text box.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
This method allows you to enter text into the text box.
The text to enter into the text box.
Allows you to find a TextBoxTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the TextBoxTester.
Provides access to all of the Properties of the TextBox.
Allows typed access to all of the properties of the underlying control.
The underlying control.
A ControlTester for testing TreeViews.
There is a convenience method for selecting a node in the tree.
Creates a ControlTester from the control name and the form instance.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form instance.
Creates a ControlTester from the control name and the form name.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The Control name.
The Form name..
Creates a ControlTester from the control name.
This is the best constructor.
The Control name.
Creates a ControlTester from a ControlTester and an index where the
original tester's name is not unique.
It is best to use the overloaded Constructor that requires just the name
parameter if possible.
The ControlTester.
The index to test.
Selects a node in the tree.
an array of the indexes of the node to select
Allows you to find a TreeViewTester by index where the name is not unique.
This was added to support the ability to find controls where their name is
not unique. If all of your controls are uniquely named (I recommend this) then
you will not need this.
The ControlTester at the specified index.
The index of the TreeViewTester.
Provides access to all of the Properties of the TreeView.
Allows typed access to all of the properties of the underlying control.
The underlying control.