I am new to unit testing. I am creating an ASP.NET MVC3 application (although my question seems to be a language agnostic) and I am confused in the basic test.
I want to do a unit test to make sure that my ValidatePassword function works - it will contain a username and password, then a hash password and see if it matches the hash for the user in the database. If so, it returns true. The problem is that I am using a mock repository, so I will need to add a user to db before running my test. I canβt create this user in my test setup because I donβt know what will be the encrypted password until I run it through the function that I am testing. Is the answer to run it through the Hash function once, write it in my test, and then check with that?
I hope this is clear. Thank!
skaz source
share