【发布时间】:2015-05-24 10:54:20
【问题描述】:
我的 LoginSystem 有一个单元测试,但它失败了,我不知道为什么,在我看来,我认为我的代码是正确的,它似乎在过去几周内工作,我只是通过单元测试。
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;
}
谁能告诉我为什么总是抛出我的异常?谢谢。
【问题讨论】:
标签: c# unit-testing