We have also encountered this problem in 6.0.8; with the sample snippet provided below. We wanted to execute a different set of statements for different overloads of the same Insert method.
Cache fakeCache = new Cache();
var cacheDictionary = new Dictionary<string, object>();
Isolate.WhenCalled(() => fakeCache.Insert(null, null))
.DoInstead(callContext =>
{
cacheDictionary[callContext.Parameters[0] as string] = callContext.Parameters[1];
});
Isolate.WhenCalled(() => fakeCache.Insert(null, null, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, null))
.DoInstead(callContext =>
{
var x = callContext.Parameters[5] as CacheItemUpdateCallback;
cacheDictionary[callContext.Parameters[0] as string] = callContext.Parameters[1];
});
The workaround that was mentioned worked for us. However, it does rely on checking the parameter count, and possibly the parameter types, to selectively execute statements.
Hopefully, it will be addressed in a future release.