I have a Unit Test for my LoginSystem, and it's failing and I have no idea why, In my opinion I think my code is correct, it seemed to be working for the past couple of weeks and I only found this error through Unit Testing.
public bool matchCheck(string Username, string Password)
{
//create a new bool and set it to false.
bool returnvar = false;
//for each basemember in the list of members.
foreach (BaseMember bm in hillracing.Members)
{
//if the username is equal to a list item username AND the password is also equal.
if (Username == bm.userName && Password == bm.passWord)
{
//they exist within the same object, so return true.
returnvar = true;
}
else
{
throw new Exception(" Did not match!");
}
}
//return this bool, true or false.
return returnvar;
}
Can someone tell me why my exception is always thrown? thanks.
Aucun commentaire:
Enregistrer un commentaire