BootstrapAdmin/Bootstrap.DataAccessTests/DictHelperTests.cs

55 lines
1.6 KiB
C#
Raw Normal View History

2016-10-28 15:30:07 +08:00
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Bootstrap.DataAccess.Tests
{
[TestClass]
public class DictHelperTests
{
[TestMethod]
public void RetrieveDictsTest()
{
SaveDictTest();
var result = DictHelper.RetrieveDicts("1");
Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的DictHelper.RetrieveDicts方法调用失败请检查数据库连接或者数据库SQL语句");
result = DictHelper.RetrieveDicts();
Assert.IsTrue(result.Count() >= 0, "不带参数的DictHelper.RetrieveDicts方法调用失败请检查数据库连接或者数据库SQL语句");
}
[TestMethod]
public void SaveDictTest()
{
Dict p = new Dict();
p.Category = "测试省份";
p.Name = "测试城市";
p.Code = "测试字典";
var result = DictHelper.SaveDict(p);
Assert.IsTrue(result, "增加用户出错");
p.ID = 1;
p.Category = "测试省份22";
p.Name = "测试城市22";
p.Code = "测试字典22";
result = DictHelper.SaveDict(p);
Assert.IsTrue(result, "更新用户出错");
}
[TestMethod]
public void DeleteDictTest()
{
SaveDictTest();
string p = "1";
try
{
DictHelper.DeleteDict(p);
Assert.IsTrue(true);
}
catch
{
Assert.IsTrue(false, "删除用户出错");
}
}
}
}