public void DynamicWidgetsPageTemplate_DynamicWidgetOnPageTemplate()
        {
            ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(DynamicTitle, DynamicUrl);
            var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

            string testName        = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix  = testName + "DynamicPage";
            string pageTitlePrefix = testName + "Dynamic Page";
            string urlNamePrefix   = testName + "dynamic-page";
            string url             = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix);
            Guid   templateId      = default(Guid);

            try
            {
                templateId = this.templateOperation.DuplicatePageTemplate(OldTemplateName, TemplateName);

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType = TypeResolutionService.ResolveType(ResolveType);
                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                this.templateOperation.AddControlToTemplate(templateId, mvcProxy, PlaceHolder, Widget);
                Guid pageId = this.locationGenerator.CreatePage(pageNamePrefix, pageTitlePrefix, urlNamePrefix, null, null);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().SetTemplateToPage(pageId, templateId);

                string responseContent = PageInvoker.ExecuteWebRequest(url);

                Assert.IsTrue(responseContent.Contains(DynamicTitle), "The dynamic item with this title was not found!");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId);
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
            }
        }
        public void AddDynamicWidgetToPage(Guid pageId, string type, string widgetName, string widgetCaption, string placeholder = "Body")
        {
            using (var mvcProxy = new MvcWidgetProxy())
            {
                PageManager pageManager = PageManager.GetManager();
                pageManager.Provider.SuppressSecurityChecks = true;
                var pageDataId = pageManager.GetPageNode(pageId).PageId;
                var page       = pageManager.EditPage(pageDataId, CultureInfo.CurrentUICulture);

                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType = TypeResolutionService.ResolveType(type);
                if (ServerOperations.MultiSite().CheckIsMultisiteMode())
                {
                    dynamicController.Model.ProviderName = "dynamicContentProvider";
                }

                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = widgetName;

                this.CreateControl(pageManager, page, mvcProxy, widgetCaption, placeholder);
            }
        }
        public void DynamicWidgetsDesignerContent_VerifySelectedItemsFunctionality()
        {
            var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

            try
            {
                for (int i = 0; i < this.dynamicTitles.Length; i++)
                {
                    ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]);
                }

                dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType   = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.SelectionMode = SelectionMode.SelectedItems;
                dynamicController.Model.SerializedSelectedItemsIds = "[\"" + dynamicCollection[3].Id.ToString() + "\"]";
                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: null, page: 1);
                var dynamicItems = modelItems.Items.ToList();
                int itemsCount   = dynamicItems.Count;

                Assert.AreEqual(1, itemsCount, "The count of the dynamic item is not as expected");

                string title = dynamicItems[0].Fields.Title;
                Assert.IsTrue(title.Equals(this.dynamicTitles[1]), "The dynamic item with this title was not found!");
            }
            finally
            {
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Taxonomies().DeleteTags(this.tagTitle);
            }
        }
