Exemplo n.º 1
0
        public void UninstallFeather_GridWidgetsInToolboxPurePageTemplate_VerifyBackend()
        {
            var  moduleOperations    = FeatherServerOperations.FeatherModule();
            var  templatesOperations = ServerOperations.Templates();
            Guid templateId          = Guid.Empty;

            moduleOperations.EnsureFeatherEnabled();

            try
            {
                templateId = templatesOperations.CreatePureMVCPageTemplate(ModuleUnloadTests.PageTemplateTitle + Guid.NewGuid().ToString("N"));
                string templateUrl = UrlPath.ResolveAbsoluteUrl(ModuleUnloadTests.SitefinityTemplateRoutePrefix + templateId.ToString());

                var templateContentBeforeDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(templateUrl + this.AppendUncacheUrl());
                Assert.IsTrue(templateContentBeforeDeactivate.Contains(ModuleUnloadTests.FeatherGridToolboxItemMarkup));

                moduleOperations.DeactivateFeather();
                moduleOperations.UninstallFeather();

                var templateContentAfterDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(templateUrl + this.AppendUncacheUrl());
                Assert.IsFalse(templateContentAfterDeactivate.Contains(ModuleUnloadTests.FeatherGridToolboxItemMarkup));
            }
            finally
            {
                moduleOperations.InstallFeather();
                templatesOperations.DeletePageTemplate(templateId);
            }
        }
Exemplo n.º 2
0
        public void PassingCssFileExtensionWithParentPath_FilesService_ProperItemsAreReturned()
        {
            // Arrange
            var fileExtension = "css";

            var tempDirName = string.Format("__tempDirectoryNameUsedForTest{0}", Guid.NewGuid());
            var tempDirPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, tempDirName);

            var tempFileName = string.Format("__tempFileNameUsedForTest{0}.{1}", Guid.NewGuid(), fileExtension);
            var tempFilePath = Path.Combine(tempDirPath, tempFileName);

            var url = new Uri(UrlPath.ResolveAbsoluteUrl(FilesServiceTests.ServiceRootUrl + string.Format("?extension={0}&path={1}", fileExtension, tempDirName)));

            // Act
            try
            {
                Directory.CreateDirectory(tempDirPath);
                File.Create(tempFilePath).Close();

                var responseString = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(url.ToString());
                var filesViewModel = Json.Decode <FilesViewModel>(responseString);

                // Assert
                Assert.IsTrue(filesViewModel != null, "The response is not a FilesViewModel");
                Assert.IsTrue(string.IsNullOrEmpty(filesViewModel.Error), "There is an error in the response");
                Assert.IsTrue(filesViewModel.Items != null, "The items are null");
                Assert.AreEqual(1, filesViewModel.Items.Count(), "The items returned are not 1");
                Assert.AreEqual(tempFileName, filesViewModel.Items.FirstOrDefault().Name, "The item returned is not the real one");
            }
            finally
            {
                File.Delete(tempFilePath);
                Directory.Delete(tempDirPath);
            }
        }
Exemplo n.º 3
0
        public void UninstallFeather_GridWidgetsInToolboxPurePage_VerifyBackend()
        {
            var  moduleOperations = FeatherServerOperations.FeatherModule();
            Guid pageId           = Guid.Empty;

            moduleOperations.EnsureFeatherEnabled();

            try
            {
                string pageUrl;
                pageId = this.CreatePage(PageTemplateFramework.Mvc, out pageUrl);

                var pageContentBeforeDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(pageUrl + this.AppendEditUrl());
                Assert.IsTrue(pageContentBeforeDeactivate.Contains(ModuleUnloadTests.FeatherGridToolboxItemMarkup));

                moduleOperations.DeactivateFeather();
                moduleOperations.UninstallFeather();

                var pageContentAfterDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(pageUrl + this.AppendEditUrl());
                Assert.IsFalse(pageContentAfterDeactivate.Contains(ModuleUnloadTests.FeatherGridToolboxItemMarkup));
            }
            finally
            {
                moduleOperations.InstallFeather();
                ServerOperations.Pages().DeletePage(pageId);
            }
        }
Exemplo n.º 4
0
        public void DeactivateFeather_GridWidgetsOnHybridPage_VerifyBackend()
        {
            var  moduleOperations = FeatherServerOperations.FeatherModule();
            Guid pageId           = Guid.Empty;

            moduleOperations.EnsureFeatherEnabled();

            try
            {
                string pageUrl;
                pageId = this.CreatePage(PageTemplateFramework.Hybrid, out pageUrl);
                this.AddGridToPage(pageId, PageTemplateFramework.Hybrid);

                var pageContentBeforeDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(pageUrl + this.AppendEditUrl());
                Assert.IsFalse(pageContentBeforeDeactivate.Contains(ModuleUnloadTests.GridUnavailableMessage));

                moduleOperations.DeactivateFeather();

                var pageContentAfterDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(pageUrl + this.AppendEditUrl());
                Assert.IsTrue(pageContentAfterDeactivate.Contains(ModuleUnloadTests.GridUnavailableMessage));
            }
            finally
            {
                ServerOperations.Pages().DeletePage(pageId);
                moduleOperations.ActivateFeather();
            }
        }
Exemplo n.º 5
0
        public void PassingHtmlFileExtensionWithNoParentPath_FilesService_ProperItemsAreReturned()
        {
            // Arrange
            var fileExtension = "html";
            var url           = new Uri(UrlPath.ResolveAbsoluteUrl(FilesServiceTests.ServiceRootUrl + string.Format("?extension={0}", fileExtension)));

            var tempDirName = string.Format("__tempDirectoryNameUsedForTest{0}", Guid.NewGuid());
            var tempDirPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, tempDirName);

            var tempFileName = string.Format("__tempFileNameUsedForTest{0}.{1}", Guid.NewGuid(), fileExtension);
            var tempFilePath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, tempFileName);

            // Act
            try
            {
                Directory.CreateDirectory(tempDirPath);
                File.Create(tempFilePath).Close();

                var responseString = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(url.ToString());
                var filesViewModel = Json.Decode <FilesViewModel>(responseString);

                // Assert
                Assert.IsTrue(filesViewModel != null, "The response is not a FilesViewModel");
                Assert.IsTrue(string.IsNullOrEmpty(filesViewModel.Error), "There is an error in the response");
                Assert.IsTrue(filesViewModel.Items != null, "The items are null");
                Assert.IsTrue(filesViewModel.Items.Count() > 0, "There are no items");
                Assert.IsTrue(filesViewModel.Items.Any(i => i.Name == tempDirName && i.IsFolder), "When called with html file extension and no parent path fake directory is NOT returned");
                Assert.IsTrue(filesViewModel.Items.Any(i => i.Name == tempFileName && !i.IsFolder), "When called with html file extension and no parent path fake css file is NOT returned");
            }
            finally
            {
                File.Delete(tempFilePath);
                Directory.Delete(tempDirPath);
            }
        }
        private string GetContent(string url, bool openInEdit = false)
        {
            url += openInEdit ? "/Action/Edit?t=" + Guid.NewGuid().ToString() : "?t=" + Guid.NewGuid().ToString();

            var webResponseContent = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(url);

            return(webResponseContent);
        }
Exemplo n.º 7
0
        public void PassingNoFileExtension_FilesService_ProperErrorReturned()
        {
            // Arrange
            var url = new Uri(UrlPath.ResolveAbsoluteUrl(FilesServiceTests.ServiceRootUrl));

            // Act
            var responseString = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(url.ToString());
            var filesViewModel = Json.Decode <FilesViewModel>(responseString);

            // Assert
            Assert.IsTrue(filesViewModel != null, "The response is not a FilesViewModel");
            Assert.IsTrue(filesViewModel.Items == null, "There are items in the response");
            Assert.AreEqual(FilesWebServiceConstants.FileExtensionNullOrEmptyExceptionMessage, filesViewModel.Error, "When called with no file extension proper error is NOT returned");
        }
