单元测试:直接写SQL不兼容SQLite数据库,改用InsertBatch方法插入数据

This commit is contained in:
Argo-Surface 2019-01-19 15:53:37 +08:00
parent f2ff717f29
commit 44dd905141
1 changed files with 4 additions and 1 deletions

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using Xunit; using Xunit;
using static Bootstrap.Admin.Controllers.Api.ExceptionsController; using static Bootstrap.Admin.Controllers.Api.ExceptionsController;
using static Longbow.Data.IPetaPocoExtensions;
namespace Bootstrap.Admin.Api namespace Bootstrap.Admin.Api
{ {
@ -92,7 +93,9 @@ namespace Bootstrap.Admin.Api
Assert.True(usr.Save(usr)); Assert.True(usr.Save(usr));
// Add author // Add author
DbManager.Create().Execute("delete from NavigationRole where RoleID in (select ID from Roles where RoleName = 'Default');insert into NavigationRole select ID, (select ID from Roles where RoleName = 'Default') from Navigations"); DbManager.Create().Execute("delete from NavigationRole where RoleID in (select ID from Roles where RoleName = 'Default')");
var rid = DbManager.Create().ExecuteScalar<string>("select ID from Roles where RoleName = 'Default'");
DbManager.Create().InsertBatch("NavigationRole", new Menu().RetrieveAllMenus("Admin").Select(m => new { RoleID = rid, NavigationID = m.Id }));
// change theme // change theme
usr.UserStatus = UserStates.ChangeTheme; usr.UserStatus = UserStates.ChangeTheme;