예제 #4
0
        private MvcWidgetProxy CreateMvcWidget(string resolveType, string widgetName, ParentFilterMode parentFilter = ParentFilterMode.All, string parentType = null, string[] parentIds = null)
        {
            var mvcProxy = new MvcWidgetProxy();

            mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
            var dynamicController = new DynamicContentController();

            dynamicController.Model.ContentType             = TypeResolutionService.ResolveType(resolveType);
            dynamicController.Model.ParentFilterMode        = parentFilter;
            dynamicController.Model.CurrentlyOpenParentType = parentType;
            dynamicController.Model.ProviderName            = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;

            if (parentIds != null)
            {
                StringBuilder sb = new StringBuilder();

                foreach (var id in parentIds)
                {
                    sb.Append("\"");
                    sb.Append(id);
                    sb.Append("\"");

                    if (Array.IndexOf(parentIds, id) < parentIds.Length - 1)
                    {
                        sb.Append(",");
                    }
                }

                dynamicController.Model.SerializedSelectedParentsIds = "[" + sb.ToString() + "]";
            }

            mvcProxy.Settings   = new ControllerSettings(dynamicController);
            mvcProxy.WidgetName = widgetName;

            return(mvcProxy);
        }
        public void DynamicWidgetsDesignerListSettings_VerifyUsePagingFunctionality()
        {
            var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

            this.pageOperations = new PagesOperations();
            string testName        = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix  = testName + "DynamicPage";
            string pageTitlePrefix = testName + "Dynamic Page";
            string urlNamePrefix   = testName + "dynamic-page";
            int    index           = 1;
            int    itemsPerPage    = 1;
            string index2          = "/2";
            string index3          = "/3";
            string url1            = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index);
            string url2            = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index + index2);
            string url3            = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index + index3);

            try
            {
                for (int i = 0; i < this.dynamicTitles.Length; i++)
                {
                    ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]);
                }

                dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType  = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.DisplayMode  = ListDisplayMode.Paging;
                dynamicController.Model.ItemsPerPage = itemsPerPage;
                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index);

                string responseContent1 = PageInvoker.ExecuteWebRequest(url1);
                string responseContent2 = PageInvoker.ExecuteWebRequest(url2);
                string responseContent3 = PageInvoker.ExecuteWebRequest(url3);

                for (int i = 0; i < this.dynamicTitles.Length; i++)
                {
                    switch (i)
                    {
                    case 0:
                        Assert.IsTrue(responseContent3.Contains(this.dynamicTitles[i]), "The dynamic item with this title was not found!");
                        Assert.IsFalse(responseContent3.Contains(this.dynamicTitles[i + 1]), "The dynamic item with this title was found!");
                        Assert.IsFalse(responseContent3.Contains(this.dynamicTitles[i + 2]), "The dynamic item with this title was found!");
                        break;

                    case 1:
                        Assert.IsTrue(responseContent2.Contains(this.dynamicTitles[i]), "The dynamic item with this title was not found!");
                        Assert.IsFalse(responseContent2.Contains(this.dynamicTitles[i + 1]), "The dynamic item with this title was found!");
                        Assert.IsFalse(responseContent2.Contains(this.dynamicTitles[i - 1]), "The dynamic item with this title was found!");
                        break;

                    case 2:
                        Assert.IsTrue(responseContent1.Contains(this.dynamicTitles[i]), "The dynamic item with this title was not found!");
                        Assert.IsFalse(responseContent1.Contains(this.dynamicTitles[i - 1]), "The dynamic item with this title was found!");
                        Assert.IsFalse(responseContent1.Contains(this.dynamicTitles[i - 2]), "The dynamic item with this title was found!");
                        break;
                    }
                }
            }
            finally
            {
                this.pageOperations.DeletePages();
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
            }
        }
        public void DynamicWidgetsDesignerSingleItemSettingsTests_DeleteSelectedDetailTemplate()
        {
            string detailTemplate = "PressArticleNew";
            string paragraphText  = "Detail template";

            this.pageOperations = new PagesOperations();
            string testName        = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix  = testName + "DynamicPage";
            string pageTitlePrefix = testName + "Dynamic Page";
            string urlNamePrefix   = testName + "dynamic-page";
            int    index           = 1;
            string url             = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index);

            string fileDeatil = null;
            string fileList   = null;

            var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

            try
            {
                fileDeatil = this.CopyFile(DynamicFileName, DynamicFileFileResource);
                fileList   = this.CopyFile(DynamicFileListName, DynamicFileListFileResource);

                for (int i = 0; i < this.dynamicTitles.Length; i++)
                {
                    ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]);
                }

                dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType  = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.ProviderName = ((Telerik.Sitefinity.Data.DataProviderBase)dynamicCollection.First().Provider).Name;
                dynamicController.ListTemplateName   = detailTemplate;
                dynamicController.DetailTemplateName = detailTemplate;
                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index);

                File.Delete(fileDeatil);

                string detailNewsUrl   = url + dynamicCollection[0].ItemDefaultUrl;
                string responseContent = PageInvoker.ExecuteWebRequest(detailNewsUrl);

                Assert.IsFalse(responseContent.Contains(paragraphText), "The paragraph text was found!");

                Assert.IsTrue(responseContent.Contains(this.dynamicTitles[0]), "The dynamic item with this title was not found!");
                Assert.IsFalse(responseContent.Contains(this.dynamicTitles[1]), "The dynamic item with this title was found!");
                Assert.IsFalse(responseContent.Contains(this.dynamicTitles[2]), "The dynamic item with this title was found!");
            }
            finally
            {
                File.Delete(fileList);
                Directory.Delete(this.folderPath);
                this.pageOperations.DeletePages();
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
            }
        }
