I have read the answer in this question: Using Moq to mock only some methods
My situation is similar but actually opposite or inverted at the same time. I will just use the same example/notation to illustrate it.
Suppose we are in this situation:
public CustomObect MyMethod()
{
var lUser = GetCurrentUser();
if (lUser.HaveAccess)
{
//One behavior
}
else
{
//Other behavior
}
//return CustomObject
}
The user in that question wanted to mock GetCurrentUser()
. In my case, I don't want to mock GetCurrentUser()
, I want it to be called, and I want the rest of MyMethod()
to be called.
How would I go about that?