I am new to Typemock and can not determine how to implement this test. If someone could please point me in the right direction it would be much appreciated.
The problem
I have three MenuItems created in my program that provide the Click event to different event handlers. I would like to fire each of these event handlers
The program
MenuItem addItem = new MenuItem();
addItem.Text = "&Add...";
addItem.Click += new EventHandler(addItem_Click);
MenuItem editItem = new MenuItem();
editItem.Text = "&Edit...";
editItem.Click += new EventHandler(editItem_Click);
MenuItem deleteItem = new MenuItem();
deleteItem.Text = "&Delete..."
deleteItem.Click += new EventHandler(deleteItem_Click);
The test code
// Create the mock of all MenuItems
Mock contextMenuItemsMock = MockManager.MockAll(typeof(MenuItem);
// Set the expectations
contextMenuItems.ExpectAddEvent("Click", 3);
contextMenuItems.ExpectSetAlways("Test);
My questions are:
1) How do I obtain the MockedEvent handle to each of the three events? Each handler is subscribed to a different instances of a MenuItem.
Depending on the answer to one above:
2) Should a method exist such as:
MockedHandle[] Mock.ExpectAddEventAlways(string name);
As this would mean the test would not fail if additional MenuItems were created in the program
Thanks for your time
Paul