예제 #7
0
        public void DynamicWidgetsAllTypes_VerifyAllFieldsOnTheFrontendWhereSomeFieldsAreEmpty()
        {
            this.pageOperations = new PagesOperations();
            string testName          = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix    = testName + "DynamicPage";
            string pageTitlePrefix   = testName + "Dynamic Page";
            string urlNamePrefix     = testName + "dynamic-page";
            int    index             = 1;
            string url               = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index);
            var    dynamicCollection = ServerOperationsFeather.DynamicModuleAllTypes().RetrieveCollectionOfAllFields();

            try
            {
                ServerOperationsFeather.DynamicModuleAllTypes().CreateFieldWithTitle(this.dynamicTitles, this.dynamicUrls);

                dynamicCollection = ServerOperationsFeather.DynamicModuleAllTypes().RetrieveCollectionOfAllFields();

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType   = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.SelectionMode = SelectionMode.AllItems;
                dynamicController.Model.ProviderName  = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;
                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index);

                string pageName = string.Format(CultureInfo.InvariantCulture, "{0}{1}", pageNamePrefix, index.ToString(CultureInfo.InvariantCulture));
                var    pageNode = PageManager.GetManager().GetPageNodes().Where(p => p.Name == pageName).FirstOrDefault();
                Assert.IsNotNull(pageNode, "Page is null");
                var pagePublishedTranslations = pageNode.GetPageData().PublishedTranslations;

                var dynamicModuleManager = DynamicModuleManager.GetManager(FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName);
                var dynamicItem          = dynamicModuleManager.GetDataItems(TypeResolutionService.ResolveType(ResolveType)).FirstOrDefault();
                Assert.IsNotNull(dynamicItem, "Dynamic item is null");
                var dynamicItemPublishedTranslations = dynamicItem.PublishedTranslations;

                if (dynamicItemPublishedTranslations.Count > 0)
                {
                    var    serlizer = new JavaScriptSerializer();
                    string translationsAssertMsg = string.Format("Page languages ({0}) does not match dynamic item languages ({1})", serlizer.Serialize(pagePublishedTranslations), serlizer.Serialize(dynamicItemPublishedTranslations));
                    Assert.IsTrue(dynamicItemPublishedTranslations.Any(d => pagePublishedTranslations.Contains(d)), translationsAssertMsg);
                }

                string responseContent = PageInvoker.ExecuteWebRequest(url);

                Assert.IsNotNull(url, "Url is null");
                Assert.IsNotNull(responseContent, string.Format("Request to URL: '{0}' returned null as content", url));
                string assertMessage = string.Format("The dynamic item with {0} title was not found in response!", this.dynamicTitles);
                Assert.IsTrue(responseContent.Contains(this.dynamicTitles), assertMessage);

                string detailNewsUrl         = url + dynamicCollection[0].ItemDefaultUrl;
                string detailResponseContent = PageInvoker.ExecuteWebRequest(detailNewsUrl);

                Assert.IsNotNull(detailResponseContent, string.Format("Request to URL: '{0}' returned null as content", detailNewsUrl));
                string detailAssertMessage = string.Format("The title {0} was not found in response!", this.dynamicTitles);
                Assert.IsTrue(detailResponseContent.Contains(this.dynamicTitles), detailAssertMessage);
            }
            finally
            {
                this.pageOperations.DeletePages();
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
            }
        }
예제 #8
0
        private void VerifyCorrectItemsOnPageWithCategoryFilterAndPaging(HierarchicalTaxon category0, HierarchicalTaxon category1, DynamicContentController dynamicController, string[] itemsTitles)
        {
            var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category0, page: 1);
            var dynamicItems = modelItems.Items.ToList();
            int itemsCount   = dynamicItems.Count;

            Assert.IsTrue(itemsCount.Equals(3), "Number of items is not correct");
            for (int i = 0; i <= 2; i++)
            {
                Assert.IsTrue(dynamicItems[i].Fields.Title.Equals(itemsTitles[3 - i], StringComparison.CurrentCulture), "The items with this title was found!");
            }

            modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category0, page: 2);
            dynamicItems = modelItems.Items.ToList();
            itemsCount   = dynamicItems.Count;

            Assert.IsTrue(itemsCount.Equals(1), "Number of items is not correct");
            Assert.IsTrue(dynamicItems[0].Fields.Title.Equals(itemsTitles[0], StringComparison.CurrentCulture), "The items with this title was found!");

            modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category1, page: 1);
            dynamicItems = modelItems.Items.ToList();
            itemsCount   = dynamicItems.Count;

            Assert.IsTrue(itemsCount.Equals(3), "Number of items is not correct");
            for (int i = 0; i <= 2; i++)
            {
                Assert.IsTrue(dynamicItems[i].Fields.Title.Equals(itemsTitles[4 - i], StringComparison.CurrentCulture), "The items with this title was found!");
            }

            modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category1, page: 2);
            dynamicItems = modelItems.Items.ToList();
            itemsCount   = dynamicItems.Count;

            Assert.IsTrue(itemsCount.Equals(1), "Number of items is not correct");
            Assert.IsTrue(dynamicItems[0].Fields.Title.Equals(itemsTitles[1], StringComparison.CurrentCulture), "The items with this title was found!");
        }
