test: 增加演示模式下授权单元测试
This commit is contained in:
parent
a588cd91a3
commit
0c85313480
|
@ -39,7 +39,7 @@ namespace Bootstrap.DataAccess.SqlServer
|
|||
public void RetrieveMenusByRoleId_Ok()
|
||||
{
|
||||
var roleId = RoleHelper.Retrieves().FirstOrDefault(r => r.RoleName == "Administrators").Id;
|
||||
Assert.NotEmpty(MenuHelper.RetrieveMenusByRoleId(roleId));
|
||||
Assert.NotNull(MenuHelper.RetrieveMenusByRoleId(roleId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -115,5 +115,24 @@ namespace Bootstrap.DataAccess
|
|||
DictHelper.ConfigIPLocator(op);
|
||||
Assert.NotNull(op.Url);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SaveByUserId_Ok()
|
||||
{
|
||||
SetSystemMode();
|
||||
var roleId = RoleHelper.Retrieves().FirstOrDefault(r => r.RoleName.Equals("Administrators", System.StringComparison.OrdinalIgnoreCase)).Id;
|
||||
Assert.True(UserHelper.SaveByRoleId(roleId, new string[0]));
|
||||
// 仍然属于 Administrators
|
||||
Assert.Contains(RoleHelper.RetrievesByUserName("Admin"), r => r.Equals("Administrators"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SaveByRoleID_Ok()
|
||||
{
|
||||
SetSystemMode();
|
||||
var uId = UserHelper.Retrieves().FirstOrDefault(u => u.UserName.Equals("Admin", System.StringComparison.OrdinalIgnoreCase))?.Id;
|
||||
Assert.True(RoleHelper.SaveByUserId(uId, new string[0]));
|
||||
Assert.Contains(RoleHelper.RetrievesByUserName("Admin"), r => r.Equals("Administrators"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue