test: 移除 Settings Post 单元测试

This commit is contained in:
Argo Zhang 2020-03-12 15:15:47 +08:00
parent 55d5e7f4fe
commit 4de4630dbc
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 15 additions and 31 deletions

View File

@ -33,8 +33,8 @@ namespace Bootstrap.Admin.Api
var data = new QueryAppOption() var data = new QueryAppOption()
{ {
AppId = "new", AppId = "new",
AppName = "UnitTest", AppName = "UnitTest_Put",
AppCode = "UnitTest", AppCode = "UnitTest_Put",
AppUrl = "http://localhost", AppUrl = "http://localhost",
AppTitle = "网站标题", AppTitle = "网站标题",
AppFooter = "网站页脚" AppFooter = "网站页脚"
@ -44,15 +44,24 @@ namespace Bootstrap.Admin.Api
Assert.True(resp); Assert.True(resp);
// Check // Check
var op = await Client.GetAsJsonAsync<QueryAppOption>("UnitTest"); var op = await Client.GetAsJsonAsync<QueryAppOption>(data.AppCode);
Assert.Equal(data.AppTitle, op.AppTitle); Assert.Equal(data.AppTitle, op.AppTitle);
// update
data.AppId = "edit";
data.AppUrl = "http://UnitTest";
resp = await Client.PutAsJsonAsync<QueryAppOption, bool>("", data);
Assert.True(resp);
op = await Client.GetAsJsonAsync<QueryAppOption>(data.AppCode);
Assert.Equal(data.AppUrl, op.AppUrl);
// 删除 // 删除
resp = await Client.DeleteAsJsonAsync<BootstrapDict, bool>("AppPath", new BootstrapDict() resp = await Client.DeleteAsJsonAsync<BootstrapDict, bool>("AppPath", new BootstrapDict()
{ {
Category = "UnitTest", Category = data.AppName,
Name = "UnitTest", Name = data.AppName,
Code = "UnitTest" Code = data.AppCode
}); });
Assert.True(resp); Assert.True(resp);
} }
@ -91,31 +100,6 @@ namespace Bootstrap.Admin.Api
resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("Demo", new BootstrapDict() { Name = "123789", Code = "0" }); resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("Demo", new BootstrapDict() { Name = "123789", Code = "0" });
Assert.True(resp); Assert.True(resp);
// AppPath
var dict = new BootstrapDict() { Category = "UnitTest", Name = "UnitTest", Code = "http://localhost/AppPath/" };
resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("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<BootstrapDict, bool>("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<BootstrapDict, bool>("AppPath", dict);
Assert.True(resp);
// Else
resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("UnitTest", dict);
Assert.False(resp);
} }
internal class CacheCorsItem : ICacheCorsItem internal class CacheCorsItem : ICacheCorsItem