Exemplo n.º 8
0
        public void PassingNegativeTakeValue_FilesService_ProperErrorReturned()
        {
            // Arrange
            var take = -1;
            var url  = new Uri(UrlPath.ResolveAbsoluteUrl(FilesServiceTests.ServiceRootUrl + string.Format("?extension=css&take={0}", take)));

            // Act
            var responseString = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(url.ToString());
            var filesViewModel = Json.Decode <FilesViewModel>(responseString);

            // Assert
            Assert.IsTrue(filesViewModel != null, "The response is not a FilesViewModel");
            Assert.IsTrue(filesViewModel.Items == null, "There are items in the response");
            Assert.AreEqual(FilesWebServiceConstants.FilesTakeNegativeValueExceptionMessage, filesViewModel.Error, "When called with negative take value proper error is NOT returned");
        }
Exemplo n.º 9
0
        public void PassingNotExistingParentPath_FilesService_ProperErrorReturned()
        {
            // Arrange
            var parentPath = "unexistingParentPath/";
            var url        = new Uri(UrlPath.ResolveAbsoluteUrl(FilesServiceTests.ServiceRootUrl + string.Format("?extension=css&path={0}", parentPath)));

            // Act
            var responseString = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(url.ToString());
            var filesViewModel = Json.Decode <FilesViewModel>(responseString);

            // Assert
            Assert.IsTrue(filesViewModel != null, "The response is not a FilesViewModel");
            Assert.IsTrue(filesViewModel.Items == null, "There are items in the response");
            Assert.AreEqual(string.Format(FilesWebServiceConstants.ParentPathNotExistingExceptionMessageFormat, parentPath), filesViewModel.Error, "When called with parent path that does not exist proper error is NOT returned");
        }
Exemplo n.º 10
0
        public void UninstallFeather_GridWidgetsInToolboxHybridPage_VerifyBackend()
        {
            var  moduleOperations = FeatherServerOperations.FeatherModule();
            Guid pageId           = Guid.Empty;

            moduleOperations.EnsureFeatherEnabled();

            try
            {
                string pageUrl;
                pageId = this.CreatePage(PageTemplateFramework.Hybrid, out pageUrl);

                var pageContentBeforeDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(pageUrl + this.AppendEditUrl());
                Assert.IsTrue(pageContentBeforeDeactivate.Contains(ModuleUnloadTests.FeatherGridToolboxItemMarkup));

                moduleOperations.DeactivateFeather();
                moduleOperations.UninstallFeather();

                var pageContentAfterDeactivate = FeatherServerOperations.FeatherWebRequests().GetResponseContentFromAuthenticateGetRequest(pageUrl + this.AppendEditUrl());
                Assert.IsFalse(pageContentAfterDeactivate.Contains(ModuleUnloadTests.FeatherGridToolboxItemMarkup));

                var configManager   = ConfigManager.GetManager();
                var toolboxesConfig = configManager.GetSection <ToolboxesConfig>();

                foreach (var toolbox in toolboxesConfig.Toolboxes.Values)
                {
                    foreach (var section in toolbox.Sections)
                    {
                        var existsFeatherWidgets = ((ICollection <ToolboxItem>)section.Tools)
                                                   .Any(i =>
                                                        i.ControlType.StartsWith("Telerik.Sitefinity.Frontend", StringComparison.Ordinal));

                        Assert.IsFalse(existsFeatherWidgets, "Feather widget still exists in section " + section.Name);
                    }
                }
            }
            finally
            {
                moduleOperations.InstallFeather();
                ServerOperations.Pages().DeletePage(pageId);
            }
        }