Resharper and Moq "Returns" method

I have a simple mocked class longRunningLibrary I want the method Returns from Moq to output some text ("This method...") which you can see in the following part of code :

 _longRunningLibrary
   .Setup(lrl => lrl.RunForALongTime(30))
   .Returns("This method has been mocked!");

To be outputted inside the Unit Test Sessions part of resharper, but I can't do it. How to proceed, is it even possible ?

2 comments
Comment actions Permalink

Hi Mehdy,

You could try this :

var text = string.Empty();
_longRunningLibrary
   .Setup(lrl => lrl.RunForALongTime(30))
   .Callback(() => text = "This method has been mocked!");
_longRunningLibrary.RunForALongTime(30);

Console.WriteLine(text);

0
Comment actions Permalink

Hello and thank you for this answer, please notice that I'm a begginner this is not a critic, I don't even know if this kind of method from Moq is useful when making test, anyway thank you for the answer.

0

Please sign in to leave a comment.