好的,我正在为会员密码更改编写测试。下面的代码是我到目前为止所拥有的。我需要一些帮助来检查密码格式。最小字符长度为 7,最大长度为 8。
此外,我可以测试密码格式是否清晰,但如何测试加密格式?
有人可以帮忙吗?
[TestMethod]
public void TestChangePassword()
{
try
{
AsaMembershipProvider prov = this.GetMembershipProvider();
MembershipCreateStatus status;
//creates user
MembershipUser user = prov.CreateUser("testUserX", "12345", "test.UserX@abc.com", "", "", true, null, out status);
//gets user
user = prov.GetUser("testUserX", false);
Assert.AreEqual(user.UserName, "testUserX");
//Authenticates username and password
var isAuthenticated = prov.ValidateUser(user.UserName, "12345");
Assert.IsTrue(isAuthenticated);
//changes password
prov.ChangePassword("testUserX", "12345", "ABCDE");
//Validates password has been changed
prov.ValidateUser(user.UserName, "ABCDE");
Assert.IsTrue(isAuthenticated);
// Change password back
prov.ChangePassword("testUserX", "ABCDE", "12345");
//Validates password has been changed back
prov.ValidateUser(user.UserName, "12345");
//Deletes User
prov.DeleteUser("testUserX", true);
//tries to get user again
user = prov.GetUser("testUserX", false);
//test that no user is returned
Assert.AreEqual(null, user);
}
catch (Exception ex)
{
LogMessage(ex);
Assert.Fail(ex.Message);
}
}