In my tests for a Presenter class, I'm faking the View class whose interface includes a collection of ListViewItems for a ListView on the form. The following Presenter code loads Company names into that collection:
_view.ListViewItems.Clear();
foreach ( Company company in companiesList )
{
ListViewItem item = new ListViewItem( company.Name );
_view.ListViewItems.Add( item );
}
If I run the code without Isolator it works fine, but when I use Isolator to fake the View I get the following message in MbUnit:
Message: InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index
Type: System.ArgumentOutOfRangeException
Source: TypeMock
ActualValue: null
ParamName: index
TargetSite: System.Object a(System.String, System.String, System.Object, System.Object, Boolean, System.Object[])
HelpLink: null
Stack:at System.Windows.Forms.ListViewItem.ListViewSubItemCollection.get_Item(Int32 index)
at System.Windows.Forms.ListViewItem.set_Text(String value)
at System.Windows.Forms.ListViewItem..ctor(String text, Int32 imageIndex)
at System.Windows.Forms.ListViewItem..ctor(String text)
at Integrator.ManagementUI.CompanyManagerPresenter.LoadData() in C:DenisIssuesIntegrator2IntegratorUIManagementUICompanyManagerPresenter.cs:line 74
Line 74 is the line above that instantiates the new ListViewItem. It's using the constructor that is passed a string, but from the message it looks like it's trying to convert it to the constructor that also has an imageIndex.
Any idea what could be wrong? (I'm using Isolator 5.3.0.0).
Thanks,
Denis