예제 #9
0
        public void DynamicWidgets_SelectByCategoryFunctionalityAndLimits()
        {
            var dynamicController = new DynamicContentController();

            dynamicController.Model.ContentType  = TypeResolutionService.ResolveType(ResolveType);
            dynamicController.Model.DisplayMode  = ListDisplayMode.Limit;
            dynamicController.Model.ProviderName = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;
            int limitCount = 3;

            dynamicController.Model.LimitCount = limitCount;
            string categoryTitle = "Category";

            string[] itemsTitles = { "Boat", "Cat", "Angel", "Kitty", "Dog" };
            string[] urls        = { "AngelUrl", "BoatUrl", "CatUrl", "KittyUrl", "DogUrl" };

            try
            {
                this.serverOperationsTaxonomies.CreateCategory(categoryTitle + "0");
                this.serverOperationsTaxonomies.CreateCategory(categoryTitle + "1", categoryTitle + "0");

                TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
                var             category0       = taxonomyManager.GetTaxa <HierarchicalTaxon>().SingleOrDefault(t => t.Title == categoryTitle + "0");
                var             category1       = taxonomyManager.GetTaxa <HierarchicalTaxon>().SingleOrDefault(t => t.Title == categoryTitle + "1");

                for (int i = 0; i < itemsTitles.Count(); i++)
                {
                    if (i <= 3)
                    {
                        ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticle(itemsTitles[i], urls[i], Guid.Empty, category0.Id);
                    }
                    else
                    {
                        ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticle(itemsTitles[i], urls[i], Guid.Empty, category1.Id);
                    }
                }

                var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category0, page: 1);
                var dynamicItems = modelItems.Items.ToList();
                int itemsCount   = dynamicItems.Count;

                Assert.IsTrue(itemsCount.Equals(3), "Number of items is not correct");
                for (int i = 0; i <= 2; i++)
                {
                    Assert.IsTrue(dynamicItems[i].Fields.Title.Equals(itemsTitles[3 - i], StringComparison.CurrentCulture), "The items with this title was found!");
                }

                modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category1, page: 1);
                dynamicItems = modelItems.Items.ToList();
                itemsCount   = dynamicItems.Count;

                Assert.IsTrue(itemsCount.Equals(1), "Number of items is not correct");
                Assert.IsTrue(dynamicItems[0].Fields.Title.Equals(itemsTitles[4], StringComparison.CurrentCulture), "The items with this title was found!");

                dynamicController.Model.DisplayMode = ListDisplayMode.All;

                modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category0, page: 1);
                dynamicItems = modelItems.Items.ToList();
                itemsCount   = dynamicItems.Count;

                Assert.IsTrue(itemsCount.Equals(4), "Number of items is not correct");
                for (int i = 0; i <= 3; i++)
                {
                    Assert.IsTrue(dynamicItems[i].Fields.Title.Equals(itemsTitles[3 - i], StringComparison.CurrentCulture), "The items with this title was found!");
                }

                modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: category1, page: 1);
                dynamicItems = modelItems.Items.ToList();
                itemsCount   = dynamicItems.Count;

                Assert.IsTrue(itemsCount.Equals(1), "Number of items is not correct");
                Assert.IsTrue(dynamicItems[0].Fields.Title.Equals(itemsTitles[4], StringComparison.CurrentCulture), "The items with this title was found!");
            }
            finally
            {
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles());
                this.serverOperationsTaxonomies.DeleteCategories("Category0", "Category1");
            }
        }
