Пример #1
0
        public void Should_Insert_And_Retrieve_BlogPost_Successfully()
        {
            var entity = TestDataProvider.CreateNewBlogPost();

            RunEntityMapTestsInTransaction(entity);
        }
Пример #2
0
        protected override SaveBlogPostPropertiesModel GetCreateModel(ISession session)
        {
            var blogPost = TestDataProvider.CreateNewBlogPost();

            var widget = TestDataProvider.CreateNewHtmlContentWidget();

            session.SaveOrUpdate(widget);

            var assignmentId1 = Guid.NewGuid();
            var assignmentId2 = Guid.NewGuid();
            var html          = string.Format("{0}{1}{3}{2}",
                                              TestDataProvider.ProvideRandomString(50),
                                              TestDataProvider.CreateChildWidgetAssignment(widget.Id, assignmentId1),
                                              TestDataProvider.ProvideRandomString(50),
                                              TestDataProvider.CreateChildWidgetAssignment(widget.Id, assignmentId2));

            session.SaveOrUpdate(blogPost.Category);
            session.SaveOrUpdate(blogPost.Author);
            session.SaveOrUpdate(blogPost.Image);
            session.SaveOrUpdate(blogPost.FeaturedImage);
            session.SaveOrUpdate(blogPost.SecondaryImage);
            session.SaveOrUpdate(blogPost.Language);

            session.Flush();
            session.Clear();

            var model = new SaveBlogPostPropertiesModel
            {
                BlogPostUrl      = string.Format("/{0}/", TestDataProvider.ProvideRandomString(200)),
                Title            = blogPost.Title,
                IntroText        = blogPost.Description,
                IsPublished      = true,
                PublishedOn      = blogPost.PublishedOn,
                LayoutId         = layout != null ? layout.Id : (defaultLayout != null ? defaultLayout.Id : (Guid?)null),
                MasterPageId     = masterPage != null ? masterPage.Id : (Guid?)null,
                CategoryId       = blogPost.Category.Id,
                AuthorId         = blogPost.Author.Id,
                MainImageId      = blogPost.Image.Id,
                FeaturedImageId  = blogPost.FeaturedImage.Id,
                SecondaryImageId = blogPost.SecondaryImage.Id,
                ActivationDate   = blogPost.ActivationDate,
                ExpirationDate   = blogPost.ExpirationDate,
                IsArchived       = true,
                UseCanonicalUrl  = true,
                UseNoFollow      = true,
                UseNoIndex       = true,
                HtmlContent      = html,
                Tags             = new List <string> {
                    TestDataProvider.ProvideRandomString(20), TestDataProvider.ProvideRandomString(20)
                },
                Language = new LanguageModel
                {
                    LanguageGroupIdentifier = Guid.NewGuid(),
                    Id   = blogPost.Language.Id,
                    Code = blogPost.Language.Code,
                    Name = blogPost.Language.Name
                },
                MetaData = new MetadataModel
                {
                    MetaDescription = blogPost.MetaDescription,
                    MetaKeywords    = blogPost.MetaKeywords,
                    MetaTitle       = blogPost.MetaTitle
                },
                AccessRules = new List <AccessRuleModel>
                {
                    new AccessRuleModel {
                        AccessLevel = AccessLevel.ReadWrite,
                        Identity    = TestDataProvider.ProvideRandomString(20),
                        IsForRole   = false
                    },
                    new AccessRuleModel {
                        AccessLevel = AccessLevel.Deny,
                        Identity    = TestDataProvider.ProvideRandomString(20),
                        IsForRole   = true
                    }
                },
                TechnicalInfo = new TechnicalInfoModel
                {
                    BlogPostContentId = Guid.NewGuid(),
                    PageContentId     = Guid.NewGuid(),
                    RegionId          = region.Id
                },
                ChildContentsOptionValues = new List <ChildContentOptionValuesModel>
                {
                    new ChildContentOptionValuesModel
                    {
                        AssignmentIdentifier = assignmentId1,
                        OptionValues         = new List <OptionValueModel>
                        {
                            new OptionValueModel
                            {
                                Key             = "O1",
                                Value           = "V1",
                                UseDefaultValue = false,
                                Type            = OptionType.Text
                            }
                        }
                    },
                    new ChildContentOptionValuesModel
                    {
                        AssignmentIdentifier = assignmentId2,
                        OptionValues         = new List <OptionValueModel>
                        {
                            new OptionValueModel
                            {
                                Key                  = "O2",
                                Value                = Guid.NewGuid().ToString(),
                                UseDefaultValue      = false,
                                Type                 = OptionType.Custom,
                                CustomTypeIdentifier = "media-images-folder"
                            },
                            new OptionValueModel
                            {
                                Key             = "O3",
                                Value           = Guid.NewGuid().ToString(),
                                UseDefaultValue = true,
                                Type            = OptionType.Text
                            }
                        }
                    }
                }
            };

            return(model);
        }