新增GroupHelperTest.cs测试功能
This commit is contained in:
parent
56c4b26258
commit
e5cba6bf50
|
@ -54,6 +54,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="TerminalHelperTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GroupHelperTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj">
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Bootstrap.DataAccess.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class GroupHelperTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void RetrieveGroupsTest()
|
||||
{
|
||||
var result = GroupHelper.RetrieveGroups("1");
|
||||
Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的GroupHelper.RetrieveGroups方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
result = GroupHelper.RetrieveGroups();
|
||||
Assert.IsTrue(result.Count() >= 0, "不带参数的GroupHelper.RetrieveGroups方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SaveGroupTest()
|
||||
{
|
||||
Group p = new Group();
|
||||
p.GroupName = "测试群组2";
|
||||
p.Description = "测试群组2";
|
||||
|
||||
var result = GroupHelper.SaveGroup(p);
|
||||
Assert.IsTrue(result, "增加用户出错");
|
||||
|
||||
p.ID = 4;
|
||||
p.GroupName = "测试群组22";
|
||||
p.Description = "测试群组22";
|
||||
result = GroupHelper.SaveGroup(p);
|
||||
Assert.IsTrue(result, "更新用户出错");
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DeleteGroupTest()
|
||||
{
|
||||
string p = "2";
|
||||
try
|
||||
{
|
||||
GroupHelper.DeleteGroup(p);
|
||||
Assert.IsTrue(true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Assert.IsTrue(false, "删除用户出错");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue