diff --git a/Bootstrap.Admin/Query/QueryLoginOption.cs b/Bootstrap.Admin/Query/QueryLoginOption.cs index 91851f4a..e8ec48ec 100644 --- a/Bootstrap.Admin/Query/QueryLoginOption.cs +++ b/Bootstrap.Admin/Query/QueryLoginOption.cs @@ -30,7 +30,7 @@ namespace Bootstrap.Admin.Query /// public QueryData RetrieveData() { - if (string.IsNullOrEmpty(Order)) Order = "LoginTime desc"; + if (string.IsNullOrEmpty(Order)) Order = "desc"; var data = LoginHelper.RetrievePages(this, StartTime, EndTime, LoginIP); return new QueryData { diff --git a/UnitTest/Bootstrap.Admin/Api/DictTest.cs b/UnitTest/Bootstrap.Admin/Api/DictTest.cs index ad2b7f77..eabee8d6 100644 --- a/UnitTest/Bootstrap.Admin/Api/DictTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/DictTest.cs @@ -11,24 +11,19 @@ namespace Bootstrap.Admin.Api.SqlServer { public DictTest(BAWebHost factory) : base(factory, "api/Dicts") { } - [Fact] - public async void Get_Ok() + [Theory()] + [InlineData("Category", "asc")] + [InlineData("Name", "asc")] + [InlineData("Code", "asc")] + [InlineData("Define", "asc")] + [InlineData("Category", "desc")] + [InlineData("Name", "desc")] + [InlineData("Code", "desc")] + [InlineData("Define", "desc")] + public async void Get_Ok(string query, string order) { // 菜单 系统菜单 系统使用条件 - var query = "?sort=Category&order=asc&offset=0&limit=20&category=%E8%8F%9C%E5%8D%95&name=%E7%B3%BB%E7%BB%9F%E8%8F%9C%E5%8D%95&define=0&_=1547608210979"; - var qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=Name&order=asc&offset=0&limit=20&category=%E8%8F%9C%E5%8D%95&name=%E7%B3%BB%E7%BB%9F%E8%8F%9C%E5%8D%95&define=0&_=1547608210979"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=Code&order=asc&offset=0&limit=20&category=%E8%8F%9C%E5%8D%95&name=%E7%B3%BB%E7%BB%9F%E8%8F%9C%E5%8D%95&define=0&_=1547608210979"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=Define&order=asc&offset=0&limit=20&category=%E8%8F%9C%E5%8D%95&name=%E7%B3%BB%E7%BB%9F%E8%8F%9C%E5%8D%95&define=0&_=1547608210979"; - qd = await Client.GetAsJsonAsync>(query); + var qd = await Client.GetAsJsonAsync>($"?sort={query}&order={order}&offset=0&limit=20&category=%E8%8F%9C%E5%8D%95&name=%E7%B3%BB%E7%BB%9F%E8%8F%9C%E5%8D%95&define=0&_=1547608210979"); Assert.Single(qd.rows); } diff --git a/UnitTest/Bootstrap.Admin/Api/GroupsTest.cs b/UnitTest/Bootstrap.Admin/Api/GroupsTest.cs index 54b44058..0ae0e2d1 100644 --- a/UnitTest/Bootstrap.Admin/Api/GroupsTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/GroupsTest.cs @@ -16,6 +16,8 @@ namespace Bootstrap.Admin.Api.SqlServer // 菜单 系统菜单 系统使用条件 var query = "?sort=GroupName&order=asc&offset=0&limit=20&groupName=Admin&description=%E7%B3%BB%E7%BB%9F%E9%BB%98%E8%AE%A4%E7%BB%84&_=1547614230481"; var qd = await Client.GetAsJsonAsync>(query); + query = "?sort=GroupName&order=desc&offset=0&limit=20&groupName=Admin&description=%E7%B3%BB%E7%BB%9F%E9%BB%98%E8%AE%A4%E7%BB%84&_=1547614230481"; + qd = await Client.GetAsJsonAsync>(query); Assert.Single(qd.rows); } diff --git a/UnitTest/Bootstrap.Admin/Api/LoginTest.cs b/UnitTest/Bootstrap.Admin/Api/LoginTest.cs index e833453a..9926b5e2 100644 --- a/UnitTest/Bootstrap.Admin/Api/LoginTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/LoginTest.cs @@ -12,7 +12,7 @@ namespace Bootstrap.Admin.Api.SqlServer [Fact] public async void Login_Get() { - var users = await Client.GetAsJsonAsync>(); + var users = await Client.GetAsJsonAsync>("?sort=LoginTime&order=&offset=0&limit=20&startTime=&endTime=&loginIp=&_=1560933256621"); Assert.NotEmpty(users.rows); } diff --git a/UnitTest/Bootstrap.Admin/Api/MenusTest.cs b/UnitTest/Bootstrap.Admin/Api/MenusTest.cs index e630fc79..5579ef8e 100644 --- a/UnitTest/Bootstrap.Admin/Api/MenusTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/MenusTest.cs @@ -11,35 +11,24 @@ namespace Bootstrap.Admin.Api.SqlServer { public MenusTest(BAWebHost factory) : base(factory, "api/Menus") { } - [Fact] - public async void Get_Ok() + [Theory] + [InlineData("Order", "asc")] + [InlineData("Name", "asc")] + [InlineData("ParentName", "asc")] + [InlineData("CategoryName", "asc")] + [InlineData("Target", "asc")] + [InlineData("IsResource", "asc")] + [InlineData("Application", "asc")] + [InlineData("Order", "desc")] + [InlineData("Name", "desc")] + [InlineData("ParentName", "desc")] + [InlineData("CategoryName", "desc")] + [InlineData("Target", "desc")] + [InlineData("IsResource", "desc")] + [InlineData("Application", "desc")] + public async void Get_Ok(string query, string order) { - var query = "?sort=Order&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - var qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=Name&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=ParentName&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=CategoryName&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=Target&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=IsResource&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=Application&order=asc&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"; - qd = await Client.GetAsJsonAsync>(query); + var qd = await Client.GetAsJsonAsync>($"?sort={query}&order={order}&offset=0&limit=100&parentName=%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2&name=%E5%85%B3%E4%BA%8E&category=1&isresource=0&appCode=2&_=1558235377255"); Assert.Single(qd.rows); } diff --git a/UnitTest/Bootstrap.Admin/Api/RolesTest.cs b/UnitTest/Bootstrap.Admin/Api/RolesTest.cs index eb3c046a..6f3bf1db 100644 --- a/UnitTest/Bootstrap.Admin/Api/RolesTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/RolesTest.cs @@ -10,12 +10,13 @@ namespace Bootstrap.Admin.Api.SqlServer { public RolesTest(BAWebHost factory) : base(factory, "api/Roles") { } - [Fact] - public async void Get_Ok() + [Theory] + [InlineData("RoleName", "asc")] + [InlineData("RoleName", "desc")] + public async void Get_Ok(string query, string order) { // 菜单 系统菜单 系统使用条件 - var query = "?sort=RoleName&order=asc&offset=0&limit=20&roleName=Administrators&description=%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%91%98&_=1547625202230"; - var qd = await Client.GetAsJsonAsync>(query); + var qd = await Client.GetAsJsonAsync>($"?sort={query}&order={order}&offset=0&limit=20&roleName=Administrators&description=%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%91%98&_=1547625202230"); Assert.Single(qd.rows); } diff --git a/UnitTest/Bootstrap.Admin/Api/TracesTest.cs b/UnitTest/Bootstrap.Admin/Api/TracesTest.cs index 8ede8143..36254607 100644 --- a/UnitTest/Bootstrap.Admin/Api/TracesTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/TracesTest.cs @@ -16,7 +16,7 @@ namespace Bootstrap.Admin.Api.SqlServer trac.Save(trac); // 菜单 系统菜单 系统使用条件 - var query = "?sort=LogTime&order=desc&offset=0&limit=20&operateType=&OperateTimeStart=&OperateTimeEnd=&_=1547617573596"; + var query = "?sort=LogTime&order=desc&offset=0&limit=20&operateType=&OperateTimeStart=&OperateTimeEnd=&AccessIP=&_=1547617573596"; var qd = await Client.GetAsJsonAsync>(query); Assert.NotEmpty(qd.rows); diff --git a/UnitTest/Bootstrap.Admin/Api/UsersTest.cs b/UnitTest/Bootstrap.Admin/Api/UsersTest.cs index 60679d4a..41353e74 100644 --- a/UnitTest/Bootstrap.Admin/Api/UsersTest.cs +++ b/UnitTest/Bootstrap.Admin/Api/UsersTest.cs @@ -21,28 +21,21 @@ namespace Bootstrap.Admin.Api.SqlServer Assert.Equal(HttpStatusCode.NoContent, resp.StatusCode); } - [Fact] - public async void Get_Ok() + [Theory] + [InlineData("DisplayName", "asc")] + [InlineData("UserName", "asc")] + [InlineData("RegisterTime", "asc")] + [InlineData("ApprovedTime", "asc")] + [InlineData("ApprovedBy", "asc")] + [InlineData("DisplayName", "desc")] + [InlineData("UserName", "desc")] + [InlineData("RegisterTime", "desc")] + [InlineData("ApprovedTime", "desc")] + [InlineData("ApprovedBy", "desc")] + public async void Get_Ok(string query, string order) { // 菜单 系统菜单 系统使用条件 - var query = "?sort=DisplayName&order=asc&offset=0&limit=20&name=Admin&displayName=Administrator&_=1547628247338"; - var qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=UserName&order=asc&offset=0&limit=20&name=Admin&displayName=Administrator&_=1547628247338"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=RegisterTime&order=asc&offset=0&limit=20&name=Admin&displayName=Administrator&_=1547628247338"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=ApprovedTime&order=asc&offset=0&limit=20&name=Admin&displayName=Administrator&_=1547628247338"; - qd = await Client.GetAsJsonAsync>(query); - Assert.Single(qd.rows); - - query = "?sort=ApprovedBy&order=asc&offset=0&limit=20&name=Admin&displayName=Administrator&_=1547628247338"; - qd = await Client.GetAsJsonAsync>(query); + var qd = await Client.GetAsJsonAsync>($"?sort={query}&order={order}&offset=0&limit=20&name=Admin&displayName=Administrator&_=1547628247338"); Assert.Single(qd.rows); } diff --git a/UnitTest/Bootstrap.Admin/Controllers/HomeTest.cs b/UnitTest/Bootstrap.Admin/Controllers/HomeTest.cs index e244966c..0f1aad5d 100644 --- a/UnitTest/Bootstrap.Admin/Controllers/HomeTest.cs +++ b/UnitTest/Bootstrap.Admin/Controllers/HomeTest.cs @@ -1,4 +1,5 @@ -using Xunit; +using Microsoft.AspNetCore.Authentication.Cookies; +using Xunit; namespace Bootstrap.Admin.Controllers.SqlServer { @@ -28,5 +29,14 @@ namespace Bootstrap.Admin.Controllers.SqlServer Assert.Contains("服务器内部错误", content); } } + + [Fact] + public async void Error_Redirect_Ok() + { + var r = await Client.GetAsync($"/Home/Error/404?{CookieAuthenticationDefaults.ReturnUrlParameter}=/Home/UnitTest"); + Assert.True(r.IsSuccessStatusCode); + var content = await r.Content.ReadAsStringAsync(); + Assert.Contains("/Home/UnitTest", content); + } } }