1. First download Nunit2.4.1 (http://xiazai.zol.com.cn/detail/27/264331.shtml#down)
2. Then download Resharper (http://kb.cnblogs.com/a/1441816/), is a Vs. NET plug-in, download, install, register. Used to execute self-written test classes.
3. Create a Test project and Test a method in the business logic class tbl_Account of the project.
/// <Summary>
/// Add a data entry
/// </Summary>
Public int Add (TPMS. Model. tbl_Account model)
{
Return dal. Add (model );
}
4. Compile the test class:
Namespace Test
{
[TestFixture]
Public class AccountAddTest
{
[Test]
Public void Add ()
{
BLL. tbl_Account bll = new BLL. tbl_Account ();
Model. tbl_Account account = new Model. tbl_Account ();
Account. PerName = "abc ";
Account. LoginName = "abc ";
Account. LoginPwd = "abc ";
Account. PerCode = 10;
Account. undefine4 = "0 ";
Account. undefine5 = "";
Int id = bll. Add (account );
Assert. AreEqual (12, id );
}
}
}
5. Execute Debug Unit Tests in VS. NET