???????????????????
???????????? ???????[ 2014/1/7 16:22:03 ] ??????????????? ???
?????????????????ftmark??????????????????pclion.UnitTest????????????????????pclion.IDB???????????????????????
??????????????Web????????????test??????test?????????WEB???壬???????????dbintfTest??asp.net????????????<div>?з??????Literal??????????Page_Load()??д???′???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using pclion.IDB;
using ftmark;
using dbintfTest;
using pclion.UnitTest;
public partial class test_dbintfTest : System.Web.UI.Page
{
protected void Page_Load(object sender?? EventArgs e)
{
DBIntfTest test = new DBIntfTest();
Assert.Init();
try
{
Literal1.Text += Assert.RunTestHtml("login"?? test.LoginTest);
Literal1.Text += "<br>" + Assert.RunTestHtml("UserGroup"??test.UserGroupTest);
}
finally
{
Literal1.Text += "<br>" + Assert.RunTestHtml("LogoutTest"?? test.LogoutTest);
}
Literal1.Text += "<br>" + Assert.EndofAll();
}
}
??????????????????????в????????иò??????????????????????????
??????????“LogoutTest"???????try-finally???У????????????????????????????????ε?????????е?????????????????ε???????????Login???????????????????Logout??
?????????????????£?
using System;
using System.Collections.Generic;
using System.Web;
namespace pclion.UnitTest
{
public class Assert
{
public static string name;
public static string msg;
private static bool success;
private static int total;
private static int passed;
public delegate void TestFunc();
#region ?????????????????
public static void Init()
{
total = 0;
passed = 0;
}
private static void BeginTest(string _name)
{
name = _name;
success = true;
msg = string.Empty;
}
private static string EndTest()
{
total++;
if (success) passed++;
string s = string.Format("[{0}][{1}] - "?? total?? name);
if (success) s += "ok";
else s += "Failure: " + msg;
return s;
}
public static string EndofAll()
{
string s;
if (total == passed) s = "all testes passed.";
else s = string.Format("[{0}] testes failure."?? total - passed);
return s;
}
/// <summary>
/// ???????????
/// </summary>
/// <param name="name">????????????</param>
/// <param name="func">???????????</param>
/// <returns>????????</returns>
public static string RunTest(string name?? TestFunc func)
{
string s;
BeginTest(name);
try
{
func();
}
catch (Exception err)
{
success = false;
msg = err.Message + "
" + err.StackTrace;
}
s = EndTest();
return s;
}
/// <summary>
/// RunTest??HTML?汾
/// </summary>
/// <param name="name"></param>
/// <param name="func"></param>
/// <returns>??????????HTML????</returns>
public static string RunTestHtml(string name?? TestFunc func)
{
return System.Web.HttpUtility.HtmlEncode(RunTest(name?? func));
}
#endregion
public static void AreEqual(bool expected)
{
success = success && expected;
}
public static void AreEqual<T>(T expected?? T actual)
{
success = success && expected.Equals(actual);
}
}
}
??????
???·???
??????????????????
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