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?
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.
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