TDD?е???????д????????
???????????? ???????[ 2014/4/18 13:52:10 ] ????????TDD ??????? ????????
[TestMethod()]
public void Should_Password_Equal_To_ConfirmPassword()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai"??
Password = "a121ww123"??
ConfirmPassword = "a121ww1231"
};
string expected = "password is not equal to confirmPassword";
string actual = target.CreateUser(user);
Assert.AreEqual(expected?? actual);
}
[TestMethod()]
public void Should_Creator_Not_Null_Or_Empty()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai"??
Password = "a121ww123"??
ConfirmPassword = "a121ww1231"
};
string expected = "password is not equal to confirmPassword";
string actual = target.CreateUser(user);
Assert.AreEqual(expected?? actual);
}
[TestMethod()]
public void Should_CreateDate_Assigned_Value()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai"??
Password = "a121ww123"??
ConfirmPassword = "a121ww123"??
Creator = "ethan.cai"
};
string expected = "createdate must be assigned value";
string actual = target.CreateUser(user);
Assert.AreEqual(expected?? actual);
}
[TestMethod()]
public void Should_CreatorIP_Not_Null_Or_Empty()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai"??
Password = "a121ww123"??
ConfirmPassword = "a121ww123"??
Creator = "ethan.cai"??
CreateDate = DateTime.Now
};
string expected = "creatorIP is null or empty";
string actual = target.CreateUser(user);
Assert.AreEqual(expected?? actual);
}
[TestMethod()]
public void Should_Trim_Username()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai "??
Password = "a121ww123"??
ConfirmPassword = "a121ww123"??
Creator = "ethan.cai"??
CreateDate = DateTime.Now??
CreatorIP = "127.0.0.1"
};
string expected = "ethan.cai";
target.CreateUser(user);
Assert.AreEqual(expected?? user.Username);
}
[TestMethod()]
public void Should_Save_MD5_Hash_Password()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai "??
Password = "a121ww123"??
ConfirmPassword = "a121ww123"??
Creator = "ethan.cai"??
CreateDate = DateTime.Now??
CreatorIP = "127.0.0.1"
};
string actual = target.CreateUser(user);
Assert.IsTrue("success" == actual
&& user.Password == BitConverter.ToString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("a121ww123"))));
}
[TestMethod()]
public void Should_Create_User_Successfully_When_User_Is_OK()
{
UserBusiness target = new UserBusiness();
User user = new User()
{
Username = "ethan.cai "??
Password = "a121ww123"??
ConfirmPassword = "a121ww123"??
Creator = "ethan.cai"??
CreateDate = DateTime.Now??
CreatorIP = "127.0.0.1"
};
string expected = "success";
string actual = target.CreateUser(user);
Assert.IsTrue(expected == actual);
}
}
??????????????????????????????????Should_Trim_Username??Should_Save_MD5_Hash_Password???????????????????б????????????????????????????Username?β????????????????????????????洢????????????????????б?????
???????????д???????????????????????????????????????????e???????????????????????????????????ò????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11