Mocking a function which uses out parameters

I have a function which uses out parameters. How can I mock this function?

My function is:

GetProperties(out string name, out string path, out string extension);

In my original code, I am doing this:

string Name;
string Path;
string Extension;
MyObject.GetProperties(out Name, out Path, out Extension);

Now, how I can mock this?

Answers


You should assign out variable's value before calling the method like this:

string Name = "name";
string Path = "path";
string Extension = "extension";
mock.Setup(item => item.GetProperties(out Name, out Path, out Extension))
    .Returns(someReturnValue);

Although I would prefer returning these values in your return type, instead of using so many out parameters.


Need Your Help

Highlight text inside textarea like Facebook does

javascript html css facebook

I try to achieve something like the Facebook does when you type @<NAME_OF_A_FRIEND> in a reply. After you choose a friend, the name of that friend is highlighted with a blueish background, so...

JAX-RS: Multiple paths

java jax-rs

Is it possible to do something like that?