单元测试:修改用户限制非法字符方法的单元测试 link #ITL7E
#Issue https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues/ITL7E
This commit is contained in:
parent
7a98489d5a
commit
a5c029e2aa
|
@ -19,10 +19,9 @@ namespace Bootstrap.Admin.Api
|
||||||
public async void Post_Ok()
|
public async void Post_Ok()
|
||||||
{
|
{
|
||||||
// register new user
|
// register new user
|
||||||
var nusr = new User() { UserName = "UnitTest-RegisterController", DisplayName = "UnitTest", Password = "1", Description = "UnitTest" };
|
var nusr = new User() { UserName = "UnitTest_RegisterController", DisplayName = "UnitTest", Password = "1", Description = "UnitTest" };
|
||||||
var resp = await Client.PostAsJsonAsync<User, bool>(nusr);
|
var resp = await Client.PostAsJsonAsync<User, bool>(nusr);
|
||||||
Assert.True(resp);
|
Assert.True(resp);
|
||||||
|
|
||||||
nusr.Delete(nusr.RetrieveNewUsers().Where(u => u.UserName == nusr.UserName).Select(u => u.Id));
|
nusr.Delete(nusr.RetrieveNewUsers().Where(u => u.UserName == nusr.UserName).Select(u => u.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Bootstrap.Admin.Api
|
||||||
var user = new User();
|
var user = new User();
|
||||||
user.Delete(user.Retrieves().Where(usr => usr.UserName == "UnitTest-Delete").Select(usr => usr.Id));
|
user.Delete(user.Retrieves().Where(usr => usr.UserName == "UnitTest-Delete").Select(usr => usr.Id));
|
||||||
|
|
||||||
var nusr = new User { UserName = "UnitTest-Delete", Password = "1", DisplayName = "DisplayName", ApprovedBy = "System", ApprovedTime = DateTime.Now, Description = "Desc", Icon = "default.jpg" };
|
var nusr = new User { UserName = "UnitTest_Delete", Password = "1", DisplayName = "DisplayName", ApprovedBy = "System", ApprovedTime = DateTime.Now, Description = "Desc", Icon = "default.jpg" };
|
||||||
var resp = await Client.PostAsJsonAsync<User, bool>("", nusr);
|
var resp = await Client.PostAsJsonAsync<User, bool>("", nusr);
|
||||||
Assert.True(resp);
|
Assert.True(resp);
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace Bootstrap.Admin.Api
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void Put_Ok()
|
public async void Put_Ok()
|
||||||
{
|
{
|
||||||
var usr = new User { UserName = "UnitTest-Change", Password = "1", DisplayName = "DisplayName", ApprovedBy = "System", ApprovedTime = DateTime.Now, Description = "Desc", Icon = "default.jpg" };
|
var usr = new User { UserName = "UnitTest_Change", Password = "1", DisplayName = "DisplayName", ApprovedBy = "System", ApprovedTime = DateTime.Now, Description = "Desc", Icon = "default.jpg" };
|
||||||
usr.Delete(usr.Retrieves().Where(u => u.UserName == usr.UserName).Select(u => u.Id));
|
usr.Delete(usr.Retrieves().Where(u => u.UserName == usr.UserName).Select(u => u.Id));
|
||||||
Assert.True(usr.Save(usr));
|
Assert.True(usr.Save(usr));
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ namespace Bootstrap.Admin.Api
|
||||||
// Login as new user
|
// Login as new user
|
||||||
var client = Host.CreateClient();
|
var client = Host.CreateClient();
|
||||||
client.BaseAddress = new Uri("http://localhost/api/Users");
|
client.BaseAddress = new Uri("http://localhost/api/Users");
|
||||||
await client.LoginAsync("UnitTest-Change", "1");
|
await client.LoginAsync("UnitTest_Change", "1");
|
||||||
resp = await client.PutAsJsonAsync<User, bool>(usr);
|
resp = await client.PutAsJsonAsync<User, bool>(usr);
|
||||||
Assert.True(resp);
|
Assert.True(resp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue