单元测试:增加RegisterController单元测试

This commit is contained in:
Argo-Surface 2019-01-16 15:50:04 +08:00
parent ada2ebdd38
commit 51e3b27134
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
using Bootstrap.DataAccess;
using System.Linq;
using Xunit;
namespace Bootstrap.Admin.Api
{
public class RegisterTest : ApiTest
{
public RegisterTest(BAWebHost factory) : base(factory, "Register", true)
{
}
[Fact]
public async void Get_Ok()
{
var resp = await Client.GetAsJsonAsync<bool>("?userName=Admin");
Assert.False(resp);
}
[Fact]
public async void Post_Ok()
{
// register new user
var nusr = new User() { UserName = "UnitTest-RegisterController", DisplayName = "UnitTest", Password = "1", Description = "UnitTest" };
var resp = await Client.PostAsJsonAsync<User, bool>("", nusr);
Assert.True(resp);
nusr.Delete(nusr.RetrieveNewUsers().Where(u => u.UserName == nusr.UserName).Select(u => u.Id));
}
}
}