This class is an implementation of the Answer interface allowing to pass functions as an answer.
It does a bit of work for the client:
// if the method has one parameter and the function also, the parameter is passed
mock.get(0) answers ( i => i.toString )
// if the method has one parameter and the function has two, the mock is passed as the second argument
mock.get(0) answers { (i, mock) => i.toString + " for mock " + mock.toString }
Similarly a mocked method with no parameters can use a function with one parameter. In that case, the mock will be passed
mock.size answers { mock => mock.hashCode }
In any other cases, if f is a function of 1 parameter, the array of the method parameters will be passed and if the function has
2 parameters, the second one will be the mock.
This class is an implementation of the Answer interface allowing to pass functions as an answer.
It does a bit of work for the client:
// if the method has one parameter and the function also, the parameter is passed mock.get(0) answers ( i => i.toString )
// if the method has one parameter and the function has two, the mock is passed as the second argument mock.get(0) answers { (i, mock) => i.toString + " for mock " + mock.toString }
Similarly a mocked method with no parameters can use a function with one parameter. In that case, the mock will be passed mock.size answers { mock => mock.hashCode }
In any other cases, if f is a function of 1 parameter, the array of the method parameters will be passed and if the function has 2 parameters, the second one will be the mock.