BootstrapAdmin11/Bootstrap.DataAccessTests/LogHelperTests.cs

41 lines
1.4 KiB
C#
Raw Normal View History

2016-10-28 16:57:27 +08:00
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Bootstrap.DataAccess.Tests
{
[TestClass]
public class LogHelperTests
{
[TestMethod]
public void RetrieveLogsTest()
{
var result = LogHelper.RetrieveLogs("1");
Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的LogHelper.RetrieveLogs方法调用失败请检查数据库连接或者数据库SQL语句");
result = LogHelper.RetrieveLogs();
Assert.IsTrue(result.Count() >= 0, "带有参数的LogHelper.RetrieveLogs方法调用失败请检查数据库连接或者数据库SQL语句");
}
[TestMethod]
public void saveLogTest()
{
Log p = new Log();
p.OperationType = 1;
p.UserID = 1;
p.OperationTime = System.DateTime.Now;
p.TableName = "日志";
p.BusinessName = "新增日志信息";
p.PrimaryKey = "ID";
p.SqlText = "Insert Into Logs";
p.OperationIp = "0.0.0.0";
var result = LogHelper.saveLog(p);
Assert.IsTrue(result, "新增日志信息出错");
}
[TestMethod]
public void DeleteLogTest()
{
string p = "2";
Assert.IsTrue(LogHelper.DeleteLog(p),"删除日志信息出错");
}
}
}