C#C
C#3y ago
joren

❔ ✅ Verifying the purpose of Moq usage

mockDatabase.Setup(db => db.GetUserName(It.IsAny<int>()))
    .Returns((int userId) => "User" + userId);

So, as you can see I use It.IsAny<int>() to mimic a value that would be passed, since GetUserName() requres an integer passed as argument.

However this value is not used in the actual mock, but rather the
string result = userManager.GetUserDisplayName(42);

the 42 that is passed here, which then calls GetUserName() inside of it.
Was this page helpful?