单元测试:修改ApproveUser_Ok单元测试,先删除,再插入,再授权,再删除测试数据

This commit is contained in:
Argo-Surface 2019-01-12 00:34:12 +08:00
parent 034fedfddb
commit 2f5be3a1d0
2 changed files with 9 additions and 1 deletions

View File

@ -119,6 +119,7 @@ namespace Bootstrap.DataAccess
/// <param name="value"></param>
public virtual bool Delete(IEnumerable<string> value)
{
if (!value.Any()) return true;
bool ret = false;
var db = DbManager.Db;
try

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using Xunit;
namespace Bootstrap.DataAccess
@ -50,7 +51,13 @@ namespace Bootstrap.DataAccess
public void ApproveUser_Ok()
{
var u = new User();
Assert.True(u.Approve("3", "Administrators"));
u.Delete(u.Retrieves().Where(usr => usr.UserName == "UnitTest").Select(usr => usr.Id));
var up = new User() { UserName = "UnitTest", Password = "123", Description = "新建用户用于测试批准", DisplayName = "UnitTest", Icon = "default.jpg" };
u.Save(up);
Assert.True(u.Approve(up.Id, "Administrators"));
u.Delete(new string[] { up.Id });
}
[Fact]