コード例 #1
0
        public async Task Roles_Should_Have_Configured_Permissions()
        {
            //admin
            var grantInfos = await _permissionManager.GetAllForRoleAsync("admin");

            RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission1);
            RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission2);
            RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission2_ChildPermission1);

            //moderator
            grantInfos = await _permissionManager.GetAllForRoleAsync("moderator");

            RoleShouldHavePermission(grantInfos, "moderator", TestPermissionNames.MyPermission1);
            RoleShouldHavePermission(grantInfos, "moderator", TestPermissionNames.MyPermission2);
            ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1);

            //supporter
            grantInfos = await _permissionManager.GetAllForRoleAsync("supporter");

            RoleShouldHavePermission(grantInfos, "supporter", TestPermissionNames.MyPermission1);
            ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2);
            ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1);
        }