コード例 #1
0
ファイル: NodesApiTests.cs プロジェクト: Szelzz/BetterCMS
        protected override SaveNodeModel GetCreateModel(ISession session)
        {
            var languageA = TestDataProvider.CreateNewLanguage();
            var languageB = TestDataProvider.CreateNewLanguage();

            session.SaveOrUpdate(languageA);
            session.SaveOrUpdate(languageB);
            session.Flush();
            session.Clear();

            return(new SaveNodeModel
            {
                Name = TestDataProvider.ProvideRandomString(MaxLength.Name),
                DisplayOrder = 1,
                Macro = TestDataProvider.ProvideRandomString(MaxLength.Text),
                ParentId = null
            });
        }
コード例 #2
0
        protected override SaveNodeModel GetCreateModel(ISession session)
        {
            var languageA = TestDataProvider.CreateNewLanguage();
            var languageB = TestDataProvider.CreateNewLanguage();

            session.SaveOrUpdate(languageA);
            session.SaveOrUpdate(languageB);
            session.Flush();
            session.Clear();

            return(new SaveNodeModel
            {
                Title = TestDataProvider.ProvideRandomString(MaxLength.Name),
                Url = TestDataProvider.ProvideRandomString(MaxLength.Url),
                PageId = null,
                DisplayOrder = 1,
                Macro = TestDataProvider.ProvideRandomString(MaxLength.Text),
                Translations = new[]
                {
                    new SaveNodeTranslation
                    {
                        LanguageId = languageA.Id,
                        Title = TestDataProvider.ProvideRandomString(MaxLength.Name),
                        Macro = TestDataProvider.ProvideRandomString(MaxLength.Name),
                        Url = TestDataProvider.ProvideRandomString(MaxLength.Url),
                        UsePageTitleAsNodeTitle = TestDataProvider.ProvideRandomBooleanValue()
                    },
                    new SaveNodeTranslation
                    {
                        LanguageId = languageB.Id,
                        Title = TestDataProvider.ProvideRandomString(MaxLength.Name),
                        Macro = TestDataProvider.ProvideRandomString(MaxLength.Name),
                        Url = TestDataProvider.ProvideRandomString(MaxLength.Url),
                        UsePageTitleAsNodeTitle = TestDataProvider.ProvideRandomBooleanValue()
                    },
                },
                UsePageTitleAsNodeTitle = false,
                ParentId = null
            });
        }
コード例 #3
0
 public void Should_Insert_And_Retrieve_Language_Successfully()
 {
     RunEntityMapTestsInTransaction(TestDataProvider.CreateNewLanguage());
 }
コード例 #4
0
        protected override SaveHtmlContentWidgetModel GetCreateModel(ISession session)
        {
            var categoryTree = TestDataProvider.CreateNewCategoryTree();

            category = TestDataProvider.CreateNewCategory(categoryTree);
            categoryTree.AvailableFor = new List <CategoryTreeCategorizableItem>
            {
                new CategoryTreeCategorizableItem
                {
                    // See Migration201502101136.cs
                    CategorizableItem = session.Load <CategorizableItem>(new Guid("B2F05159-74AF-4B67-AEB9-36B9CC9EED57")),
                    CategoryTree      = categoryTree
                }
            };
            session.SaveOrUpdate(categoryTree);
            session.SaveOrUpdate(category);
            session.Flush();

            var widget = TestDataProvider.CreateNewHtmlContentWidget();

            session.SaveOrUpdate(widget);

            var content = TestDataProvider.CreateNewHtmlContentWidget();

            var language1 = TestDataProvider.CreateNewLanguage();

            session.SaveOrUpdate(language1);

            var language2 = TestDataProvider.CreateNewLanguage();

            session.SaveOrUpdate(language2);

            var assignmentId1 = Guid.NewGuid();
            var assignmentId2 = Guid.NewGuid();

            content.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(content);
            session.Flush();
            return(new SaveHtmlContentWidgetModel
            {
                Name = TestDataProvider.ProvideRandomString(MaxLength.Name),
                IsPublished = true,
                PublishedOn = content.PublishedOn,
                PublishedByUser = content.PublishedByUser,
                Categories = new List <Guid>()
                {
                    category.Id
                },
                CustomCss = content.CustomCss,
                UseCustomCss = true,
                Html = content.Html,
                UseHtml = true,
                CustomJavaScript = content.CustomJs,
                UseCustomJavaScript = true,
                Options = new List <OptionModel>
                {
                    new OptionModel
                    {
                        DefaultValue = "1",
                        Key = "K1",
                        Type = OptionType.Text,
                        Translations = new List <OptionTranslationModel>
                        {
                            new OptionTranslationModel
                            {
                                LanguageId = language1.Id.ToString(),
                                Value = "translated_lang1"
                            },
                            new OptionTranslationModel
                            {
                                LanguageId = language2.Id.ToString(),
                                Value = "translated_lang2"
                            }
                        }
                    },

                    new OptionModel
                    {
                        DefaultValue = Guid.NewGuid().ToString(),
                        Key = "K2",
                        Type = OptionType.Custom,
                        CustomTypeIdentifier = MediaManagerFolderOptionProvider.Identifier
                    }
                },
                ChildContentsOptionValues = new List <MultilingualChildContentOptionValuesModel>
                {
                    new MultilingualChildContentOptionValuesModel
                    {
                        AssignmentIdentifier = assignmentId1,
                        MultilingualOptionValues = new List <MultilingualOptionValueModel>
                        {
                            new MultilingualOptionValueModel
                            {
                                Key = "O1",
                                Value = "V1",
                                UseDefaultValue = false,
                                Type = OptionType.Text,
                                Translations = new List <OptionTranslationModel>
                                {
                                    new OptionTranslationModel
                                    {
                                        LanguageId = language1.Id.ToString(),
                                        Value = "V1_translated_lang1"
                                    },
                                    new OptionTranslationModel
                                    {
                                        LanguageId = language2.Id.ToString(),
                                        Value = "V1_translated_lang2"
                                    }
                                }
                            }
                        }
                    },
                    new MultilingualChildContentOptionValuesModel
                    {
                        AssignmentIdentifier = assignmentId2,
                        MultilingualOptionValues = new List <MultilingualOptionValueModel>
                        {
                            new MultilingualOptionValueModel
                            {
                                Key = "O2",
                                Value = Guid.NewGuid().ToString(),
                                UseDefaultValue = false,
                                Type = OptionType.Custom,
                                CustomTypeIdentifier = "media-images-folder"
                            },
                            new MultilingualOptionValueModel
                            {
                                Key = "O3",
                                Value = Guid.NewGuid().ToString(),
                                UseDefaultValue = true,
                                Type = OptionType.Text
                            }
                        }
                    }
                }
            });
        }
コード例 #5
0
        protected override SaveServerControlWidgetModel GetCreateModel(ISession session)
        {
            var categoryTree = TestDataProvider.CreateNewCategoryTree();
            var category     = TestDataProvider.CreateNewCategory(categoryTree);

            categoryTree.AvailableFor = new List <CategoryTreeCategorizableItem>
            {
                new CategoryTreeCategorizableItem
                {
                    // See Migration201502101136.cs
                    CategorizableItem = session.Load <CategorizableItem>(new Guid("B2F05159-74AF-4B67-AEB9-36B9CC9EED57")),
                    CategoryTree      = categoryTree
                }
            };
            session.SaveOrUpdate(categoryTree);
            session.SaveOrUpdate(category);
            session.Flush();

            var content = TestDataProvider.CreateNewServerControlWidget();

            session.SaveOrUpdate(content);
            session.Flush();

            var language1 = TestDataProvider.CreateNewLanguage();

            session.SaveOrUpdate(language1);

            var language2 = TestDataProvider.CreateNewLanguage();

            session.SaveOrUpdate(language2);

            return(new SaveServerControlWidgetModel
            {
                Name = TestDataProvider.ProvideRandomString(MaxLength.Name),
                WidgetUrl = content.Url,
                PreviewUrl = content.PreviewUrl,
                IsPublished = true,
                PublishedOn = content.PublishedOn,
                PublishedByUser = content.PublishedByUser,
                Categories = new List <Guid> {
                    category.Id
                },
                Options = new List <OptionModel>
                {
                    new OptionModel
                    {
                        DefaultValue = "1",
                        Key = "K1",
                        Type = OptionType.Text,
                        Translations = new List <OptionTranslationModel>
                        {
                            new OptionTranslationModel
                            {
                                LanguageId = language1.Id.ToString(),
                                Value = "translated_lang1"
                            },
                            new OptionTranslationModel
                            {
                                LanguageId = language2.Id.ToString(),
                                Value = "translated_lang2"
                            }
                        }
                    },

                    new OptionModel
                    {
                        DefaultValue = Guid.NewGuid().ToString(),
                        Key = "K2",
                        Type = OptionType.Custom,
                        CustomTypeIdentifier = MediaManagerFolderOptionProvider.Identifier
                    }
                }
            });
        }