コード例 #1
0
        private IReadOnlyCollection <ClaimSetResourceClaim> SetupParentResourceClaims(IEnumerable <ClaimSet> testClaimSets, Application testApplication, int resourceClaimCount = 5)
        {
            var claimSetResourceClaims = new List <ClaimSetResourceClaim>();

            foreach (var claimSet in testClaimSets)
            {
                foreach (var index in Enumerable.Range(1, resourceClaimCount))
                {
                    var resourceClaim = new ResourceClaim
                    {
                        ClaimName    = $"TestResourceClaim{index:N}",
                        DisplayName  = $"TestResourceClaim{index:N}",
                        ResourceName = $"TestResourceClaim{index:N}",
                        Application  = testApplication
                    };
                    var action = new Action
                    {
                        ActionName = ActionName.Create.Value,
                        ActionUri  = "create"
                    };
                    var claimSetResourceClaim = new ClaimSetResourceClaim
                    {
                        ResourceClaim = resourceClaim, Action = action, ClaimSet = claimSet
                    };
                    claimSetResourceClaims.Add(claimSetResourceClaim);
                }
            }

            Save(claimSetResourceClaims.Cast <object>().ToArray());

            return(claimSetResourceClaims);
        }
コード例 #2
0
        protected IReadOnlyCollection <ResourceClaim> SetupResourceClaims(Application testApplication, int resourceClaimCount = 5, int childResourceClaimCount = 3)
        {
            var parentResourceClaims = new List <ResourceClaim>();
            var childResourceClaims  = new List <ResourceClaim>();
            var actions = new List <Action>();

            foreach (var parentIndex in Enumerable.Range(1, resourceClaimCount))
            {
                var resourceClaim = new ResourceClaim
                {
                    ClaimName    = $"TestParentResourceClaim{parentIndex}",
                    DisplayName  = $"TestParentResourceClaim{parentIndex}",
                    ResourceName = $"TestParentResourceClaim{parentIndex}",
                    Application  = testApplication
                };
                parentResourceClaims.Add(resourceClaim);

                childResourceClaims.AddRange(Enumerable.Range(1, childResourceClaimCount)
                                             .Select(childIndex => new ResourceClaim
                {
                    ClaimName             = $"TestChildResourceClaim{childIndex}",
                    DisplayName           = $"TestChildResourceClaim{childIndex}",
                    ResourceName          = $"TestChildResourceClaim{childIndex}",
                    Application           = testApplication,
                    ParentResourceClaim   = resourceClaim,
                    ParentResourceClaimId = resourceClaim.ResourceClaimId
                }));
            }

            foreach (var action in ActionName.GetAll())
            {
                var actionObject = new Action
                {
                    ActionName = action.Value,
                    ActionUri  = action.Value
                };
                actions.Add(actionObject);
            }

            Save(parentResourceClaims.Cast <object>().ToArray());
            Save(childResourceClaims.Cast <object>().ToArray());
            Save(actions.Cast <object>().ToArray());

            return(parentResourceClaims);
        }
コード例 #3
0
        private IReadOnlyCollection <ClaimSetResourceClaim> SetupParentResourceClaimsWithChildren(IEnumerable <ClaimSet> testClaimSets, Application testApplication, int resourceClaimCount = 5, int childResourceClaimCount = 3)
        {
            var parentResourceClaims = new List <ResourceClaim>();
            var childResourceClaims  = new List <ResourceClaim>();

            foreach (var parentIndex in Enumerable.Range(1, resourceClaimCount))
            {
                var resourceClaim = new ResourceClaim
                {
                    ClaimName    = $"TestParentResourceClaim{parentIndex:N}",
                    DisplayName  = $"TestParentResourceClaim{parentIndex:N}",
                    ResourceName = $"TestParentResourceClaim{parentIndex:N}",
                    Application  = testApplication
                };
                parentResourceClaims.Add(resourceClaim);

                childResourceClaims.AddRange(Enumerable.Range(1, childResourceClaimCount)
                                             .Select(childIndex => new ResourceClaim
                {
                    ClaimName             = $"TestChildResourceClaim{childIndex:N}",
                    DisplayName           = $"TestChildResourceClaim{childIndex:N}",
                    ResourceName          = $"TestChildResourceClaim{childIndex:N}",
                    Application           = testApplication,
                    ParentResourceClaim   = resourceClaim,
                    ParentResourceClaimId = resourceClaim.ResourceClaimId
                }));
            }

            Save(parentResourceClaims.Cast <object>().ToArray());
            Save(childResourceClaims.Cast <object>().ToArray());

            var claimSetResourceClaims = new List <ClaimSetResourceClaim>();
            var claimSets = testClaimSets.ToList();

            foreach (var claimSet in claimSets)
            {
                foreach (var index in Enumerable.Range(1, childResourceClaimCount))
                {
                    var action = new Action
                    {
                        ActionName = ActionName.Create.Value,
                        ActionUri  = "create"
                    };
                    var claimSetResourceClaim = new ClaimSetResourceClaim
                    {
                        ResourceClaim = childResourceClaims[index - 1],
                        Action        = action,
                        ClaimSet      = claimSet
                    };
                    claimSetResourceClaims.Add(claimSetResourceClaim);
                }
            }

            Save(claimSetResourceClaims.Cast <object>().ToArray());

            claimSetResourceClaims = new List <ClaimSetResourceClaim>();
            foreach (var claimSet in claimSets)
            {
                foreach (var index in Enumerable.Range(1, resourceClaimCount))
                {
                    var parentResource = parentResourceClaims[index - 1];
                    var action         = new Action
                    {
                        ActionName = ActionName.Create.Value,
                        ActionUri  = "create"
                    };
                    var claimSetResourceClaim = new ClaimSetResourceClaim
                    {
                        ResourceClaim = parentResource,
                        Action        = action,
                        ClaimSet      = claimSet
                    };
                    claimSetResourceClaims.Add(claimSetResourceClaim);
                    var childResources = childResourceClaims
                                         .Where(x => x.ParentResourceClaimId == parentResource.ResourceClaimId).Select(x =>
                                                                                                                       new ClaimSetResourceClaim
                    {
                        ResourceClaim = x,
                        Action        = action,
                        ClaimSet      = claimSet
                    }).ToArray();
                    claimSetResourceClaims.AddRange(childResources);
                }
            }

            Save(claimSetResourceClaims.Cast <object>().ToArray());

            return(claimSetResourceClaims);
        }