修复单元测试
This commit is contained in:
parent
fd96c9d420
commit
b230b44b49
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
@ -15,8 +16,8 @@ namespace Bootstrap.DataAccess.Tests
|
|||
[TestInitialize]
|
||||
public void IniInitialized()
|
||||
{
|
||||
Group = new Group() { GroupName="_测试部门_",Description="我是很厉害的测试部门"};
|
||||
User = new User() { UserName = "_测试用户_", Password = "123", PassSalt = "123", DisplayName = "测试者" };
|
||||
Group = new Group() { GroupName = "_测试部门_", Description = "我是很厉害的测试部门" };
|
||||
User = new User() { UserName = "_测试用户_", Password = "123", PassSalt = "123", DisplayName = "测试者", RegisterTime = DateTime.Now, ApprovedTime = DateTime.Now };
|
||||
Role = new Role() { RoleName = "_测试角色_", Description = "测试角色" };
|
||||
}
|
||||
|
||||
|
@ -45,8 +46,8 @@ namespace Bootstrap.DataAccess.Tests
|
|||
|
||||
//测试更新部门方法 ID!=0
|
||||
var group = groups.FirstOrDefault(g => g.GroupName == Group.GroupName);
|
||||
group.Description="我是测试部门";
|
||||
Assert.IsTrue(GroupHelper.SaveGroup(group), string.Format("更新部门ID={0}操作失败,请检查GroupHelper.SaveGroup方法",group.ID));
|
||||
group.Description = "我是测试部门";
|
||||
Assert.IsTrue(GroupHelper.SaveGroup(group), string.Format("更新部门ID={0}操作失败,请检查GroupHelper.SaveGroup方法", group.ID));
|
||||
var ret = GroupHelper.RetrieveGroups(group.ID.ToString());
|
||||
Assert.IsTrue(ret.Count() == 1, "带参数的GroupHelper.RetrieveGroups方法失败");
|
||||
Assert.AreEqual(group.Description, ret.First().Description, string.Format("更新部门ID={0}操作失败,请检查GroupHelper.SaveGroup方法", group.ID));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
@ -15,7 +16,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
public void Initialized()
|
||||
{
|
||||
Role = new Role() { RoleName = "_测试角色_", Description = "这是一个测试角色", Checked = "0" };
|
||||
User = new User() { UserName = "_测试用户_", Password = "111", PassSalt = "111", DisplayName = "_测试用户_", Checked = "0" };
|
||||
User = new User() { UserName = "_测试用户_", Password = "111", PassSalt = "111", DisplayName = "_测试用户_", Checked = "0", RegisterTime = DateTime.Now, ApprovedTime = DateTime.Now };
|
||||
Group = new Group() { GroupName = "_测试部门_", Description = "这是一个测试部门", Checked = "0" };
|
||||
}
|
||||
[TestCleanup]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
@ -15,7 +16,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
[TestInitialize]
|
||||
public void Initialized()
|
||||
{
|
||||
User = new User() { UserName = "_测试用户_", Password = "123", PassSalt = "123",DisplayName="测试者" };
|
||||
User = new User() { UserName = "_测试用户_", Password = "123", PassSalt = "123", DisplayName = "测试者", RegisterTime = DateTime.Now, ApprovedTime = DateTime.Now };
|
||||
Role = new Role() { RoleName = "_测试角色_", Description = "测试角色" };
|
||||
Group = new Group() { GroupName = "_测试部门_", Description = "测试部门" };
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
[TestMethod]
|
||||
public void RetrieveUsersTest()
|
||||
{
|
||||
Assert.IsTrue(UserHelper.RetrieveUsers().Count() >=1, "不带参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
Assert.IsTrue(UserHelper.RetrieveUsers().Count() >= 1, "不带参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -73,9 +74,9 @@ namespace Bootstrap.DataAccess.Tests
|
|||
if (role == null) RoleHelper.SaveRole(Role);
|
||||
role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName);
|
||||
|
||||
Assert.IsTrue(UserHelper.SaveUsersByRoleId(role.ID,user.ID.ToString()), "存储角色用户信息失败");
|
||||
Assert.IsTrue(UserHelper.SaveUsersByRoleId(role.ID, user.ID.ToString()), "存储角色用户信息失败");
|
||||
|
||||
Assert.IsTrue(UserHelper.RetrieveUsersByRoleId(role.ID).Count()>=1, string.Format("获取角色ID={0}的用户信息失败",role.ID));
|
||||
Assert.IsTrue(UserHelper.RetrieveUsersByRoleId(role.ID).Count() >= 1, string.Format("获取角色ID={0}的用户信息失败", role.ID));
|
||||
|
||||
//删除数据
|
||||
string sql = "Delete from Users where UserName = '_测试用户_';";
|
||||
|
|
Loading…
Reference in New Issue