2019-01-21 17:33:20 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
|
|
|
|
using Bootstrap.Security;
|
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2019-05-15 00:22:13 +08:00
|
|
|
|
namespace Bootstrap.Admin.Api.SqlServer
|
2019-01-21 17:33:20 +08:00
|
|
|
|
{
|
|
|
|
|
public class DictTest : ControllerTest
|
|
|
|
|
{
|
|
|
|
|
public DictTest(BAWebHost factory) : base(factory, "api/Dicts") { }
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async void Get_Ok()
|
|
|
|
|
{
|
|
|
|
|
// 菜单 系统菜单 系统使用条件
|
|
|
|
|
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<QueryData<BootstrapDict>>(query);
|
|
|
|
|
Assert.Single(qd.rows);
|
2019-05-18 21:21:03 +08:00
|
|
|
|
|
|
|
|
|
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<QueryData<BootstrapDict>>(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<QueryData<BootstrapDict>>(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<QueryData<BootstrapDict>>(query);
|
|
|
|
|
Assert.Single(qd.rows);
|
2019-01-21 17:33:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async void PostAndDelete_Ok()
|
|
|
|
|
{
|
|
|
|
|
var ret = await Client.PostAsJsonAsync<BootstrapDict, bool>("", new BootstrapDict() { Name = "UnitTest-Dict", Category = "UnitTest-Category", Code = "0", Define = 0 });
|
|
|
|
|
Assert.True(ret);
|
|
|
|
|
|
2019-05-18 17:48:40 +08:00
|
|
|
|
var ids = DictHelper.RetrieveDicts().Where(d => d.Name == "UnitTest-Dict").Select(d => d.Id);
|
2019-01-21 17:33:20 +08:00
|
|
|
|
Assert.True(await Client.DeleteAsJsonAsync<IEnumerable<string>, bool>(ids));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|