public void TextField_EditDefaultValue_MarkupIsCorrect() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.MetaField.DefaultValue = "My default text"; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValueTest", "text-field-value-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId); Assert.IsTrue(pageContent.Contains("My default text"), "Form did not render the default text in the text field."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
private void ExecuteResponsesSearchTextTest(string[,] responsesFieldsValues, string searchedText, int expectedResultsCount) { var fieldsPerResponse = responsesFieldsValues.GetLength(1); var controls = new MvcWidgetProxy[fieldsPerResponse]; for (int i = 0; i < controls.Length; i++) { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); control.Settings = new ControllerSettings(controller); controls[i] = control; } var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(controls); var manager = FormsManager.GetManager(); var form = manager.GetForm(formId); var masterDetailView = new FormsMasterDetailView(); masterDetailView.FormDescription = form; var masterDetailDefinition = new MasterGridViewDefinition(); typeof(FormsMasterDetailView).GetMethod("ConfigureSearchFields", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(masterDetailView, new object[] { masterDetailDefinition }); var fields = masterDetailDefinition.SearchFields.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(fieldsPerResponse, fields.Length, string.Format(CultureInfo.InvariantCulture, "The produced search fields count ({0}) is not equal to the actual fields count on the form ({1})", fields.Length, fieldsPerResponse)); var service = new FormsService(); try { using (var fluent = App.WorkWith()) { for (int responseIndex = 0; responseIndex < responsesFieldsValues.GetLength(0); responseIndex++) { var formEntry = fluent.Forms().Form(form.Name).Entry().CreateNew(Guid.NewGuid()); for (int fieldValueIndex = 0; fieldValueIndex < responsesFieldsValues.GetLength(1); fieldValueIndex++) { formEntry.SetFieldValue(fields[fieldValueIndex], responsesFieldsValues[responseIndex, fieldValueIndex]); } formEntry.SaveChanges(); } } var filterClauses = fields.Select(f => string.Format(CultureInfo.InvariantCulture, "{0}.ToUpper().Contains(\"{1}\".ToUpper())", f, searchedText)); var filter = "(" + string.Join(" OR ", filterClauses) + ")"; var entries = service.GetFormEntries(form.Name, null, "Title ASC", 0, 50, filter, manager.Provider.FormsNamespace + "." + form.Name, null, Guid.Empty); Assert.AreEqual(expectedResultsCount, entries.TotalCount, string.Format(CultureInfo.InvariantCulture, "The returned search results ({0}) do not match the expected ones ({1})", entries.TotalCount, expectedResultsCount)); } finally { FormsModuleCodeSnippets.DeleteForm(formId); } }
public void PageBreak_HeaderAndFooterFieldsInitialized() { var controllerForBody = new PageBreakController(); var controlForBody = new MvcWidgetProxy(); controlForBody.ControllerName = typeof(PageBreakController).FullName; controlForBody.Settings = new ControllerSettings(controllerForBody); var controllerForHeader = new TextFieldController(); var controlForHeader = new MvcWidgetProxy(); controlForHeader.ControllerName = typeof(TextFieldController).FullName; controlForHeader.Settings = new ControllerSettings(controllerForHeader); var controllerForFooter = new ParagraphTextFieldController(); var controlForFooter = new MvcWidgetProxy(); controlForFooter.ControllerName = typeof(ParagraphTextFieldController).FullName; controlForFooter.Settings = new ControllerSettings(controllerForFooter); var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(new List <Control>() { controlForHeader }, new List <Control>() { controlForBody }, new List <Control>() { controlForFooter }, null); var pageManager = PageManager.GetManager(); try { 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, "PageBreakValueTest", "section-header-field-value-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId); var formMultipageDecorator = ObjectFactory.Resolve <IFormMultipageDecorator>(); Assert.IsTrue(pageContent.Contains(formMultipageDecorator.SeparatorBegin), "Form did not render page separators"); Assert.IsTrue(pageContent.Contains("data-sf-role=\"text-field-container\""), "Form did not render page header"); Assert.IsTrue(pageContent.Contains("data-sf-role=\"paragraph-text-field-container\""), "Form did not render page footer"); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void Setup() { var control = new MvcControllerProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.MetaField.FieldName = FormEventsTests.FieldName; controller.MetaField.DefaultValue = "My default text"; control.Settings = new ControllerSettings(controller); FormEventsTests.formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); }
public void TextField_SubmitValue_ResponseIsCorrect() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.MetaField.DefaultValue = "My default text"; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var formManager = FormsManager.GetManager(); var form = formManager.GetForms().FirstOrDefault(f => f.Id == formId); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValueTest", "text-field-value-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id; var textFieldName = this.GetTextFieldName(formManager, form); this.FindAndSubmitForm(pageManager, pageDataId, textFieldName); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNotNull(formEntry, "Form entry has not been submitted."); var submittedValue = formEntry.GetValue(textFieldName) as string; Assert.IsTrue(submittedValue == "Submitted value", "Form did not persisted the submitted text value correctly."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void TextFieldUrl_SubmitIncorrectValue_ServerValidationFails() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.Model.InputType = Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField.TextType.Url; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var formManager = FormsManager.GetManager(); var form = formManager.GetForms().FirstOrDefault(f => f.Id == formId); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValidationTest", "text-field-validation-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var textFieldName = ServerOperationsFeather.Forms().GetFirstFieldName(formManager, form); var result = ServerOperationsFeather.Forms().SubmitField(textFieldName, "Submitted value", pageManager, pageId); var contentResult = result as ViewResult; Assert.IsNotNull(contentResult, "Submit should return content result."); Assert.AreEqual(Res.Get <FormResources>().UnsuccessfullySubmittedMessage, contentResult.ViewBag.SubmitMessage, "The Submit didn't result in error as expected!"); Assert.AreEqual("Form.SubmitResultView", contentResult.ViewName); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void TextFieldUrl_SubmitIncorrectValue_ServerValidationFails() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.Model.InputType = Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField.TextType.Url; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var formManager = FormsManager.GetManager(); var form = formManager.GetForms().FirstOrDefault(f => f.Id == formId); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValidationTest", "text-field-validation-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id; var textFieldName = this.GetTextFieldName(formManager, form); var formController = this.FindAndSubmitForm(pageManager, pageDataId, textFieldName); Assert.IsFalse((bool)formController.TempData["sfSubmitSuccess"], "The Submit result was not correct"); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void TextFieldUrl_SubmitIncorrectValue_ServerValidationFails() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.Model.InputType = Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField.TextType.Url; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var formManager = FormsManager.GetManager(); var form = formManager.GetForms().FirstOrDefault(f => f.Id == formId); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValidationTest", "text-field-validation-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var textFieldName = ServerOperationsFeather.Forms().GetFirstFieldName(formManager, form); var result = ServerOperationsFeather.Forms().SubmitField(textFieldName, "Submitted value", pageManager, pageId); var contentResult = result as ContentResult; Assert.IsNotNull(contentResult, "Submit should return content result."); Assert.AreEqual(Res.Get<FormResources>().UnsuccessfullySubmittedMessage, contentResult.Content, "The Submit didn't result in error as expected!"); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void TextFieldUrl_SubmitIncorrectValue_ServerValidationFails() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.Model.InputType = Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField.TextType.Url; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var formManager = FormsManager.GetManager(); var form = formManager.GetForms().FirstOrDefault(f => f.Id == formId); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValidationTest", "text-field-validation-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id; var textFieldName = this.GetTextFieldName(formManager, form); var formController = this.FindAndSubmitForm(pageManager, pageDataId, textFieldName); Assert.IsFalse((bool)formController.TempData["sfSubmitSuccess"], "The Submit result was not correct"); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
private void ExecuteResponsesSearchTextTest(string[,] responsesFieldsValues, string searchedText, int expectedResultsCount) { var fieldsPerResponse = responsesFieldsValues.GetLength(1); var controls = new MvcWidgetProxy[fieldsPerResponse]; for (int i = 0; i < controls.Length; i++) { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); control.Settings = new ControllerSettings(controller); controls[i] = control; } var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(controls); var manager = FormsManager.GetManager(); var form = manager.GetForm(formId); var masterDetailView = new FormsMasterDetailView(); masterDetailView.FormDescription = form; var masterDetailDefinition = new MasterGridViewDefinition(); typeof(FormsMasterDetailView).GetMethod("ConfigureSearchFields", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(masterDetailView, new object[] { masterDetailDefinition }); var fields = masterDetailDefinition.SearchFields.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(fieldsPerResponse, fields.Length, string.Format(CultureInfo.InvariantCulture, "The produced search fields count ({0}) is not equal to the actual fields count on the form ({1})", fields.Length, fieldsPerResponse)); var service = new FormsService(); try { using (var fluent = App.WorkWith()) { for (int responseIndex = 0; responseIndex < responsesFieldsValues.GetLength(0); responseIndex++) { var formEntry = fluent.Forms().Form(form.Name).Entry().CreateNew(Guid.NewGuid()); for (int fieldValueIndex = 0; fieldValueIndex < responsesFieldsValues.GetLength(1); fieldValueIndex++) { formEntry.SetFieldValue(fields[fieldValueIndex], responsesFieldsValues[responseIndex, fieldValueIndex]); } formEntry.SaveChanges(); } } var filterClauses = fields.Select(f => string.Format(CultureInfo.InvariantCulture, "{0}.ToUpper().Contains(\"{1}\".ToUpper())", f, searchedText)); var filter = "(" + string.Join(" OR ", filterClauses) + ")"; var entries = service.GetFormEntries(form.Name, null, "Title ASC", 0, 50, filter, manager.Provider.FormsNamespace + "." + form.Name, null, Guid.Empty); Assert.AreEqual(expectedResultsCount, entries.TotalCount, string.Format(CultureInfo.InvariantCulture, "The returned search results ({0}) do not match the expected ones ({1})", entries.TotalCount, expectedResultsCount)); } finally { FormsModuleCodeSnippets.DeleteForm(formId); } }
public DataSource (TextFieldController tvc) { this.tvc = tvc; }
public void TextField_EditDefaultValue_MarkupIsCorrect() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.MetaField.DefaultValue = "My default text"; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValueTest", "text-field-value-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageContent = FeatherServerOperations.Pages().GetPageContent(pageId); Assert.IsTrue(pageContent.Contains("My default text"), "Form did not render the default text in the text field."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public void TextField_SubmitValue_ResponseIsCorrect() { var control = new MvcWidgetProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.MetaField.DefaultValue = "My default text"; control.Settings = new ControllerSettings(controller); var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); var formManager = FormsManager.GetManager(); var form = formManager.GetForms().FirstOrDefault(f => f.Id == formId); var pageManager = PageManager.GetManager(); try { 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, "TextFieldValueTest", "text-field-value-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id; var textFieldName = this.GetTextFieldName(formManager, form); this.FindAndSubmitForm(pageManager, pageDataId, textFieldName); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNotNull(formEntry, "Form entry has not been submitted."); var submittedValue = formEntry.GetValue(textFieldName) as string; Assert.IsTrue(submittedValue == "Submitted value", "Form did not persisted the submitted text value correctly."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
public DataSource(TextFieldController tvc) { this.tvc = tvc; }
public void Setup() { var control = new MvcControllerProxy(); control.ControllerName = typeof(TextFieldController).FullName; var controller = new TextFieldController(); controller.MetaField.FieldName = FormEventsTests.FieldName; controller.MetaField.DefaultValue = "My default text"; control.Settings = new ControllerSettings(controller); FormEventsTests.formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control); }