chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I'm getting the following error on several tests that have passed up until this point. I can't point to any changes that may have caused this problem.

The error:
Test method TimeEntryTest.ApplicationFormTest.printToolStripButton_ClickTest threw exception: System.Reflection.AmbiguousMatchException: Ambiguous match found...

The Stack:
at System.DefaultBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] canidates, Object[]& args, ParameterModifier[] modifiers, CultureInfo cultureInfo, String[] names, Object& state)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
at TimeEntryTest.ApplicationFormTest.ExecutePrintTest(String itemOrButton) in C:Documents and SettingscedplghMy DocumentsVisual Studio 2005ProjectsCorporateTimeEntryTimeEntry.rootTimeEntryTimeEntryTestApplicationFormTest.cs:line 1016
at TimeEntryTest.ApplicationFormTest.printToolStripButton_ClickTest() in C:Documents and SettingscedplghMy DocumentsVisual Studio 2005ProjectsCorporateTimeEntryTimeEntry.rootTimeEntryTimeEntryTestApplicationFormTest.cs:line 1003
The Code:

[[TestMethod]
        public void printToolStripMenuItem_ClickTest()
        {
            ExecutePrintTest("item");
        }

        public void ExecutePrintTest(string itemOrButton)
        {
            MockManager.ClearAll();
            MockObject displayControllerMock = MockManager.MockObject(typeof(DisplayController), Constructor.Mocked);
            MockObject timesheetFormMock = MockManager.MockObject(typeof(TimesheetForm), Constructor.Mocked);
            MockObject applicationFormMock = MockManager.MockObject(typeof(ApplicationForm), Constructor.Mocked);

            ApplicationForm target = applicationFormMock.Object as ApplicationForm;
            DisplayController displayController = displayControllerMock.Object as DisplayController;
            TimesheetForm timesheetForm = timesheetFormMock.Object as TimesheetForm;


            applicationFormMock.ExpectGet("DisplayController", displayController);
            applicationFormMock.ExpectGet("ActiveMdiChild", timesheetForm);
            displayControllerMock.ExpectCall("PrintTimesheet").Args(timesheetForm);

            Corporate_TimeEntry_Client_ApplicationFormAccessor accessor = new Corporate_TimeEntry_Client_ApplicationFormAccessor(target);

            if (itemOrButton == "button")
            {
                accessor.printToolStripButton_Click(timesheetForm, null);
                return;
            }
            if (itemOrButton == "item")
                accessor.printToolStripMenuItem_Click(timesheetForm, null);

        }


The error occures at this line:

 MockObject timesheetFormMock = MockManager.MockObject(typeof(TimesheetForm), Constructor.Mocked);


Any ideas?
asked by lghummel (1.2k points)

1 Answer

0 votes
Hi,
I guess the TimesheetForm has no default constructor and has more then one constructor that contains the same number of arguments. Some of these arguments (in the same position) are classes (as opposed to primitives and value types).

Never mind, just upgrade to 3.6.1 we fixed that bug. 8)
answered by scott (32k points)
...