单元测试:增加api/Apps单元测试

This commit is contained in:
Argo-Surface 2019-02-24 19:15:42 +08:00
parent c262c09c5f
commit 3e98f49070
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,28 @@
using Bootstrap.DataAccess;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Bootstrap.Admin.Api
{
public class AppsTest : ControllerTest
{
public AppsTest(BAWebHost factory) : base(factory, "api/Apps") { }
[Fact]
public async void Post_Ok()
{
var rid = new Role().Retrieves().Where(r => r.RoleName == "Administrators").First().Id;
var cates = await Client.PostAsJsonAsync<string, IEnumerable<App>>(rid, string.Empty);
Assert.NotEmpty(cates);
}
[Fact]
public async void Put_Ok()
{
var rid = new Role().Retrieves().Where(r => r.RoleName == "Administrators").First().Id;
var ret = await Client.PutAsJsonAsync<IEnumerable<string>, bool>(rid, new string[] { "1", "2" });
Assert.True(ret);
}
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.Admin.Api.MySql
{
[Collection("MySqlContext")]
public class AppsTest : Api.AppsTest
{
public AppsTest(MySqlBAWebHost factory) : base(factory) { }
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.Admin.Api.SQLite
{
[Collection("SQLiteContext")]
public class AppsTest : Api.CategoryTest
{
public AppsTest(SQLiteBAWebHost factory) : base(factory) { }
}
}

Binary file not shown.