Пример #1
0
        public Guid CreateFormWithWidgets(IEnumerable <Control> widgets, string formTitle = null, bool publishForm = true)
        {
            var formId = Guid.NewGuid();

            string formSuccessMessage = "Success! Thanks for filling out our form!";

            var formControls = new List <Control>();

            foreach (var widget in widgets)
            {
                formControls.Add(widget);
            }

            var formName = "form_" + formId.ToString("N");

            if (formTitle == null)
            {
                formTitle = formId.ToString("N");
            }

            this.CreateForm(formId, formName, formTitle, formSuccessMessage, formControls, publishForm);

            SystemManager.ClearCurrentTransactions();
            SystemManager.RestartApplication(false);
            System.Threading.Thread.Sleep(1000);

            return(formId);
        }
Пример #2
0
        public void DynamicStructureTransfer_ImportDynamicModule_VerifyMvcWidgetsExist()
        {
            var exportModulePath = HostingEnvironment.MapPath(ImportExportDynamicStructureTests.ExportModulePath);

            if (!Directory.Exists(exportModulePath))
            {
                Directory.CreateDirectory(exportModulePath);
            }

            var assembly = ServerOperationsFeather.DynamicModules().GetTestUtilitiesAssembly();

            Dictionary <string, string> files = new System.Collections.Generic.Dictionary <string, string>()
            {
                { "PackedModule.sf", ImportExportDynamicStructureTests.DynamicModuleFile },
                { "widgetTemplates.sf", ImportExportDynamicStructureTests.DynamicModuleWidgetTemplatesFile },
                { "configs.sf", ImportExportDynamicStructureTests.DynamicModuleConfigurationsFile }
            };

            foreach (var file in files)
            {
                using (Stream embeddedFileStream = assembly.GetManifestResourceStream(file.Value))
                {
                    var filePath = string.Concat(exportModulePath, Path.DirectorySeparatorChar, file.Key);
                    using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
                    {
                        embeddedFileStream.CopyTo(fileStream);
                    }
                }
            }

            // Restart the application
            SystemManager.ClearCurrentTransactions();
            ServerOperations.SystemManager().RestartApplication(false);
            WaitUtils.WaitForSitefinityToStart(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) +
                                               (HostingEnvironment.ApplicationVirtualPath.TrimEnd('/') ?? string.Empty));

            var dynamicWidgetSection = ServerOperationsFeather.Pages().GetDynamicWidgetToolboxSection(ModuleName);

            string[] widgets = new string[]
            {
                ModuleWidgetTitle1,
                ModuleWidgetTitle2,
                ModuleWidgetTitle3
            };

            foreach (var widget in widgets)
            {
                Assert.IsTrue(ServerOperationsFeather.Pages().IsWidgetPresentInToolbox(dynamicWidgetSection, widget, isMvcWidget: true), "Widget " + widget + " is missing!");
                Assert.IsTrue(ServerOperationsFeather.Pages().IsWidgetPresentInToolbox(dynamicWidgetSection, widget, isMvcWidget: false), "Widget " + widget + " is missing!");
            }
        }
Пример #3
0
        /// <summary>
        /// Creates the form with widget.
        /// </summary>
        /// <param name="widget">The widget.</param>
        /// <returns></returns>
        public Guid CreateFormWithWidget(Control widget)
        {
            var formId = Guid.NewGuid();

            string formSuccessMessage = "Test form success message";

            var formControls = new List <Control>();

            formControls.Add(widget);

            this.CreateForm(formId, "form_" + formId.ToString("N"), formId.ToString("N"), formSuccessMessage, formControls);

            SystemManager.ClearCurrentTransactions();
            SystemManager.RestartApplication(false);
            System.Threading.Thread.Sleep(1000);

            return(formId);
        }
Пример #4
0
        public Guid CreateFormWithWidgets(IList <Control> formHeaderControls, IList <Control> formBodyControls, IList <Control> formFooterControls, string formTitle)
        {
            var formId = Guid.NewGuid();

            string formSuccessMessage = "Test form success message";

            if (formTitle == null)
            {
                formTitle = formId.ToString("N");
            }

            this.CreateFormWithHeaderAndFooter(formId, "form_" + formId.ToString("N"), formTitle, formSuccessMessage, formHeaderControls, formBodyControls, formFooterControls);

            SystemManager.ClearCurrentTransactions();
            SystemManager.RestartApplication(false);
            System.Threading.Thread.Sleep(1000);

            return(formId);
        }
Пример #5
0
        public Guid CreateFormWithWidgets(IEnumerable <Control> widgets)
        {
            var formId = Guid.NewGuid();

            string formSuccessMessage = "Test form success message";

            var formControls = new Dictionary <Control, string>();

            foreach (var widget in widgets)
            {
                formControls.Add(widget, "Body");
            }

            FormsModuleCodeSnippets.CreateForm(formId, "form_" + formId.ToString("N"), formId.ToString("N"), formSuccessMessage, formControls);

            SystemManager.ClearCurrentTransactions();
            SystemManager.RestartApplication(false);
            System.Threading.Thread.Sleep(1000);

            return(formId);
        }
Пример #6
0
        public void Navigation_FieldIsCorrectlyInitializedOnNewWidgetAdded()
        {
            var controller = new PageBreakController();
            var control    = new MvcWidgetProxy();

            control.ControllerName = typeof(PageBreakController).FullName;
            control.Settings       = new ControllerSettings(controller);

            var controls = new List <Control>()
            {
                control
            };
            var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(controls);

            var pageManager  = PageManager.GetManager();
            var formsManager = FormsManager.GetManager();

            try
            {
                var culture  = SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage;
                var tempForm = formsManager.EditForm(formId, culture);
                formsManager.SaveChanges();

                var zoneEditorService = new ZoneEditorService();
                var parameters        = new Dictionary <string, string>();
                parameters["ControllerName"] = typeof(NavigationFieldController).FullName;

                zoneEditorService.UpdateControlState(
                    new Telerik.Sitefinity.Web.UI.ZoneEditorWebServiceArgs()
                {
                    ControlType   = typeof(MvcControllerProxy).FullName,
                    PageId        = tempForm.Id,
                    PlaceholderId = "Body",
                    Parameters    = parameters,
                    MediaType     = DesignMediaType.Form,
                    Attributes    = new Dictionary <string, string>(),
                    CommandName   = "new",
                    Url           = "/Sitefinity/Forms/" + tempForm.Name
                });

                var tempFormId = tempForm.Id;

                SystemManager.ClearCurrentTransactions();
                formsManager = FormsManager.GetManager();
                tempForm     = formsManager.GetDraft(tempFormId);

                var masterForm = formsManager.Lifecycle.CheckIn(tempForm, culture);
                formsManager.Lifecycle.Publish(masterForm, culture);
                formsManager.SaveChanges();

                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "NavigationFieldInitializationTest", "section-header-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);

                var pageName1 = Res.Get <FieldResources>().PageName + "1";
                var pageName2 = Res.Get <FieldResources>().PageName + "2";
                Assert.IsTrue(pageContent.Contains(pageName1), "Form did not render navigation field pages");
                Assert.IsTrue(pageContent.Contains(pageName2), "Form did not render navigation field pages");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }