public void ContentBlockWidget_AdvancedSettings()
        {
            string testName = "ContentBlockWidgetAdvancedSettings";
            string pageNamePrefix = testName + "ContentBlockPage";
            string pageTitlePrefix = testName + "Content Block";
            string urlNamePrefix = testName + "content-block";
            int pageIndex = 1;
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            var content = App.WorkWith().ContentItems()
                           .Published()
                           .Where(c => c.Title == ContentBlockTitle)
                           .Get().Single();

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
            var contentBlockController = new ContentBlockController();
            contentBlockController.SharedContentID = content.Id;
            mvcProxy.Settings = new ControllerSettings(contentBlockController);

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

            string responseContent = PageInvoker.ExecuteWebRequest(url);

            Assert.IsTrue(responseContent.Contains(ContentBlockContent), "The content block with this title was not found!");
        }
        public void ContentBlockWidget_EditSharedContent()
        {
            string testName = "ContentBlockWidgetEditSharedContent";
            string pageNamePrefix = testName + "ContentBlockPage";
            string pageTitlePrefix = testName + "Content Block";
            string urlNamePrefix = testName + "content-block";
            int pageIndex = 1;
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            var content = App.WorkWith().ContentItems()
                           .Where(c => c.Title == ContentBlockTitle && c.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master)
                           .Get().Single();

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
            var contentBlockController = new ContentBlockController();
            contentBlockController.SharedContentID = content.Id;
            mvcProxy.Settings = new ControllerSettings(contentBlockController);

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

            App.WorkWith().ContentItem(content.Id).CheckOut().Do(cI =>
            {
                cI.Content = ContentBlockContentEdited;
                cI.LastModified = DateTime.UtcNow;
            })
                .CheckIn().Publish().SaveChanges();

            string responseContent = PageInvoker.ExecuteWebRequest(url);
            Assert.IsTrue(responseContent.Contains(ContentBlockContentEdited), "The content block with this title was not found!");
        }
        public void ContentBlockWidget_FormatContentViaAlignTextLeftFunctionalityToContentBlock()
        {
            string pageNamePrefix = "ContentBlockPage";
            string pageTitlePrefix = "Content Block";
            string urlNamePrefix = "content-block";
            int pageIndex = 1;
            string contentBlockContent = "<div style=\"text-align:left;\">Align text left</div>";
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
            var contentBlockController = new ContentBlockController();
            contentBlockController.Content = contentBlockContent;
            mvcProxy.Settings = new ControllerSettings(contentBlockController);

            this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex);
            string responseContent = PageInvoker.ExecuteWebRequest(url);

            Assert.IsTrue(responseContent.Contains(contentBlockContent), "Content was not aligned left!");
        }
        public void ContentBlockWidget_AddTableToContentBlock()
        {
            string pageNamePrefix = "ContentBlockPage";
            string pageTitlePrefix = "Content Block";
            string urlNamePrefix = "content-block";
            int pageIndex = 1;
            string contentBlockContent = "<table><tbody><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></tbody></table>";
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
            var contentBlockController = new ContentBlockController();
            contentBlockController.Content = contentBlockContent;
            mvcProxy.Settings = new ControllerSettings(contentBlockController);

            this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex);
            string responseContent = PageInvoker.ExecuteWebRequest(url);

            Assert.IsTrue(responseContent.Contains(contentBlockContent), "Table was not found!");
        }
        public void ContentBlockWidget_SocialShareButtonsFunctionality()
        {
            string pageNamePrefix = "ContentBlockPage";
            string pageTitlePrefix = "Content Block";
            string urlNamePrefix = "content-block";
            int pageIndex = 1;
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);
            string socialShare = "list-inline sf-social-share";

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
            var contentBlockController = new ContentBlockController();
            contentBlockController.Content = ContentBlockContent;
            contentBlockController.EnableSocialSharing = true;
            mvcProxy.Settings = new ControllerSettings(contentBlockController);

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

            string responseContent = PageInvoker.ExecuteWebRequest(url);

            Assert.IsTrue(responseContent.Contains(socialShare), "Social share button was not found!");
        }
        public void ContentBlockWidget_InsertImageToContentBlock()
        {
            string pageNamePrefix = "ContentBlockPage";
            string pageTitlePrefix = "Content Block";
            string urlNamePrefix = "content-block";
            int pageIndex = 1;
            string imageTitle = "One";
            string imageExtension = ".jpg";
            string imageName = "1.jpg";
            string contentBlockContentPart1 = "<img alt=\"\" src=\"";
            string contentBlockContentPart2 = "\" />";
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            try
            {
                var imageId = Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Images().CreateImage(imageTitle, imageExtension, imageName);
                var imageUrl = Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Images().GetImageUrl(imageId);

                string contentBlockContent = string.Concat(contentBlockContentPart1, imageUrl, contentBlockContentPart2);

                var mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
                var contentBlockController = new ContentBlockController();
                contentBlockController.Content = contentBlockContent;
                mvcProxy.Settings = new ControllerSettings(contentBlockController);

                this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex);
                string responseContent = PageInvoker.ExecuteWebRequest(url);

                Assert.IsTrue(responseContent.Contains(contentBlockContent), "Image was not found!");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Images().DeleteAllImages(Telerik.Sitefinity.TestUtilities.CommonOperations.ContentLifecycleStatus.Master);
            }
        }
        public void ContentBlockWidget_InsertHyperlinkToContentBlock()
        {
            string pageNamePrefix = "ContentBlockPage";
            string pageTitlePrefix = "Content Block";
            string urlNamePrefix = "content-block";
            int pageIndex = 1;
            string contentBlockContent = "<a href=\"http://wheather.com\" title=\"wheather\">Wheather site</a>";
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(ContentBlockController).FullName;
            var contentBlockController = new ContentBlockController();
            contentBlockController.Content = contentBlockContent;
            mvcProxy.Settings = new ControllerSettings(contentBlockController);

            this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex);
            string responseContent = PageInvoker.ExecuteWebRequest(url);

            Assert.IsTrue(responseContent.Contains(contentBlockContent), "Hyperlink was not found!");
        }