I've created an MVC application and I've set up Roger Martin's sqlite Providers in place of the default Providers. I'm curious about how I would go about unit testing these.
Below is a stripped down method that has many validations, only one of which is still present. Among other things, I want to write tests that ensures one can't register if the username has been taken, and can register if the username is free (and other validations pass), etc.
I can see how unit tests could determine success or failure, but not failure for a specific reason, unless I check the output MembershipCreateStatus parameter but I'm not sure if there is a better way. Further, what I need to give for object providerUserKey? Any insight would be very helpful.
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
//some validations, and then:
MembershipUser u = GetUser(username, false);
if (u == null)
{
///register user
status = MembershipCreateStatus.Success;
return GetUser(username, false);
}
else
{
status = MembershipCreateStatus.DuplicateUserName;
}
return null;
}