protected EntityFrameworkCore.Data.Scope CreateScope(AuthorizationsTestContext context, string scopeName, params string[] parentScopeNames) { var scope = new EntityFrameworkCore.Data.Scope { Name = scopeName, Description = scopeName, CreationBy = context.CurrentUserId, ModificationBy = context.CurrentUserId }; context.Scopes().Add(scope); foreach (var parentScopeName in parentScopeNames) { var parentScope = context.ChangeTracker .Entries <EntityFrameworkCore.Data.Scope>() .Select(e => e.Entity) .First(s => s.Name == parentScopeName); context.ScopeHierarchies().Add(new EntityFrameworkCore.Data.ScopeHierarchy { Child = scope, Parent = parentScope }); } return(scope); }
protected EntityFrameworkCore.Data.Authorization CreateAuthorization(AuthorizationsTestContext context, Guid principalId, EntityFrameworkCore.Data.Role role, EntityFrameworkCore.Data.Scope scope) { var authorization = new EntityFrameworkCore.Data.Authorization { PrincipalId = principalId, Role = role, Scope = scope, CreationBy = context.CurrentUserId, ModificationBy = context.CurrentUserId }; context.Authorizations().Add(authorization); return(authorization); }