예제 #10
0
        public void DynamicWidgets_VerifySelectedItemsFunctionalityWithSortDescending()
        {
            string sortExpession = "Title DESC";

            string[] selectedDynamicTitles = { "Title2", "Title7", "Title5" };
            string[] expectedDynamicTitles = { "Title7", "Title5", "Title2" };

            try
            {
                for (int i = 0; i < 10; i++)
                {
                    ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem("Title" + i, "Title" + i + "Url");
                }

                var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType    = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.SelectionMode  = SelectionMode.SelectedItems;
                dynamicController.Model.SortExpression = sortExpession;
                dynamicController.Model.ProviderName   = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;

                var selectedDynamicItems = new DynamicContent[3];

                for (int i = 0; i < selectedDynamicTitles.Count(); i++)
                {
                    selectedDynamicItems[i] = dynamicCollection.FirstOrDefault <DynamicContent>(n => n.UrlName == (selectedDynamicTitles[i] + "Url"));
                }

                //// SerializedSelectedItemsIds string should appear in the following format: "[\"ca782d6b-9e3d-6f9e-ae78-ff00006062c4\",\"66782d6b-9e3d-6f9e-ae78-ff00006062c4\"]"
                dynamicController.Model.SerializedSelectedItemsIds =
                    "[\"" + selectedDynamicItems[0].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[1].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[2].Id.ToString() + "\"]";

                var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: null, page: 1);
                var dynamicItems = modelItems.Items.ToList();
                int itemsCount   = dynamicItems.Count;

                for (int i = 0; i < itemsCount; i++)
                {
                    Assert.IsTrue(dynamicItems[i].Fields.Title.Equals(expectedDynamicTitles[i]), "The item with this title was not found!");
                }

                dynamicController.Model.SelectionMode = SelectionMode.AllItems;

                modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: null, page: 1);
                dynamicItems = modelItems.Items.ToList();

                int lastIndex = 9;
                for (int i = 0; i < 10; i++)
                {
                    Assert.IsTrue(dynamicItems[i].Fields.Title.Equals(this.dynamicTitle + lastIndex), "The item with this title was not found!");
                    lastIndex--;
                }
            }
            finally
            {
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles());
            }
        }
예제 #11
0
        public void DynamicWidgets_SelectByTagAndSortFunctionality()
        {
            int tagsCount = 3;

            Guid[] taxonId       = new Guid[tagsCount];
            string sortExpession = "Title ASC";

            string[] itemsTitles  = { "Boat", "Cat", "Angel", "Kitty", "Dog" };
            string[] urls         = { "AngelUrl", "BoatUrl", "CatUrl", "KittyUrl", "DogUrl" };
            string[] sortedTitles = { "Angel", "Boat", "Cat" };

            var dynamicController = new DynamicContentController();

            dynamicController.Model.ContentType    = TypeResolutionService.ResolveType(ResolveType);
            dynamicController.Model.SortExpression = sortExpession;
            dynamicController.Model.ProviderName   = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;

            try
            {
                for (int i = 0; i < tagsCount; i++)
                {
                    taxonId[i] = this.serverOperationsTaxonomies.CreateFlatTaxon(Telerik.Sitefinity.TestUtilities.CommonOperations.TaxonomiesConstants.TagsTaxonomyId, this.tagTitles[i]);
                }

                for (int i = 0; i < itemsTitles.Count(); i++)
                {
                    if (i <= 2)
                    {
                        ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticle(itemsTitles[i], urls[i], taxonId[0], Guid.Empty);
                    }
                    else
                    {
                        ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticle(itemsTitles[i], urls[i], taxonId[i - 2], Guid.Empty);
                    }
                }

                TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();

                for (int i = 0; i < tagsCount; i++)
                {
                    var tag          = taxonomyManager.GetTaxa <FlatTaxon>().Where(t => t.Id == taxonId[i]).FirstOrDefault();
                    var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: tag, page: 1);
                    var dynamicItems = modelItems.Items.ToList();
                    int itemsCount   = dynamicItems.Count;

                    if (i == 0)
                    {
                        for (int j = 0; j < itemsCount; j++)
                        {
                            Assert.IsTrue(dynamicItems[j].Fields.Title.Equals(sortedTitles[j], StringComparison.CurrentCulture), "The item with this title was not found!");
                        }
                    }
                    else
                    {
                        for (int j = 0; j < itemsCount; j++)
                        {
                            Assert.IsTrue(dynamicItems[j].Fields.Title.Equals(itemsTitles[i + 2], StringComparison.CurrentCulture), "The item with this title was not found!");
                        }
                    }
                }
            }
            finally
            {
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles());
                this.serverOperationsTaxonomies.DeleteTags(this.tagTitles);
            }
        }
