How to fake method’s parameters
Although Typemock Isolator know how to fake out and ref parameters there are times that a certain parameter passed to shall return a specific value.
Consider this scenario – a call to a stream object:
In the test we want to fake the return value but we also want to fill the byte array with some valid values as well.
Setting the return value is easy just use WhenCalled(…).WillReturn(1024) but how can we cause the method to return a valid byte array as well? Luckily for us we can use DoInstead to change the method’s parameters as well its return value:
Now we can test our code knowing that when our stream will be called it will return a byte array that was declared by the test.