From 2f5be3a1d0373d3ebcc539b37362c8fddae84e1f Mon Sep 17 00:00:00 2001 From: Argo-Surface Date: Sat, 12 Jan 2019 00:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9ApproveUser=5FOk=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=8C=E5=85=88=E5=88=A0=E9=99=A4=EF=BC=8C=E5=86=8D?= =?UTF-8?q?=E6=8F=92=E5=85=A5=EF=BC=8C=E5=86=8D=E6=8E=88=E6=9D=83=EF=BC=8C?= =?UTF-8?q?=E5=86=8D=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess/User.cs | 1 + UniTest/Bootstrap.DataAccess/UsersTest.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Bootstrap.DataAccess/User.cs b/Bootstrap.DataAccess/User.cs index 60366d84..a67a42ce 100644 --- a/Bootstrap.DataAccess/User.cs +++ b/Bootstrap.DataAccess/User.cs @@ -119,6 +119,7 @@ namespace Bootstrap.DataAccess /// public virtual bool Delete(IEnumerable value) { + if (!value.Any()) return true; bool ret = false; var db = DbManager.Db; try diff --git a/UniTest/Bootstrap.DataAccess/UsersTest.cs b/UniTest/Bootstrap.DataAccess/UsersTest.cs index 330719fe..3344778c 100644 --- a/UniTest/Bootstrap.DataAccess/UsersTest.cs +++ b/UniTest/Bootstrap.DataAccess/UsersTest.cs @@ -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]