예제 #12
0
        public void DynamicWidgets_VerifySelectedItemsFunctionalityWithNoLimit()
        {
            this.pageOperations = new PagesOperations();
            string testName        = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix  = testName + "DynamicPage";
            string pageTitlePrefix = testName + "Dynamic Page";
            string urlNamePrefix   = testName + "dynamic-page";
            int    index           = 1;
            string url             = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index);

            string[] itemsNames = new string[25];

            try
            {
                for (int i = 0; i < 25; i++)
                {
                    ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem("Title" + i, "Title" + i + "Url");
                    itemsNames[i] = "Title" + i;
                }

                var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType   = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.SelectionMode = SelectionMode.SelectedItems;
                dynamicController.Model.DisplayMode   = ListDisplayMode.All;
                dynamicController.Model.ItemsPerPage  = 5;
                dynamicController.Model.LimitCount    = 5;
                dynamicController.Model.ProviderName  = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                mvcProxy.Settings       = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName     = WidgetName;

                string[] selectedDynamicTitles = { "Title7", "Title15", "Title11", "Title3", "Title5", "Title8", "Title2", "Title16", "Title6" };
                var      selectedDynamicItems  = new DynamicContent[9];

                for (int i = 0; i < selectedDynamicTitles.Count(); i++)
                {
                    selectedDynamicItems[i] = dynamicCollection.FirstOrDefault <DynamicContent>(n => n.UrlName == (selectedDynamicTitles[i] + "Url"));
                }

                //// SerializedSelectedItemsIds string should appear in the following format: "[\"ca782d6b-9e3d-6f9e-ae78-ff00006062c4\",\"66782d6b-9e3d-6f9e-ae78-ff00006062c4\"]"
                dynamicController.Model.SerializedSelectedItemsIds =
                    "[\"" + selectedDynamicItems[0].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[1].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[2].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[3].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[4].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[5].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[6].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[7].Id.ToString() + "\"," +
                    "\"" + selectedDynamicItems[8].Id.ToString() + "\"]";

                this.VerifyCorrectItemsOnPageWithNoLimitsOption(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index, url, selectedDynamicTitles);

                dynamicController.Model.SelectionMode = SelectionMode.AllItems;

                this.VerifyCorrectItemsOnPageWithNoLimitsOption(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index, url, itemsNames);
            }
            finally
            {
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles());
            }
        }
        public void DynamicWidgetsDesignerContent_VerifyDynamicItemsByPublicationDateCustomRangeFunctionality()
        {
            var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

            try
            {
                DateTime publicationDate = new DateTime(2014, 10, 23, 12, 00, 00);

                for (int i = 0; i < this.dynamicTitles.Length; i++)
                {
                    ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]);
                }

                dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();
                ServerOperationsFeather.DynamicModulePressArticle().PublishPressArticleWithSpecificDate(dynamicCollection[4], publicationDate);

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType   = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.SelectionMode = SelectionMode.FilteredItems;
                dynamicController.Model.ProviderName  = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;
                dynamicController.Model.SerializedAdditionalFilters = @"{
            ""QueryItems"":[
	            {
		            ""IsGroup"":true,
		            ""Ordinal"":0,
		            ""Join"":""AND"",
		            ""ItemPath"":""_0"",
		            ""Value"":null,
		            ""Condition"":null,
		            ""Name"":""PublicationDate""
	            },
	            {
		            ""IsGroup"":false,
		            ""Ordinal"":0,
		            ""Join"":""AND"",
		            ""ItemPath"":""_0_0"",
		            ""Value"":""Wed, 22 Oct 2014 21:00:00 GMT"",
		            ""Condition"":
			            {
				            ""FieldName"":""PublicationDate"",
				            ""FieldType"":""System.DateTime"",
				            ""Operator"":"">""
			            },
		            ""Name"":""PublicationDate.Wed, 22 Oct 2014 21:00:00 GMT""
	            },
	            {
		            ""IsGroup"":false,
		            ""Ordinal"":1,
		            ""Join"":""AND"",
		            ""ItemPath"":""_0_1"",
		            ""Value"":""Fri, 24 Oct 2014 21:00:00 GMT"",
		            ""Condition"":
			            {
				            ""FieldName"":""PublicationDate"",
				            ""FieldType"":""System.DateTime"",
				            ""Operator"":""<""
			            },
		            ""Name"":""PublicationDate.Fri, 24 Oct 2014 21:00:00 GMT""
	            }"    ;

                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: null, page: 1);
                var dynamicItems = modelItems.Items.ToList();
                int itemsCount   = dynamicItems.Count;

                Assert.AreEqual(1, itemsCount, "The count of the dynamic item is not as expected");

                string title1 = dynamicItems[0].Fields.Title;
                Assert.IsTrue(title1.Equals(this.dynamicTitles[2]), "The dynamic item with this title was not found!");

                for (int i = 0; i < itemsCount; i++)
                {
                    string titleNotExist = dynamicItems[i].Fields.Title;
                    Assert.IsFalse(titleNotExist.Equals(this.dynamicTitles[0]), "The dynamic item with this title was found!");
                    Assert.IsFalse(titleNotExist.Equals(this.dynamicTitles[1]), "The dynamic item with this title was found!");
                }
            }
            finally
            {
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Taxonomies().DeleteTags(this.tagTitle);
            }
        }
