KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following method: public CustomObect MyMethod() { var lUser = GetCurrentUser(); if (lUser.HaveAccess) { //One behavior } else { //Other behavior } //return CustomObject } I want to mock IMyInterface.GetCurrentUser , so that while calling MyMethod I could get to one of the code paths to check it. How to do that with Moq? I'm doing the following thing: var moq = new Mock<IMyInterface>(); moq.Setup(x => x.GetCurrentUser()).Returns(lUnauthorizedUser); //act var lResult = moq.Object.MyMethod(); But for some reason lResult is always null , and when I'm trying to get into MyMethod in debug, I'm always skipping to the next statement.
Tags (comma-separated)
Save Edits
Cancel