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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
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
asked by denisv (2.8k points)

1 Answer

0 votes
Hi Denis,

I would like to investigate this issue further - let's take this issue offline.
answered by dhelper (11.9k points)
...