I wanted to bypass an internal method call and hence have mocked it. The mocked method delegate looks like:
public Microsoft.Moles.Framework.MolesDelegates.OutOutFunc<string,string,string,
byte[]> GetlineStringStringOutStringOut { set; }
Now, in my test when I try to access this mocked method like:
GetlineStringStringOutStringOut = (a,b,c) => {return bytearray};
an error occurs saying parameter 2 and 3 must be declared with out keyword but when I declare them with out keyword it's doesn't compile at all. I read other SO questions and answers and it seems it can't be done.
Is it possible to provide user defined delegate for this? If yes, please give an example.
EDIT:
I tried to declare my own delegate of same signature as mocked delegate
static delegate byte[] MyFunc<String, String, String>
(string a, out string b, out string c);
but I'm not sure how can I call this while calling the mocked delegate method?
You need to assign values to b
and c
variables before returning from your lambda and also specify the parameters types explicitly, something like this:
GetlineStringStringOutStringOut = (string a, out string b, out string c) =>
{
b = c = string.Empty;
return new byte[] { };
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With