Has this been fixed? I'm using Isolator 6.0.8 and have what appears to be a related issue. If I try to Swap.CallsOn a collection-based object (with parameterized property indexer overloads) I get something similar.
System.Web.SessionState.HttpSessionState is basically a wrapper around a System.Collections.Specialized.NameObjectCollectionBase. The System.Collections.Specialized.NameValueCollection derives from NameObjectCollectionBase.
So in a web-related test, I have:
var session = Isolate.Fake.Instance<HttpSessionState>();
var coll = new NameValueCollection();
Isolate.Swap.CallsOn(session).WithCallsTo(coll);
Later, in my tests, I do:
Assert.IsNull(session["key"]);
On this line, I get an exception:
System.ArgumentException: Object of type 'System.String' cannot be converted to type 'System.Int32'.
The reason for this, it appears, is that the collection has two indexer properties:
public string this[string] { get; set; }
public string this[int] { get; set; }
That is, you can access items in HttpSessionState OR in NameValueCollection by item index or by item key. The swapper is, I'm guessing, picking the wrong indexer and trying to call the int-based collection indexer when I'm passing a string key.
I can work around this, but it would be nice to have this work out of the box.