From 4de4630dbc7cb4926191ae1140dd63eb7fbeb8ea Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 12 Mar 2020 15:15:47 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E7=A7=BB=E9=99=A4=20Settings=20Post=20?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bootstrap.Admin/Api/SettingsTest.cs | 46 ++++++------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/test/UnitTest/Bootstrap.Admin/Api/SettingsTest.cs b/test/UnitTest/Bootstrap.Admin/Api/SettingsTest.cs index 31538da2..5c73bfb8 100644 --- a/test/UnitTest/Bootstrap.Admin/Api/SettingsTest.cs +++ b/test/UnitTest/Bootstrap.Admin/Api/SettingsTest.cs @@ -33,8 +33,8 @@ namespace Bootstrap.Admin.Api var data = new QueryAppOption() { AppId = "new", - AppName = "UnitTest", - AppCode = "UnitTest", + AppName = "UnitTest_Put", + AppCode = "UnitTest_Put", AppUrl = "http://localhost", AppTitle = "网站标题", AppFooter = "网站页脚" @@ -44,15 +44,24 @@ namespace Bootstrap.Admin.Api Assert.True(resp); // Check - var op = await Client.GetAsJsonAsync("UnitTest"); + var op = await Client.GetAsJsonAsync(data.AppCode); Assert.Equal(data.AppTitle, op.AppTitle); + // update + data.AppId = "edit"; + data.AppUrl = "http://UnitTest"; + resp = await Client.PutAsJsonAsync("", data); + Assert.True(resp); + + op = await Client.GetAsJsonAsync(data.AppCode); + Assert.Equal(data.AppUrl, op.AppUrl); + // 删除 resp = await Client.DeleteAsJsonAsync("AppPath", new BootstrapDict() { - Category = "UnitTest", - Name = "UnitTest", - Code = "UnitTest" + Category = data.AppName, + Name = data.AppName, + Code = data.AppCode }); Assert.True(resp); } @@ -91,31 +100,6 @@ namespace Bootstrap.Admin.Api resp = await Client.PostAsJsonAsync("Demo", new BootstrapDict() { Name = "123789", Code = "0" }); Assert.True(resp); - - // AppPath - var dict = new BootstrapDict() { Category = "UnitTest", Name = "UnitTest", Code = "http://localhost/AppPath/" }; - resp = await Client.PostAsJsonAsync("AppPath", dict); - Assert.True(resp); - - Assert.Equal(dict.Code.TrimEnd('/'), DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "应用首页" && d.Name == dict.Name)?.Code ?? ""); - - // update by set dict.Define = 0 - dict.Define = 0; - dict.Code = "http://127.0.0.1/UnitTest"; - resp = await Client.PostAsJsonAsync("AppPath", dict); - Assert.True(resp); - - Assert.Equal(dict.Code.TrimEnd('/'), DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "应用首页" && d.Name == dict.Name)?.Code ?? ""); - - // del - dict.Name = "UnitTest"; - dict.Code = "UnitTest"; - resp = await Client.DeleteAsJsonAsync("AppPath", dict); - Assert.True(resp); - - // Else - resp = await Client.PostAsJsonAsync("UnitTest", dict); - Assert.False(resp); } internal class CacheCorsItem : ICacheCorsItem