test: 增加演示模式下授权单元测试

This commit is contained in:
Argo Zhang 2019-09-12 18:30:21 +08:00
parent a588cd91a3
commit 0c85313480
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
2 changed files with 20 additions and 1 deletions

View File

@ -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]

View File

@ -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"));
}
}
}