예제 #14
0
        public void DynamicWidgetsDesignerContent_VerifyDynamicItemsByPublicationDateLastOneDayFunctionality()
        {
            var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();

            try
            {
                DateTime earlierPublicationDate    = DateTime.UtcNow.AddDays(-10);
                string   earlierPublishedItemTitle = this.dynamicTitles[0];
                Guid     earlierPublishedItemId    = Guid.Empty;
                for (int i = 0; i < this.dynamicTitles.Length; i++)
                {
                    if (i == 0)
                    {
                        earlierPublishedItemId = ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]).Id;
                    }
                    else
                    {
                        ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]);
                    }
                }

                var earlierPublishedItem = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles().First(i => i.Id == earlierPublishedItemId && i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master);
                ServerOperationsFeather.DynamicModulePressArticle().PublishPressArticleWithSpecificDate(earlierPublishedItem, earlierPublicationDate);

                var mvcProxy = new MvcWidgetProxy();
                mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
                var dynamicController = new DynamicContentController();
                dynamicController.Model.ContentType   = TypeResolutionService.ResolveType(ResolveType);
                dynamicController.Model.SelectionMode = SelectionMode.FilteredItems;
                dynamicController.Model.ProviderName  = FeatherWidgets.TestUtilities.CommonOperations.DynamicModulesOperations.ProviderName;
                dynamicController.Model.SerializedAdditionalFilters = @"{
				""QueryItems"": [
					{
						""IsGroup"":true,
						""Ordinal"":0,
						""Join"":""AND"",
						""ItemPath"":""_0"",
						""Value"":null,
						""Condition"":null,
						""Name"":""PublicationDate""
					},
					{
						""IsGroup"":false,
						""Ordinal"":0,
						""Join"":""AND"",
						""ItemPath"":""_0_0"",
						""Value"":""DateTime.UtcNow.AddDays(-1.0)"",
						""Condition"": {
							""FieldName"":""PublicationDate"",
							""FieldType"":""System.DateTime"",
							""Operator"":"">""
						},
						""Name"":""PublicationDate.DateTime.UtcNow.AddDays(-1.0)""
					}
				]
			}"            ;
                mvcProxy.Settings   = new ControllerSettings(dynamicController);
                mvcProxy.WidgetName = WidgetName;

                var modelItems   = dynamicController.Model.CreateListViewModel(taxonFilter: null, page: 1);
                var dynamicItems = modelItems.Items.ToList();
                int itemsCount   = dynamicItems.Count;

                Assert.AreEqual(2, itemsCount, "The count of the dynamic item is not as expected");

                string title1 = dynamicItems[0].Fields.Title;
                Assert.IsTrue(this.dynamicTitles.Contains(title1), "The dynamic item with this title was not found!");
                Assert.IsFalse(title1.Equals(earlierPublishedItemTitle), "The dynamic item with this title was found!");

                string title2 = dynamicItems[1].Fields.Title;
                Assert.IsTrue(this.dynamicTitles.Contains(title2), "The dynamic item with this title was not found!");
                Assert.IsFalse(title2.Equals(earlierPublishedItemTitle), "The dynamic item with this title was found!");
            }
            finally
            {
                dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles();
                ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Taxonomies().DeleteTags(this.tagTitle);
            }
        }