I am quite new to Moq and I am not sure is this even possible, but let say, if I have one method named GeneratedHashedAndSaltedPassword()and I am making a call to that method from method named CheckUsersPassword() is there any chance that i can write from Unit test Moq expression that says: Verify if GeneratedHashedAndSaltedPassword is call from CheckUsersPassword method?
I will know that CheckUsersPassword method preformed correctly if it makes a call to GeneratedHashedAndSaltedPassword method without any exception.
What I have for now is not much, since I am having difficult time with Moq and it's logic.
[Test] public void CheckIfPasswordIsHashed_Test() { var securityServiceMock = new Mock<User>(); securityServiceMock.Setup(m => m.CheckUsersPassword(It.IsAny<string>())).Returns(true); securityServiceMock.VerifyAll(); } I was trying to SetUp CheckUsersPassword, but I still don't know how or even if I can preform Verification I need. Does somebody has more experience with this kind of issue?
This is what CheckUserPassword does:
public bool CheckUsersPassword(string password) { return SecurityService.GenerateHashedAndSaltedPassword(password, Salt) == Password; } It makes simple call to GenerateHashedAndSaltedPassword() and compares result with current user password.
CheckUsersPasswordmethod?