コード例 #1
0
        private void CreateTestDataForPagingTests(out List <IContent> createdContent, out List <IMember> createdMembers, out List <IMedia> createdMedia)
        {
            // Create content
            createdContent = new List <IContent>();
            ContentType contentType = ContentTypeBuilder.CreateBasicContentType("blah");

            ContentTypeService.Save(contentType);
            for (int i = 0; i < 3; i++)
            {
                Content c1 = ContentBuilder.CreateBasicContent(contentType);
                ContentService.Save(c1);
                createdContent.Add(c1);
            }

            // Create media
            createdMedia = new List <IMedia>();
            MediaType imageType = MediaTypeBuilder.CreateImageMediaType("myImage");

            MediaTypeService.Save(imageType);
            for (int i = 0; i < 3; i++)
            {
                Media c1 = MediaBuilder.CreateMediaImage(imageType, -1);
                MediaService.Save(c1);
                createdMedia.Add(c1);
            }

            // Create members
            MemberType memberType = MemberTypeBuilder.CreateSimpleMemberType("simple");

            MemberTypeService.Save(memberType);
            createdMembers = MemberBuilder.CreateSimpleMembers(memberType, 3).ToList();
            GetMemberService().Save(createdMembers);

            IRelationType relType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelatedMediaAlias);

            // Relate content to media
            foreach (IContent content in createdContent)
            {
                foreach (IMedia media in createdMedia)
                {
                    RelationService.Relate(content.Id, media.Id, relType);
                }
            }

            // Relate members to media
            foreach (IMember member in createdMembers)
            {
                foreach (IMedia media in createdMedia)
                {
                    RelationService.Relate(member.Id, media.Id, relType);
                }
            }
        }
コード例 #2
0
        private void CreateTestDataForPagingTests(out List <IContent> createdContent, out List <IMember> createdMembers, out List <IMedia> createdMedia)
        {
            // Create content
            createdContent = new List <IContent>();
            ContentType contentType = ContentTypeBuilder.CreateBasicContentType("blah");

            ContentTypeService.Save(contentType);
            for (int i = 0; i < 3; i++)
            {
                Content c1 = ContentBuilder.CreateBasicContent(contentType);
                ContentService.Save(c1);
                createdContent.Add(c1);
            }

            // Create related content
            var relatedContent = new List <IContent>();

            for (int i = 0; i < 3; i++)
            {
                Content c1 = ContentBuilder.CreateBasicContent(contentType);
                ContentService.Save(c1);
                relatedContent.Add(c1);
            }

            // Create media
            createdMedia = new List <IMedia>();
            MediaType imageType = MediaTypeBuilder.CreateImageMediaType("myImage");

            MediaTypeService.Save(imageType);
            for (int i = 0; i < 3; i++)
            {
                Media c1 = MediaBuilder.CreateMediaImage(imageType, -1);
                MediaService.Save(c1);
                createdMedia.Add(c1);
            }

            // Create members
            MemberType memberType = MemberTypeBuilder.CreateSimpleMemberType("simple");

            MemberTypeService.Save(memberType);
            createdMembers = MemberBuilder.CreateSimpleMembers(memberType, 3).ToList();
            GetMemberService().Save(createdMembers);

            IRelationType relatedMediaRelType   = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelatedMediaAlias);
            IRelationType relatedContentRelType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelatedDocumentAlias);

            // Relate content to media
            foreach (IContent content in createdContent)
            {
                foreach (IMedia media in createdMedia)
                {
                    RelationService.Relate(content.Id, media.Id, relatedMediaRelType);
                }
            }

            // Relate content to content
            foreach (IContent relContent in relatedContent)
            {
                foreach (IContent content in createdContent)
                {
                    RelationService.Relate(relContent.Id, content.Id, relatedContentRelType);
                }
            }

            // Relate members to media
            foreach (IMember member in createdMembers)
            {
                foreach (IMedia media in createdMedia)
                {
                    RelationService.Relate(member.Id, media.Id, relatedMediaRelType);
                }
            }

            // Create copied content
            var copiedContent = new List <IContent>();

            for (int i = 0; i < 3; i++)
            {
                Content c1 = ContentBuilder.CreateBasicContent(contentType);
                ContentService.Save(c1);
                copiedContent.Add(c1);
            }

            IRelationType copiedContentRelType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelateDocumentOnCopyAlias);

            // Relate content to content (mimics copy)
            foreach (IContent content in createdContent)
            {
                foreach (IContent cpContent in copiedContent)
                {
                    RelationService.Relate(content.Id, cpContent.Id, copiedContentRelType);
                }
            }

            // Create trashed content
            var trashedContent = new List <IContent>();

            for (int i = 0; i < 3; i++)
            {
                Content c1 = ContentBuilder.CreateBasicContent(contentType);
                ContentService.Save(c1);
                trashedContent.Add(c1);
            }

            IRelationType trashedRelType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias);

            // Relate to trashed content
            foreach (IContent trContent in trashedContent)
            {
                foreach (IContent content in createdContent)
                {
                    RelationService.Relate(trContent.Id, content.Id, trashedRelType);
                }
            }

            // Create trashed media
            var trashedMedia = new List <IMedia>();

            for (int i = 0; i < 3; i++)
            {
                Media m1 = MediaBuilder.CreateMediaImage(imageType, -1);
                MediaService.Save(m1);
                trashedMedia.Add(m1);
            }

            IRelationType trashedMediaRelType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias);

            // Relate to trashed media
            foreach (IMedia trMedia in trashedMedia)
            {
                foreach (IMedia media in createdMedia)
                {
                    RelationService.Relate(trMedia.Id, media.Id, trashedMediaRelType);
                }
            }
        }