??????vs2010??vs2013??ū????????????asp.net??ū??????????????????????????????????????????????????????С????????
???????????????Web?????е????????????????????????У????????ū???????????????????????????????????????????????????????????????????????£?????????????????????????????κζ???????????ü?????????д????????????κ????е?????????????
????????????????????????£?
?????????????????????????????assert.cs????????????App_Code?С?
??????д?????????????DBIntfTest???????????????????DBIntf?????????????????£?
using System;
using System.Data;
using System.Collections.Generic;
using pclion.IDB;
using pclion.UnitTest;
using ftmark;
namespace dbintfTest
{
/// <summary>
///???? DBIntfTest ????????????? ftmark.DBIntf ?????????
///</summary>
public class DBIntfTest
{
const string connstr = "Data Source=.;Persist Security Info=True;User id=sa;Password=123456;Initial Catalog=exam2013";
//private TestContext testContextInstance;
public int examid=8;
public string usercode = "yw0707";
public string passwd = "yw0707";
public int userid = 39;
public DBIntf dbintf;
public Config config;
public DBIntfTest()
{
dbintf = new DBIntf();
dbintf.Open(connstr);
config = new Config();
dbintf.config = config;
config.userinfo = new UserInfo();
}
/// <summary>
///DBIntf ????????
///</summary>
public void LoginTest()
{
ftmark.UserInfo userinfo = new UserInfo();
int nr = dbintf.login(examid?? usercode?? passwd?? ref userinfo);
Assert.AreEqual<int>(0?? nr);
config.userinfo = userinfo;
Assert.AreEqual<int>(examid?? userinfo.examid);
Assert.AreEqual<int>(39?? userinfo.userid);
Assert.AreEqual<string>(usercode??userinfo.usercode);
}
public void LogoutTest()
{
dbintf.logout();
object t = dbintf.db.ExecuteScalar("select logined from tb_user where userid=@userid"??
dbintf.db.Parameter("@userid"?? config.userinfo.userid));
Assert.AreEqual(t != null);
Assert.AreEqual(!(bool)t);
}
public void UserGroupTest()
{
UserGroup[] usergroups = dbintf.getUserGroup(config.userinfo.userid);
Assert.AreEqual(usergroups != null);
Assert.AreEqual<int>(1?? usergroups.Length);
config.usergroup = usergroups[0];
Assert.AreEqual<int>(1?? config.usergroup.subjectid);
Assert.AreEqual<int>(7?? config.usergroup.itemno);
}
}
}