test: 补全单元测试

This commit is contained in:
Argo Window10 2019-11-15 16:58:34 +08:00
parent a4ba50cea7
commit 47bfeb59eb
2 changed files with 38 additions and 1 deletions

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using Bootstrap.DataAccess;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Xunit;
@ -28,5 +30,29 @@ namespace Bootstrap.Admin.Api.SqlServer
var cates = await Client.GetAsJsonAsync<IEnumerable<string>>("RetrieveParentMenus");
Assert.NotEmpty(cates);
}
[Fact]
public async void ValidateMenuBySubMenu_Ok()
{
var id = MenuHelper.RetrieveAllMenus("Admin").First(m => m.Name == "个人中心").Id;
var cates = await Client.GetAsJsonAsync<bool>($"ValidateMenuBySubMenu/{id}");
Assert.False(cates);
id = MenuHelper.RetrieveAllMenus("Admin").First(m => m.Name == "后台管理").Id;
cates = await Client.GetAsJsonAsync<bool>($"ValidateMenuBySubMenu/{id}");
Assert.True(cates);
}
[Fact]
public async void ValidateParentMenuById_Ok()
{
var id = MenuHelper.RetrieveAllMenus("Admin").First(m => m.Name == "个人中心").Id;
var cates = await Client.GetAsJsonAsync<bool>($"ValidateParentMenuById/{id}");
Assert.True(cates);
var subId = MenuHelper.RetrieveAllMenus("Admin").First(m => m.ParentId == id).Id;
cates = await Client.GetAsJsonAsync<bool>($"ValidateParentMenuById/{subId}");
Assert.False(cates);
}
}
}

View File

@ -22,5 +22,16 @@ namespace Bootstrap.Admin.Api.SqlServer
// for test SignalRManager.SendTaskLog
await System.Threading.Tasks.Task.Delay(6000);
}
[Fact]
public async void Put_Ok()
{
var resp = await Client.PutAsJsonAsync<string, bool>("/api/Tasks/SQL日志?operType=pause", "");
Assert.True(resp);
// receive log
var recv = await Client.PutAsJsonAsync<string, bool>("/api/Tasks/SQL日志?operType=run", "");
Assert.True(recv);
}
}
}