How to provide a user-defined delegate with options in Microsoft Moles

I wanted to get around the challenge of the internal method and therefore ridicule it. The mocking delegate looks like this:

public Microsoft.Moles.Framework.MolesDelegates.OutOutFunc<string,string,string, byte[]> GetlineStringStringOutStringOut { set; } 

Now, in my test, when I try to access this bullied method, for example:

 GetlineStringStringOutStringOut = (a,b,c) => {return bytearray}; 

an error occurs indicating that parameter 2 and 3 should be declared with the out keyword, but when I declare them with the out keyword, it does not compile at all. I read other questions and answers, and it seems this is not possible.

Can a user-defined delegate be provided for this? If yes, please give an example.

EDIT:

I tried to declare my own delegate with the same signature as the laughed delegate

 static delegate byte[] MyFunc<String, String, String> (string a, out string b, out string c); 

but I'm not sure how this can be called calling the delegate method?

+4
source share
1 answer

You need to assign values ​​to the variables b and c before returning from your lambda, and also explicitly specify the types of parameters, for example:

 GetlineStringStringOutStringOut = (string a, out string b, out string c) => { b = c = string.Empty; return new byte[] { }; }; 
+6
source

Source: https://habr.com/ru/post/1385866/


All Articles