Yes I must use the WithExact.
My DummyDict is a class that will decorate a Dictionary. So the class is implementing IDictionary<string> and create an instance of Dictionary<string>. when a function is DummyDict is called, it calls the same function on the real Dictionary. (Decorator design pattern).
For your test, you can only implement the TryGetValue function.
For the workaround, I use the DoInstead with an if inside to validate the first parameter. It's uggly, but it works.
Isolate.WhenCalled(() => myDict.TryGetValue(streamId, out fakeOldStream))
.DoInstead(context =>
{
var streamIdParam = (StreamId) context.Parameters[0];
if (streamIdParam == streamId)
{
context.Parameters[1] = fakeOldStream;
return true;
}
else
{
context.Parameters[1] = null;
return false;
}
});