public async Task ProcessAsync_CallsIntoGenerateValidationSummaryWithExpectedParameters(
            ValidationSummary validationSummary,
            bool expectedExcludePropertyErrors)
        {
            // Arrange
            var expectedViewContext = CreateViewContext();

            var generator = new Mock<IHtmlGenerator>();
            generator
                .Setup(mock => mock.GenerateValidationSummary(
                    expectedViewContext,
                    expectedExcludePropertyErrors,
                    null,   // message
                    null,   // headerTag
                    null))  // htmlAttributes
                .Returns(new TagBuilder("div"))
                .Verifiable();

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator.Object)
            {
                ValidationSummary = validationSummary,
            };

            var expectedPreContent = "original pre-content";
            var expectedContent = "original content";
            var expectedPostContent = "original post-content";
            var output = new TagHelperOutput(
                tagName: "div",
                attributes: new TagHelperAttributeList(),
                getChildContentAsync: (useCachedResult, encoder) => Task.FromResult<TagHelperContent>(
                    new DefaultTagHelperContent()));
            output.PreContent.SetContent(expectedPreContent);
            output.Content.SetContent(expectedContent);
            output.PostContent.SetContent(expectedPostContent);

            validationSummaryTagHelper.ViewContext = expectedViewContext;

            var context = new TagHelperContext(
                allAttributes: new TagHelperAttributeList(
                    Enumerable.Empty<TagHelperAttribute>()),
                items: new Dictionary<object, object>(),
                uniqueId: "test");

            // Act & Assert
            await validationSummaryTagHelper.ProcessAsync(context, output);

            generator.Verify();
            Assert.Equal("div", output.TagName);
            Assert.Empty(output.Attributes);
            Assert.Equal(expectedPreContent, output.PreContent.GetContent());
            Assert.Equal(expectedContent, output.Content.GetContent());
            Assert.Equal(expectedPostContent, output.PostContent.GetContent());
        }
        public async Task ProcessAsync_CallsIntoGenerateValidationSummaryWithExpectedParameters(
            ValidationSummary validationSummary,
            bool expectedExcludePropertyErrors)
        {
            // Arrange
            var expectedViewContext = CreateViewContext();

            var generator = new Mock<IHtmlGenerator>();
            generator
                .Setup(mock => mock.GenerateValidationSummary(
                    expectedViewContext,
                    expectedExcludePropertyErrors,
                    null,   // message
                    null,   // headerTag
                    null))  // htmlAttributes
                .Returns(new TagBuilder("div"))
                .Verifiable();

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator.Object)
            {
                ValidationSummary = validationSummary,
            };

            var expectedPreContent = "original pre-content";
            var expectedContent = "original content";
            var expectedPostContent = "original post-content";
            var output = new TagHelperOutput(
                "div",
                attributes: new TagHelperAttributeList());
            output.PreContent.SetContent(expectedPreContent);
            output.Content.SetContent(expectedContent);
            output.PostContent.SetContent(expectedPostContent);

            
            validationSummaryTagHelper.ViewContext = expectedViewContext;

            // Act & Assert
            await validationSummaryTagHelper.ProcessAsync(context: null, output: output);

            generator.Verify();
            Assert.Equal("div", output.TagName);
            Assert.Empty(output.Attributes);
            Assert.Equal(expectedPreContent, output.PreContent.GetContent());
            Assert.Equal(expectedContent, output.Content.GetContent());
            Assert.Equal(expectedPostContent, output.PostContent.GetContent());
        }
示例#3
0
        public void ValidationSummaryProperty_ThrowsWhenSetToInvalidValidationSummaryValue(
            ValidationSummary validationSummary)
        {
            // Arrange
            var generator = new TestableHtmlGenerator(new EmptyModelMetadataProvider());

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator);
            var validationTypeName         = typeof(ValidationSummary).FullName;
            var expectedMessage            =
                $@"The value of argument 'value' ({validationSummary}) is invalid for Enum type '{validationTypeName}'.
Parameter name: value";

            // Act & Assert
            var ex = Assert.Throws <ArgumentException>(
                "value",
                () => { validationSummaryTagHelper.ValidationSummary = validationSummary; });

            Assert.Equal(expectedMessage, ex.Message);
        }
示例#4
0
        public void Header()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(null, vs.Header);
                vs.Header = "newheader";
                Assert.AreEqual("newheader", vs.Header);
                Assert.AreEqual(vs.Header, vs.HeaderContentControlInternal.Content);
                vs.Header = null;
                Assert.IsNull(vs.Header);
                Assert.AreEqual("0 Errors", vs.HeaderContentControlInternal.Content);
            });
            EnqueueTestComplete();
        }
示例#5
0
        public void HeaderTemplate()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(vs);
                Assert.IsNotNull(vs.HeaderTemplate);
                DataTemplate testDataTemplate = page.LayoutRoot.Resources["testDataTemplate"] as DataTemplate;
                Assert.IsNotNull(testDataTemplate);
                vs.HeaderTemplate = testDataTemplate;
                Assert.AreEqual(testDataTemplate, vs.HeaderTemplate);
                Assert.AreEqual(testDataTemplate, vs.HeaderContentControlInternal.ContentTemplate);
            });
            EnqueueTestComplete();
        }
        protected override void CreateChildControls()
        {
            Controls.Clear();

            pnlValidation                    = new Panel();
            validationSummary                = new ValidationSummary();
            validationSummary.DisplayMode    = ValidationSummaryDisplayMode;
            validationSummary.CssClass       = @"message error";
            validationSummary.ShowMessageBox = ValidationSummaryShowMessageBox;
            validationSummary.ShowSummary    = ValidationSummaryShowSummary;
            pnlValidation.Controls.Add(validationSummary);

            if (HasValidationSummary)
            {
                pnlMessageCenter.Controls.Add(pnlValidation);
            }

            this.Controls.Add(pnlMessageCenter);
            base.CreateChildControls();
        }
        /// <summary>
        /// Determines whether the specified value is valid.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="field">The field.</param>
        /// <param name="summary">The summary.</param>
        public override bool IsValid(object value, string field, ref ValidationSummary summary)
        {
            string   dayText = value as string;
            DateTime day     = DateTime.Now;

            if (DateTime.TryParse(dayText, out day))
            {
                int result = DateTime.Compare(day, DateTime.Now);
                if (result < 0)
                {
                    ValidationEntry ve = new ValidationEntry(false, String.Format(Resources.NoValidDate, new[] { field }), field, value);
                    summary.Add(ve);

                    return(false);
                }
                return(true);
            }

            return(false);
        }
        public void EnsureObjectLevelErrorsInvolvingInvalidFieldsAreNotShown()
        {
            ValidationSummary validationSummary = null;

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                validationSummary = this.GetTemplatePart <ValidationSummary>("ValidationSummary");
                this.ExpectContentLoaded();
                this.DataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                this.GetInputControls();
                this.textBox.Text = "1";

                this.comboBox.SelectedItem = 9;
                this.DataForm.ValidateItem();
                Assert.AreEqual(1, validationSummary.Errors.Count);
                Assert.AreEqual("IntProperty must be between 0 and 7.", validationSummary.Errors[0].Message);

                this.comboBox.SelectedItem = 1;
                this.DataForm.ValidateItem();
                Assert.AreEqual(1, validationSummary.Errors.Count);
                Assert.AreEqual("IntProperty cannot be equal to StringProperty.", validationSummary.Errors[0].Message);

                this.comboBox.SelectedItem = 9;
                this.DataForm.ValidateItem();
                Assert.AreEqual(1, validationSummary.Errors.Count);
                Assert.AreEqual("IntProperty must be between 0 and 7.", validationSummary.Errors[0].Message);

                this.comboBox.SelectedItem = 2;
                Assert.AreEqual(0, validationSummary.Errors.Count);
            });

            this.EnqueueTestComplete();
        }
示例#9
0
        public void ErrorClickedSelectedItem()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                page.nameTextBox.Text = "ABCDEFG!@#$";
                Assert.AreEqual(1, vs.Errors.Count);

                ValidationSummaryItem newVsi = new ValidationSummaryItem("test error", null, ValidationSummaryItemType.ObjectError, new ValidationSummaryItemSource("property name", page.nameTextBox), this);
                vs.Errors.Add(newVsi);

                bool clicked = false;

                // Setup the delegate to capture the event
                vs.ErrorsListBoxInternal.SelectedItem = newVsi;
                FocusingInvalidControlEventArgs eArgs = null;
                ValidationSummaryItem vsi             = null;
                vs.FocusingInvalidControl            += new EventHandler <FocusingInvalidControlEventArgs>(delegate(object o, FocusingInvalidControlEventArgs e)
                {
                    clicked = true;
                    eArgs   = e;
                    vsi     = e.Item;
                });

                // Simulate a click on the first item
                vs.ExecuteClickInternal();
                Assert.IsTrue(clicked);
                Assert.IsNotNull(vsi);
                Assert.AreEqual("test error", vsi.Message);
                Assert.AreEqual(ValidationSummaryItemType.ObjectError, vsi.ItemType);
                Assert.AreEqual(this, vsi.Context);
                Assert.AreEqual(page.nameTextBox, vsi.Sources[0].Control);
                Assert.AreEqual("property name", vsi.Sources[0].PropertyName);
            });
            EnqueueTestComplete();
        }
示例#10
0
        public void DisplayedErrors_ItemTypeUpdates()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(vs);
                BindingExpression be = page.nameTextBox.GetBindingExpression(TextBox.TextProperty);
                Assert.IsNotNull(be);

                // Cause a validation error via the input control
                page.nameTextBox.Text = "ABCDEFG!@#$";
                Assert.AreEqual(1, vs.DisplayedErrors.Count);
                Assert.IsTrue(vs.HasErrors);
                Assert.IsTrue(vs.HasDisplayedErrors);

                // Add object error
                ValidationSummaryItem newError = new ValidationSummaryItem(null, "new error", ValidationSummaryItemType.ObjectError, null, null);
                vs.Errors.Add(newError);
                Assert.AreEqual(2, vs.DisplayedErrors.Count);
                Assert.IsTrue(vs.HasErrors);
                Assert.IsTrue(vs.HasDisplayedErrors);

                // Change filter
                vs.Filter = ValidationSummaryFilters.ObjectErrors;
                Assert.AreEqual(1, vs.DisplayedErrors.Count);
                Assert.IsTrue(vs.HasErrors);
                Assert.IsTrue(vs.HasDisplayedErrors);

                // Change ItemType so that there's no object errors
                newError.ItemType = ValidationSummaryItemType.PropertyError;
                Assert.AreEqual(0, vs.DisplayedErrors.Count);
                Assert.IsTrue(vs.HasErrors);
                Assert.IsFalse(vs.HasDisplayedErrors);
            });
            EnqueueTestComplete();
        }
示例#11
0
        /// <summary>
        /// When one of the input controls has its ShowErrorsInSummary property changed, we have to go through all the ValidationSummaries on the page and update them
        /// </summary>
        /// <param name="parent">The parent ValidationSummary</param>
        private static void UpdateDisplayedErrorsOnAllValidationSummaries(DependencyObject parent)
        {
            if (parent == null)
            {
                return;
            }

            ValidationSummary vs = parent as ValidationSummary;

            if (vs != null)
            {
                vs.UpdateDisplayedErrors();
                return;
            }

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(parent, i);
                UpdateDisplayedErrorsOnAllValidationSummaries(child);
            }
        }
示例#12
0
        public override void RenderControl()
        {
            page = HttpContext.Current.Handler as BasePage;
            base.RenderControl();

            page.MessageBus.Subscribe <DisplayAlertMessage>(RenderAlert);

            AlertHolder = new PlaceHolder();
            this.ContentPlaceHolder.Controls.Add(AlertHolder);

            if (Me.IncludeValidationSummary)
            {
                ValidationSummary summary = new ValidationSummary();
                summary.HeaderText         = "The following error(s) occurred:";
                summary.DisplayMode        = ValidationSummaryDisplayMode.List;
                summary.EnableClientScript = true;
                summary.CssClass           = "alert alert-danger";

                this.ContentPlaceHolder.Controls.Add(summary);
            }
        }
示例#13
0
        /// <summary>
        /// Saves the Resource asynchronous.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Cellent.Template.Common.Exceptions.ValidationException"></exception>
        public async Task <IResourceModel> SaveAsync()
        {
            if (State == Constants.EntityState.Unchanged)
            {
                return(this);
            }

            ValidationSummary summary = Validator.Validate(this);

            if (!summary.IsValid)
            {
                throw new ValidationException(summary);
            }

            ResourceDto resource = await ServiceClient <IResourceService>
                                   .ExecuteAsync(d => d.SaveAsync(Factory.Convert(this)));

            IResourceModel resourceModel = Factory.Convert(resource);

            return(resourceModel);
        }
示例#14
0
        public void SelectionChanged()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                page.nameTextBox.Text = "ABCDEFG!@#$";
                Assert.AreEqual(1, vs.Errors.Count);

                ValidationSummaryItem newEsi = new ValidationSummaryItem(null, "test error", ValidationSummaryItemType.ObjectError, null, null);

                ValidationSummaryItemSource source1 = new ValidationSummaryItemSource("prop1", page.nameTextBox);
                newEsi.Sources.Add(source1);
                ValidationSummaryItemSource source2 = new ValidationSummaryItemSource("prop2", page.emailTextBox);
                newEsi.Sources.Add(source2);

                vs.Errors.Add(newEsi);
                ValidationSummaryItem newEsi2 = new ValidationSummaryItem(null, "test error", ValidationSummaryItemType.ObjectError, null, null);
                vs.Errors.Add(newEsi2);

                // Setup the delegate to capture the event
                bool selectionChanged = false;
                vs.SelectionChanged  += new EventHandler <SelectionChangedEventArgs>(delegate(object o, SelectionChangedEventArgs e)
                {
                    selectionChanged = true;
                });

                vs.ErrorsListBoxInternal.SelectedItem = newEsi;
                vs.ErrorsListBoxInternal.SelectedItem = newEsi2;
                // First click
                vs.ExecuteClickInternal();
                Assert.IsTrue(selectionChanged);
            });

            EnqueueTestComplete();
        }
        protected void rgAbsentReason_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            try
            {
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem item = e.Item as GridEditableItem;

                    if (item != null)
                    {
                        TextBox txtName = item["Reason"].FindControl("txtReason") as TextBox;
                        if (txtName != null)
                        {
                            TableCell cell = (TableCell)txtName.Parent;
                            RequiredFieldValidator validator = new RequiredFieldValidator();
                            if (cell != null)
                            {
                                txtName.ID = "txtReason";
                                validator.ControlToValidate = txtName.ID;
                                validator.ErrorMessage      = "Please Enter Reason\n";
                                validator.SetFocusOnError   = true;
                                validator.Display           = ValidatorDisplay.None;
                            }
                            ValidationSummary validationsum = new ValidationSummary();
                            validationsum.ID             = "validationsum1";
                            validationsum.ShowMessageBox = true;
                            validationsum.ShowSummary    = false;
                            validationsum.DisplayMode    = ValidationSummaryDisplayMode.SingleParagraph;
                            cell.Controls.Add(validator);
                            cell.Controls.Add(validationsum);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.AbsentReason, "rgAbsentReason_ItemCreated", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
            }
        }
        public void ErrorsAndWarnings()
        {
            //Arrange
            var view                = new ValidationSummary();
            var viewModel           = new ModelStateDictionary();
            var viewModelToValidate = new ValidationSummaryViewModel();
            var validator           = new ValidationSummaryViewModelValidator();
            var results             = validator.Validate(viewModelToValidate);

            results.AddToModelStateWithSeverity(viewModel, string.Empty);

            //Act
            var document = new ValidationSummaryDocument(view.RenderAsHtml(viewModel));

            //Assert
            document.ErrorsClass.Should().StartWith("validation-summary-errors");
            document.ErrorsClass.Should().NotContain("-valid");
            document.WarningsClass.Should().StartWith("validation-summary-warnings");
            document.WarningsClass.Should().NotContain("-valid");
            document.Errors.Count.Should().Be(2);
            document.Warnings.Count.Should().Be(2);
        }
示例#17
0
        public void Filter()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(vs);
                ICollection filteredErrors = vs.DisplayedErrors;
                Assert.IsNotNull(filteredErrors);
                Assert.AreEqual(0, filteredErrors.Count);
                page.nameTextBox.Text = "ABCDEFG!@#$";
                Assert.AreEqual(1, filteredErrors.Count);
                page.emailTextBox.Text = "abcd";
                Assert.AreEqual(2, filteredErrors.Count);

                vs.Errors.Add(new ValidationSummaryItem(null, "custom1", ValidationSummaryItemType.ObjectError, null, null));
                Assert.AreEqual(3, filteredErrors.Count);
                vs.Errors.Add(new ValidationSummaryItem(null, "custom2", ValidationSummaryItemType.ObjectError, null, null));
                Assert.AreEqual(4, filteredErrors.Count);

                vs.Filter = ValidationSummaryFilters.ObjectErrors;
                Assert.AreEqual(2, filteredErrors.Count);

                vs.Filter = ValidationSummaryFilters.PropertyErrors;
                Assert.AreEqual(2, filteredErrors.Count);
                vs.Filter = ValidationSummaryFilters.None;
                Assert.AreEqual(0, filteredErrors.Count);
                vs.Filter = ValidationSummaryFilters.ObjectErrors | ValidationSummaryFilters.PropertyErrors;
                Assert.AreEqual(4, filteredErrors.Count, "or'ing entity and property");
                vs.Filter = ValidationSummaryFilters.All;
                Assert.AreEqual(4, filteredErrors.Count, "all");
            });
            EnqueueTestComplete();
        }
示例#18
0
        /// <summary>
        /// Builds the row containing the search button and sets the button's properties
        /// </summary>
        /// <param name="searchFormTable">Root table that holds the search row</param>
        private void BuildSearchRow(Table searchFormTable)
        {
            //Add the row for the search button
            TableRow  searchRow  = new TableRow();
            TableCell searchCell = new TableCell();

            searchCell.ColumnSpan = 2;
            //Search Button

            Button searchButton = new Button();

            searchButton.Visible          = false;
            searchButton.ID               = SearchButtonID;
            searchButton.Click           += new EventHandler(searchButton_Click);
            searchButton.Text             = LoadResource("SearchText");
            searchButton.CssClass         = "ms-ButtonHeightWidth";
            searchButton.ValidationGroup  = MetaSearchValidationGroup;
            searchButton.CausesValidation = true;
            //Add controls to containers
            searchCell.Controls.Add(searchButton);
            searchRow.Cells.Add(searchCell);
            searchFormTable.Rows.Add(searchRow);

            //Add Validation Summary row
            TableRow validationRow = new TableRow();

            searchFormTable.Rows.Add(validationRow);
            TableCell validationCell = new TableCell();

            validationRow.Cells.Add(validationCell);
            validationCell.ColumnSpan = 2;

            ValidationSummary validationSummary = new ValidationSummary();

            validationSummary.ValidationGroup    = MetaSearchValidationGroup;
            validationSummary.EnableClientScript = true;
            validationCell.Controls.Add(validationSummary);
        }
        public void ValidationSummaryPeer()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);
            ValidationSummary vs = page.validationSummary;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                ValidationSummaryAutomationPeer peer = new ValidationSummaryAutomationPeer(vs);
                Assert.IsNotNull(peer);
                Assert.AreEqual(AutomationControlType.Group, peer.GetAutomationControlType());
                Assert.AreEqual("ValidationSummary", peer.GetClassName());
                Assert.AreEqual("0 Errors", peer.GetName());

                vs.Errors.Add(new ValidationSummaryItem("header1", "msg1", ValidationSummaryItemType.PropertyError, null, null));
                Assert.AreEqual("1 Error", peer.GetName());
                vs.Errors.Add(new ValidationSummaryItem("header2", "msg2", ValidationSummaryItemType.PropertyError, null, null));
                Assert.AreEqual("2 Errors", peer.GetName());
            });
            EnqueueTestComplete();
        }
示例#20
0
        public void SortByVisualTreeOrdering()
        {
            ValidationSummaryTestPage page = new ValidationSummaryTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(0, ValidationSummary.SortByVisualTreeOrdering(null, null), "both null");
                Assert.AreEqual(0, ValidationSummary.SortByVisualTreeOrdering(null, page.emailTextBox), "null 1");
                Assert.AreEqual(0, ValidationSummary.SortByVisualTreeOrdering(page.nameTextBox, null), "null 2");
                Assert.AreEqual(-1, ValidationSummary.SortByVisualTreeOrdering(page.nameTextBox, page.emailTextBox), "same level");
                Assert.AreEqual(0, ValidationSummary.SortByVisualTreeOrdering(page.mainPanel, page.mainPanel), "same reference");
                Assert.AreEqual(1, ValidationSummary.SortByVisualTreeOrdering(page.emailTextBox, page.nameTextBox), "inverse");
                Assert.AreEqual(0, ValidationSummary.SortByVisualTreeOrdering(page.emailTextBox, new TextBox()), "not in visual tree");
                Assert.AreEqual(-1, ValidationSummary.SortByVisualTreeOrdering(page.emailTextBox, page.tb1), "nested");
                Assert.AreEqual(1, ValidationSummary.SortByVisualTreeOrdering(page.lastTextBox, page.tb1), "nested after");
                Assert.AreEqual(-1, ValidationSummary.SortByVisualTreeOrdering(page.mainPanel, page.tb1), "parent child");
                Assert.AreEqual(1, ValidationSummary.SortByVisualTreeOrdering(page.tb1, page.mainPanel), "parent child reverse");
            });
            EnqueueTestComplete();
        }
示例#21
0
    public void RegisterValidationSummaryMessageBox(ValidationSummary vs)
    {
        System.Reflection.FieldInfo fi = typeof(Page).GetField("_validated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        if (fi != null)
        {
            if ((bool)fi.GetValue(Page))
            {
                if (!Page.IsValid)
                {
                    if (vs.ShowMessageBox)
                    {
                        System.Text.StringBuilder sb = new System.Text.StringBuilder(vs.HeaderText);
                        string sep = " ";
                        switch (vs.DisplayMode)
                        {
                        case ValidationSummaryDisplayMode.BulletList:
                            sep = "\\n-";
                            break;

                        case ValidationSummaryDisplayMode.List:
                            sep = "\\n";
                            break;
                        }
                        foreach (IValidator val in Validators)
                        {
                            if (!val.IsValid)
                            {
                                sb.Append(sep);
                                sb.Append(val.ErrorMessage.Replace("\'", "\\'"));
                            }
                        }
                        Javascript.Notify(sb.ToString(), true);
                    }
                }
            }
        }
    }
        public void EnsureExternalErrorsAreNotRemoved()
        {
            ValidationSummary validationSummary = null;

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                validationSummary = this.GetTemplatePart <ValidationSummary>("ValidationSummary");
                validationSummary.Errors.Add(new ValidationSummaryItem("Message", "Header", ValidationSummaryItemType.ObjectError, null, null));
                this.ExpectContentLoaded();
                this.DataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                this.GetInputControls();
                Assert.AreEqual(1, validationSummary.Errors.Count);
                SetValue(this.textBox, "1");
                this.CommitAllFields();
                Assert.AreEqual(1, validationSummary.Errors.Count);

                this.DataForm.ValidateItem();
                Assert.AreEqual(2, validationSummary.Errors.Count);

                SetValue(this.textBox, "test string 1");
                this.CommitAllFields();
                this.DataForm.ValidateItem();

                Assert.AreEqual(1, validationSummary.Errors.Count);
            });

            this.EnqueueTestComplete();
        }
示例#23
0
        protected void rgClassRoom_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.FilteringItem)
            {
                GridFilteringItem fileterItem = (GridFilteringItem)e.Item;
                for (int i = 0; i < fileterItem.Cells.Count; i++)
                {
                    fileterItem.Cells[i].Style.Add("text-align", "left");
                }
            }
            try
            {
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem           item = e.Item as GridEditableItem;
                    RequiredFieldValidator     validator;
                    RegularExpressionValidator regvalidator;
                    TableCell cell;
                    if (item != null)
                    {
                        ValidationSummary validationsum = new ValidationSummary();
                        validationsum.ID             = "validationsum1";
                        validationsum.ShowMessageBox = true;
                        validationsum.ShowSummary    = false;
                        validationsum.DisplayMode    = ValidationSummaryDisplayMode.SingleParagraph;
                        GridTextBoxColumnEditor editor  = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("Name");
                        ImageButton             cmdEdit = (ImageButton)item["Edit"].Controls[0];
                        if (editor != null)
                        {
                            cell      = (TableCell)editor.TextBoxControl.Parent;
                            validator = new RequiredFieldValidator();

                            if (cell != null)
                            {
                                editor.TextBoxControl.ID    = "Name";
                                validator.ControlToValidate = editor.TextBoxControl.ID;
                                validator.ErrorMessage      = "Please Enter ClassRoom\n";
                                validator.SetFocusOnError   = true;
                                validator.Display           = ValidatorDisplay.None;
                                cell.Controls.Add(validator);
                                cell.Controls.Add(validationsum);
                            }
                        }
                        TextBox txtMaxSize = item["MaxSize"].FindControl("txtMaxSize") as TextBox;
                        if (txtMaxSize != null)
                        {
                            cell         = (TableCell)txtMaxSize.Parent;
                            regvalidator = new RegularExpressionValidator();
                            if (cell != null)
                            {
                                txtMaxSize.ID = "txtMaxSize";
                                regvalidator.ControlToValidate    = txtMaxSize.ID;
                                regvalidator.ValidationExpression = "[0-9]*";
                                regvalidator.ErrorMessage         = "Max size require numeric. \n";
                                regvalidator.SetFocusOnError      = true;
                                regvalidator.Display = ValidatorDisplay.None;
                                cell.Controls.Add(regvalidator);
                                cell.Controls.Add(validationsum);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.ClassRoom, "rgClassRoom_ItemCreated", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
            }
        }
示例#24
0
 public static IValidationResponse <T> ToValidationResponse <T>(this ValidationSummary validationSummary)
 {
     return(new ValidationResponse <T> {
         Errors = validationSummary.Errors
     });
 }
        public void ExportHTML(string SettingsFileName, ref ImageValidatorData data, ref ImageValidatorSettings settings, string FileName, bool bSilent, bool bThumbnails)
        {
            ValidationSummary validationSummary = new ValidationSummary(ref data, ref settings);

            string Folder = Path.GetDirectoryName(FileName) + "\\" + Path.GetFileNameWithoutExtension(FileName) + "_Thumbnails";

            if (bThumbnails)
            {
                Directory.CreateDirectory(Folder);
            }

            // Note C# string literals can span multiple lines, " need to be converted to ""
            string template = @"
<!DOCTYPE HTML PUBLIC \""-//W3C//DTD HTML 4.01 Transitional//EN\"" \""http://www.w3.org/TR/html4/loose.dtd\"">
<html>
<head>
<title>ImageValidator Report</title>
</head>
<body>
<h1>ImageValidator Report</h1>

<br>
<h4>ImageValidator Settings ""%SETTINGSFILENAME%"":</h4>
<div style=""margin:10px;margin-left:40px"" >%SETTINGS% </div>
<br>

<h4>Summary:</h4>
<div style=""margin:10px;margin-left:40px""> %SUMMARY% </div>
<br>

<h4>Output:</h4>
<div style=""margin:10px;margin-left:40px""> %OUTPUT% </div>
<br>

<br>
<b>Generated by Application:</b> ImageValidator.exe (part of UnrealEngine by Epic Games)<br>
<b>Application Version:</b> %VERSION%<br>
<b>Generated by User:</b> %USER%<br>
<b>Generated Date:</b> %DATE%<br>

<style type=""text/css"">
//body { background-color:#000000; color:#E0E0E0 }

* {
    font-family: ?Times New Roman?, Times, serif;
 //   font-weight: bold;
    
}

h1 { color:#555555; font-size:32px; border-bottom:solid thin black; }

table, hd, th {
    border:0px; color:#000000; padding:4px; border-spacing:0px;
    border-collapse:collapse;
    }
   
td { padding:2px; padding-right:7px }
td.Output { padding:7px; border:1px solid #cccccc; }

th {
    background-color:#E0E0E0;
    color: #000000;
    text-align: left;
    border: 1px solid #c0c0c0;
}

a.prefix {
    border: 0px solid;
    padding: 3px;
    padding-left: 5px;
    padding-right: 5px;
    font-weight: bold;
    text-decoration:none;
    margin:4px;
    white-space: nowrap;
}

a.prefix:link {
    border:1px solid #7777FF;
    background-color:#ddddff;
    color: #7777FF;
}


a.prefix:hover {
    background-color:#7777FF;
    color: #ddddff;
}

</style>
    
</body>
</html>";

            // we can change this if needed:
            //ImageFormat imageFormat = ImageFormat.Jpeg;   // small file size?
            //ImageFormat imageFormat = ImageFormat.Gif;   // dither artifacts
            ImageFormat imageFormat = ImageFormat.Png;    // good compromise

            // we derive the extension from imageFormat e.g. ".jpg"
            string imageFormatExtension = "";
            {
                if (imageFormat == ImageFormat.Jpeg)
                {
                    imageFormatExtension = ".jpg";
                }
                else if (imageFormat == ImageFormat.Gif)
                {
                    imageFormatExtension = ".gif";
                }
                else if (imageFormat == ImageFormat.Png)
                {
                    imageFormatExtension = ".Png";
                }

                Debug.Assert(imageFormatExtension != "");
            }

            // todo: how to repro, Date, IVxml file attached?, thumbnails

            string Output = "<table class=Output><tr>";

            Output += "<th>Result (pixels failed)</th>";

            if (bThumbnails)
            {
                Output += "<th>Thumbnails (test/diff/ref)</th>";
            }
            Output += "<th>Matinee Location (in sec)</th>";
            //            Output += "<th>Actor</th>";
            //            Output += "<th>Map</th>";
            //            Output += "<th>Platform</th>";
            Output += "<th>Folder Name</th>";
            Output += "<th>File Name</th></tr>\n";
            {
                uint Index = 0;
                foreach (ImageValidatorData.ImageEntry entry in data.imageEntries)
                {
                    TestResult test = entry.testResult;
                    bool       bShowDiffAndRefThumbnails = !test.IsPassed(ref settings);

                    // open table row
                    Output += "<tr class=Output>";

                    Color BackColor = Color.White;

                    string ThumbnailTest = Folder + "\\Test" + Index + imageFormatExtension;
                    string ThumbnailDiff = Folder + "\\Diff" + Index + imageFormatExtension;
                    string ThumbnailRef  = Folder + "\\Ref" + Index + imageFormatExtension;

                    if (test != null)
                    {
                        BackColor = test.GetColor(ref settings);

                        if (bThumbnails)
                        {
                            test.ThumbnailTest.Save(ThumbnailTest, imageFormat);

                            if (bShowDiffAndRefThumbnails)
                            {
                                test.ThumbnailDiff.Save(ThumbnailDiff, imageFormat);
                                test.ThumbnailRef.Save(ThumbnailRef, imageFormat);
                            }
                        }
                    }

                    ImageValidatorData.ImageEntryColumnData columnData = new ImageValidatorData.ImageEntryColumnData(entry.Name);

                    string ResultString = "?";

                    if (entry.testResult != null)
                    {
                        ResultString = entry.testResult.GetString(ref settings);
                    }

                    Output += "<td class=Output bgcolor=" + ColorTranslator.ToHtml(BackColor) + ">" + ResultString + "</td>";

                    // thumbnails
                    if (bThumbnails)
                    {
                        Output += "<td class=Output>";

                        if (test != null)
                        {
                            Output += "<img src=\"" + ThumbnailTest + "\" width=" + test.ThumbnailTest.Width + " height=" + test.ThumbnailTest.Height + ">";

                            if (bShowDiffAndRefThumbnails)
                            {
                                Output += "<img src=\"" + ThumbnailDiff + "\" width=" + test.ThumbnailDiff.Width + " height=" + test.ThumbnailDiff.Height + ">";
                                Output += "<img src=\"" + ThumbnailRef + "\" width=" + test.ThumbnailRef.Width + " height=" + test.ThumbnailRef.Height + ">";
                            }
                        }

                        Output += "</td>";
                    }

                    Output += "<td class=Output>" + columnData.Time + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Actor + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Map + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Platform + "</td>";
                    Output += "<td class=Output>" + Path.GetDirectoryName(entry.Name) + "</td>";
                    Output += "<td class=Output>" + Path.GetFileName(entry.Name) + "</td>";

                    // close table row
                    Output += "</tr>\n";
                    ++Index;
                }
                Output += "</table>\n";
            }

            string SettingsString = "";
            {
                SettingsString +=
                    "<table>\n" +
                    "<tr><td>Test Directory:</td> <td>" + settings.TestDir + "</td></tr>\n" +
                    "<tr><td>Reference Directory:</td> <td>" + settings.RefDir + "</td></tr>\n" +
                    "<tr><td>Threshold (in 0..255 range):</td> <td>" + settings.Threshold + "</td></tr>\n" +
                    "<tr><td>PixelCountToFail:</td> <td>" + settings.PixelCountToFail + "</td></tr>\n" +
                    "</table>\n";
            }

            string SummaryString = "";

            {
                bool bPassed = validationSummary.Failed == 0;

                string FailedColor   = "";
                string SuceededColor = "";

                if (bPassed)
                {
                    SuceededColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(true));
                }
                else
                {
                    FailedColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(false));
                }

                SummaryString +=
                    "<table>\n" +
//                    "<tr><td>Files processed:</td> <td>" + (validationSummary.Failed + validationSummary.Succeeded) + "</td></tr>\n" +
                    "<tr><td" + FailedColor + ">Failed:</td> <td" + FailedColor + ">" + validationSummary.Failed + "</td></tr>\n" +
                    "<tr><td" + SuceededColor + ">Succeeded:</td> <td" + SuceededColor + ">" + validationSummary.Succeeded + "</td></tr>\n" +
                    "</table>\n";
            }

            template = template.Replace("%DATE%", DateTime.Now.ToString());
            template = template.Replace("%SETTINGSFILENAME%", SettingsFileName);

            template = template.Replace("%SETTINGS%", SettingsString);
            template = template.Replace("%SUMMARY%", SummaryString);

            template = template.Replace("%OUTPUT%", Output);
            template = template.Replace("%USER%", Environment.UserName);
            template = template.Replace("%VERSION%", ImageValidatorSettings.GetVersionString());


            System.IO.File.WriteAllText(FileName, template);

            if (!bSilent)
            {
                MessageBox.Show("Export to HTML successful", "ImageValidator", MessageBoxButtons.OK);
            }
        }
示例#26
0
    private void MostrarAfegirPelicula()
    {
        try
        {
            // Definim els TextBox i demes controls per a creació (quasi igual al mode edició, reutilitzem controls i codi)
            fupPortada          = new FileUpload();
            txtTitol            = new TextBox();
            txtDirector         = new TextBox();
            txtAny              = new TextBox();
            txtDuracio          = new TextBox();
            txtPais             = new TextBox();
            txtGuio             = new TextBox();
            txtMusica           = new TextBox();
            txtGenere           = new TextBox();
            txtInterprets       = new TextBox();
            txtTrama            = new TextBox();
            txtEnllaçEnLinia    = new TextBox();
            txtEnllaçDescarrega = new TextBox();
            drdGenere           = new DropDownList();
            rfvTitol            = new RequiredFieldValidator();
            rfvGenere           = new RequiredFieldValidator();
            rnvAny              = new RangeValidator();
            vsAfegirPelicula    = new ValidationSummary();

            // Apliquem una mica d'estils
            txtInterprets.TextMode = TextBoxMode.MultiLine;
            txtTrama.TextMode      = TextBoxMode.MultiLine;

            txtTitol.CssClass            = "camps_afegir_pelicula";
            txtDirector.CssClass         = "camps_afegir_pelicula";
            txtAny.CssClass              = "camps_afegir_pelicula";
            txtDuracio.CssClass          = "camps_afegir_pelicula";
            txtPais.CssClass             = "camps_afegir_pelicula";
            txtGuio.CssClass             = "camps_afegir_pelicula";
            txtMusica.CssClass           = "camps_afegir_pelicula";
            txtGenere.CssClass           = "camps_afegir_pelicula";
            txtInterprets.CssClass       = "camps_afegir_pelicula";
            txtTrama.CssClass            = "camps_afegir_pelicula";
            txtEnllaçEnLinia.CssClass    = "camps_afegir_pelicula";
            txtEnllaçDescarrega.CssClass = "camps_afegir_pelicula";

            // Validacio
            vsAfegirPelicula.ValidationGroup = "vgAfegirPelicula";

            // Validar que el nom de la pelicula no estigui vuit
            rfvTitol.ErrorMessage    = "El titol es requerit";
            rfvTitol.ToolTip         = "El titol es requerit";
            rfvTitol.CssClass        = "failureNotification";
            rfvTitol.SetFocusOnError = true;
            rfvTitol.ValidationGroup = "vgAfegirPelicula";
            txtTitol.ID = "txtTitol";
            rfvTitol.ControlToValidate = txtTitol.ID;

            // Validar rang de valors del any
            rnvAny.ErrorMessage    = "Any erroni. Nomes es prermet des del 1895 fins l'any actual";
            rnvAny.ToolTip         = "Any erroni. Nomes es prermet des del 1895 fins l'any actual";
            rnvAny.CssClass        = "failureNotification";
            rnvAny.MinimumValue    = "1895";
            rnvAny.MaximumValue    = Convert.ToString(DateTime.Now.Year);
            rnvAny.Type            = ValidationDataType.Integer;
            rnvAny.SetFocusOnError = true;
            rnvAny.ValidationGroup = "vgAfegirPelicula";
            txtAny.ID = "txtAny";
            rnvAny.ControlToValidate = txtAny.ID;

            // Validar que el gènere estigui seleccionat
            rfvGenere.ErrorMessage    = "El gènere es requerit";
            rfvGenere.ToolTip         = "El gènere es requerit";
            rfvGenere.CssClass        = "failureNotification";
            rfvGenere.SetFocusOnError = true;
            rfvGenere.ValidationGroup = "vgAfegirPelicula";
            drdGenere.ID = "drdGenere";
            rfvGenere.ControlToValidate = drdGenere.ID;
            rfvGenere.InitialValue      = "0";

            drdGenere.Items.Add(new ListItem("Selecciona", "0"));
            drdGenere.Items.Add(new ListItem("Ciencia Ficció", "1"));
            drdGenere.Items.Add(new ListItem("Drama", "2"));
            drdGenere.Items.Add(new ListItem("Terror", "3"));
            drdGenere.Items.Add(new ListItem("Thriller", "4"));
            drdGenere.Items.Add(new ListItem("Policiac", "5"));
            drdGenere.Items.Add(new ListItem("Eròtic", "6"));
            drdGenere.Items.Add(new ListItem("X", "7"));
            drdGenere.Items.Add(new ListItem("Acció", "8"));
            drdGenere.Items.Add(new ListItem("Comèdia", "9"));
            drdGenere.Items.Add(new ListItem("Humor", "10"));
            drdGenere.Items.Add(new ListItem("Cine Negre", "11"));
            drdGenere.Items.Add(new ListItem("Gore", "12"));
            drdGenere.Items.Add(new ListItem("Musical", "13"));
            drdGenere.Items.Add(new ListItem("Sèrie B", "14"));
            drdGenere.Items.Add(new ListItem("Documental", "15"));
            drdGenere.Items.Add(new ListItem("Bèlic", "16"));
            drdGenere.Items.Add(new ListItem("Western", "17"));

            // els afegim al placeholder, juntament amb totes les etiquetes html necessaries
            phPelicula.Controls.Add(new LiteralControl("<div id=\"pelicula_mode_creacio\"><h2>Afegir nova pel·licula</h2><ul><li><h3>Portada:</h3>"));
            phPelicula.Controls.Add(fupPortada);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Titol:</h3>"));
            phPelicula.Controls.Add(txtTitol);
            phPelicula.Controls.Add(new LiteralControl("<br />"));
            phPelicula.Controls.Add(rfvTitol);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Director:</h3>"));
            phPelicula.Controls.Add(txtDirector);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Any:</h3>"));
            phPelicula.Controls.Add(txtAny);
            phPelicula.Controls.Add(new LiteralControl("<br />"));
            phPelicula.Controls.Add(rnvAny);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Duració:</h3>"));
            phPelicula.Controls.Add(txtDuracio);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>País:</h3>"));
            phPelicula.Controls.Add(txtPais);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Guio:</h3>"));
            phPelicula.Controls.Add(txtGuio);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Música:</h3>"));
            phPelicula.Controls.Add(txtMusica);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Gènere:</h3>"));
            phPelicula.Controls.Add(drdGenere);
            phPelicula.Controls.Add(new LiteralControl("<br />"));
            phPelicula.Controls.Add(rfvGenere);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Interprets:</h3>"));
            phPelicula.Controls.Add(txtInterprets);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Trama:</h3>"));
            phPelicula.Controls.Add(txtTrama);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Veure en linia:</h3>"));
            phPelicula.Controls.Add(txtEnllaçEnLinia);
            phPelicula.Controls.Add(new LiteralControl("</li><li><h3>Descarregar:</h3>"));
            phPelicula.Controls.Add(txtEnllaçDescarrega);
            phPelicula.Controls.Add(new LiteralControl("</li><ul></div><!-- fi pelicula_mode_creacio -->"));

            // Afegim el boto finalitzar i l'associem a l'esdeveniment corresponent
            btnAfegirPelicula                 = new Button();
            btnAfegirPelicula.Text            = "Crear";
            btnAfegirPelicula.CssClass        = "btn_afegir_pelicula";
            btnAfegirPelicula.ValidationGroup = "vgAfegirPelicula";
            btnAfegirPelicula.Click          += new EventHandler(this.btnAfegirPelicula_Click);
            phPelicula.Controls.Add(btnAfegirPelicula);

            // Afegim el boto cancelar i l'associem a l'esdeveniment corresponent
            btnCancelarCrearPelicula          = new Button();
            btnCancelarCrearPelicula.Text     = "Cancelar";
            btnCancelarCrearPelicula.CssClass = "btn_afegir_pelicula";
            btnCancelarCrearPelicula.Click   += new EventHandler(this.btnCancelarAfegirPelicula_Click);
            phPelicula.Controls.Add(btnCancelarCrearPelicula);
        }
        catch (Exception ex)
        {
            phPelicula.Controls.Add(new LiteralControl("<div id=\"error_afegir_pelicula\"><p>Error a l'afegir pelicula. Missatge d'error: " + ex.Message + "</p></div><!-- fi error_afegir_pelicula -->"));
        }
    }
        public async Task ProcessAsync_GeneratesValidationSummaryWhenNotNone(ValidationSummary validationSummary)
        {
            // Arrange
            var tagBuilder = new TagBuilder("span2");
            tagBuilder.InnerHtml.SetHtmlContent("New HTML");

            var generator = new Mock<IHtmlGenerator>();
            generator
                .Setup(mock => mock.GenerateValidationSummary(
                    It.IsAny<ViewContext>(),
                    It.IsAny<bool>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<object>()))
                .Returns(tagBuilder)
                .Verifiable();

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator.Object)
            {
                ValidationSummary = validationSummary,
            };

            var expectedPreContent = "original pre-content";
            var expectedContent = "original content";
            var output = new TagHelperOutput(
                tagName: "div",
                attributes: new TagHelperAttributeList(),
                getChildContentAsync: (_) => Task.FromResult<TagHelperContent>(new DefaultTagHelperContent()));
            output.PreContent.SetContent(expectedPreContent);
            output.Content.SetContent(expectedContent);
            output.PostContent.SetContent("Content of validation message");

            var viewContext = CreateViewContext();
            validationSummaryTagHelper.ViewContext = viewContext;

            var context = new TagHelperContext(
                allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
                    Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
                items: new Dictionary<object, object>(),
                uniqueId: "test");

            // Act
            await validationSummaryTagHelper.ProcessAsync(context, output);

            // Assert
            Assert.Equal("div", output.TagName);
            Assert.Empty(output.Attributes);
            Assert.Equal(expectedPreContent, output.PreContent.GetContent());
            Assert.Equal(expectedContent, output.Content.GetContent());
            Assert.Equal("Content of validation messageNew HTML", output.PostContent.GetContent());
            generator.Verify();
        }
        public void ExportHTML(string SettingsFileName, ref ImageValidatorData data, ref ImageValidatorSettings settings, string FileName, bool bSilent, bool bThumbnails)
        {
            ValidationSummary validationSummary = new ValidationSummary(ref data, ref settings);

            string Folder = Path.GetDirectoryName(FileName) + "\\" + Path.GetFileNameWithoutExtension(FileName) + "_Thumbnails";

            if (bThumbnails)
            {
                Directory.CreateDirectory(Folder);
            }

            // Note C# string literals can span multiple lines, " need to be converted to ""
            string template = @"
<!DOCTYPE HTML PUBLIC \""-//W3C//DTD HTML 4.01 Transitional//EN\"" \""http://www.w3.org/TR/html4/loose.dtd\"">
<html>
<head>
<title>ImageValidator Report</title>
</head>
<body>
<h1>ImageValidator Report</h1>

<br>
<h4>ImageValidator Settings ""%SETTINGSFILENAME%"":</h4>
<div style=""margin:10px;margin-left:40px"" >%SETTINGS% </div>
<br>

<h4>Summary:</h4>
<div style=""margin:10px;margin-left:40px""> %SUMMARY% </div>
<br>

<h4>Output:</h4>
<div style=""margin:10px;margin-left:40px""> %OUTPUT% </div>
<br>

<br>
<b>Generated by Application:</b> ImageValidator.exe (part of UnrealEngine by Epic Games)<br>
<b>Application Version:</b> %VERSION%<br>
<b>Generated by User:</b> %USER%<br>
<b>Generated Date:</b> %DATE%<br>

<style type=""text/css"">
//body { background-color:#000000; color:#E0E0E0 }

* {
    font-family: ?Times New Roman?, Times, serif;
 //   font-weight: bold;
    
}

h1 { color:#555555; font-size:32px; border-bottom:solid thin black; }

table, hd, th {
    border:0px; color:#000000; padding:4px; border-spacing:0px;
    border-collapse:collapse;
    }
   
td { padding:2px; padding-right:7px }
td.Output { padding:7px; border:1px solid #cccccc; }

th {
    background-color:#E0E0E0;
    color: #000000;
    text-align: left;
    border: 1px solid #c0c0c0;
}

a.prefix {
    border: 0px solid;
    padding: 3px;
    padding-left: 5px;
    padding-right: 5px;
    font-weight: bold;
    text-decoration:none;
    margin:4px;
    white-space: nowrap;
}

a.prefix:link {
    border:1px solid #7777FF;
    background-color:#ddddff;
    color: #7777FF;
}


a.prefix:hover {
    background-color:#7777FF;
    color: #ddddff;
}

</style>
    
</body>
</html>";

            // we can change this if needed:
            //ImageFormat imageFormat = ImageFormat.Jpeg;   // small file size?
            //ImageFormat imageFormat = ImageFormat.Gif;   // dither artifacts
            ImageFormat imageFormat = ImageFormat.Png;    // good compromise

            // we derive the extension from imageFormat e.g. ".jpg"
            string imageFormatExtension = "";
            {
                if (imageFormat == ImageFormat.Jpeg)
                {
                    imageFormatExtension = ".jpg";
                }
                else if (imageFormat == ImageFormat.Gif)
                {
                    imageFormatExtension = ".gif";
                }
                else if (imageFormat == ImageFormat.Png)
                {
                    imageFormatExtension = ".Png";
                }

                Debug.Assert(imageFormatExtension != "");
            }

            // todo: how to repro, Date, IVxml file attached?, thumbnails

            string Output = "<table class=Output><tr>";

            Output += "<th>Result (pixels failed)</th>";

            if (bThumbnails)
            {
                Output += "<th>Thumbnails (test/diff/ref)</th>";
            }
            Output += "<th>Matinee Location (in sec)</th>";
            //            Output += "<th>Actor</th>";
            //            Output += "<th>Map</th>";
            //            Output += "<th>Platform</th>";
            Output += "<th>Folder Name</th>";
            Output += "<th>File Name</th></tr>\n";
            {
                uint Index = 0;
                foreach (ImageValidatorData.ImageEntry entry in data.imageEntries)
                {
                    TestResult test = entry.testResult;
                    bool bShowDiffAndRefThumbnails = !test.IsPassed(ref settings);

                    // open table row
                    Output += "<tr class=Output>";

                    Color BackColor = Color.White;

                    string ThumbnailTest = Folder + "\\Test" + Index + imageFormatExtension;
                    string ThumbnailDiff = Folder + "\\Diff" + Index + imageFormatExtension;
                    string ThumbnailRef = Folder + "\\Ref" + Index + imageFormatExtension;

                    if (test != null)
                    {
                        BackColor = test.GetColor(ref settings);

                        if (bThumbnails)
                        {
                            test.ThumbnailTest.Save(ThumbnailTest, imageFormat);

                            if (bShowDiffAndRefThumbnails)
                            {
                                test.ThumbnailDiff.Save(ThumbnailDiff, imageFormat);
                                test.ThumbnailRef.Save(ThumbnailRef, imageFormat);
                            }
                        }
                    }

                    ImageValidatorData.ImageEntryColumnData columnData = new ImageValidatorData.ImageEntryColumnData(entry.Name);

                    string ResultString = "?";

                    if (entry.testResult != null)
                    {
                        ResultString = entry.testResult.GetString(ref settings);
                    }

                    Output += "<td class=Output bgcolor=" + ColorTranslator.ToHtml(BackColor) + ">" + ResultString + "</td>";

                    // thumbnails
                    if (bThumbnails)
                    {
                        Output += "<td class=Output>";

                        if (test != null)
                        {
                            Output += "<img src=\"" + ThumbnailTest + "\" width=" + test.ThumbnailTest.Width + " height=" + test.ThumbnailTest.Height + ">";

                            if (bShowDiffAndRefThumbnails)
                            {
                                Output += "<img src=\"" + ThumbnailDiff + "\" width=" + test.ThumbnailDiff.Width + " height=" + test.ThumbnailDiff.Height + ">";
                                Output += "<img src=\"" + ThumbnailRef + "\" width=" + test.ThumbnailRef.Width + " height=" + test.ThumbnailRef.Height + ">";
                            }
                        }

                        Output += "</td>";
                    }

                    Output += "<td class=Output>" + columnData.Time + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Actor + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Map + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Platform + "</td>";
                    Output += "<td class=Output>" + Path.GetDirectoryName(entry.Name) + "</td>";
                    Output += "<td class=Output>" + Path.GetFileName(entry.Name) + "</td>";

                    // close table row
                    Output += "</tr>\n";
                    ++Index;
                }
                Output += "</table>\n";
            }

            string SettingsString = "";
            {
                SettingsString +=
                    "<table>\n" +
                    "<tr><td>Test Directory:</td> <td>" + settings.TestDir + "</td></tr>\n" +
                    "<tr><td>Reference Directory:</td> <td>" + settings.RefDir + "</td></tr>\n" +
                    "<tr><td>Threshold (in 0..255 range):</td> <td>" + settings.Threshold + "</td></tr>\n" +
                    "<tr><td>PixelCountToFail:</td> <td>" + settings.PixelCountToFail + "</td></tr>\n" +
                    "</table>\n";
            }

            string SummaryString = "";
            {
                bool bPassed = validationSummary.Failed == 0;

                string FailedColor = "";
                string SuceededColor = "";

                if (bPassed)
                {
                    SuceededColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(true));
                }
                else
                {
                    FailedColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(false));
                }
                
                SummaryString +=
                    "<table>\n" +
//                    "<tr><td>Files processed:</td> <td>" + (validationSummary.Failed + validationSummary.Succeeded) + "</td></tr>\n" +
                    "<tr><td" + FailedColor + ">Failed:</td> <td" + FailedColor + ">" + validationSummary.Failed + "</td></tr>\n" +
                    "<tr><td" + SuceededColor + ">Succeeded:</td> <td" + SuceededColor + ">" + validationSummary.Succeeded + "</td></tr>\n" +
                    "</table>\n";
            }

            template = template.Replace("%DATE%", DateTime.Now.ToString());
            template = template.Replace("%SETTINGSFILENAME%", SettingsFileName);

            template = template.Replace("%SETTINGS%", SettingsString);
            template = template.Replace("%SUMMARY%", SummaryString);

            template = template.Replace("%OUTPUT%", Output);
            template = template.Replace("%USER%", Environment.UserName);
            template = template.Replace("%VERSION%", ImageValidatorSettings.GetVersionString());


            System.IO.File.WriteAllText(FileName, template);

            if (!bSilent)
            {
                MessageBox.Show("Export to HTML successful", "ImageValidator", MessageBoxButtons.OK);
            }
        }
        public void ValidationSummaryProperty_ThrowsWhenSetToInvalidValidationSummaryValue(
            ValidationSummary validationSummary)
        {
            // Arrange
            var generator = new TestableHtmlGenerator(new EmptyModelMetadataProvider());

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator);
            var validationTypeName = typeof(ValidationSummary).FullName;
            var expectedMessage =
                $@"The value of argument 'value' ({validationSummary}) is invalid for Enum type '{validationTypeName}'.
Parameter name: value";

            // Act & Assert
            var ex = Assert.Throws<ArgumentException>(
                "value",
                () => { validationSummaryTagHelper.ValidationSummary = validationSummary; });
            Assert.Equal(expectedMessage, ex.Message);
        }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationException"/> class.
 /// </summary>
 /// <param name="summary">The summary.</param>
 public ValidationException(ValidationSummary summary)
     : base(summary.ToString())
 {
     Summary = summary;
 }
示例#31
0
        /// <summary>
        /// Load the controls which will form the user interface.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Set the literal control.
            _literalUpload       = new Literal();
            _literalInstructions = new Literal();

            // Create the required controls.
            _textBoxLicenceKey        = new TextBox();
            _buttonActivate           = new Button();
            _buttonRefresh            = new Button();
            _validatorRequired        = new RequiredFieldValidator();
            _validatorRegEx           = new RegularExpressionValidator();
            _validationLicenceSummary = new ValidationSummary();
            _literalResult            = new Literal();

            // Set the new controls properties.
            _buttonActivate.ID              = "ButtonActivate";
            _buttonActivate.Click          += new EventHandler(_buttonActivate_Click);
            _buttonActivate.ValidationGroup = VALIDATION_LICENCE;
            _buttonRefresh.ID                  = "ButtonRefresh";
            _buttonRefresh.Click              += new EventHandler(_buttonActivate_Click);
            _buttonRefresh.Visible             = false;
            _textBoxLicenceKey.ID              = "TextBoxLicenceKey";
            _textBoxLicenceKey.ValidationGroup = VALIDATION_LICENCE;

            // Set the validators.
            _validatorRequired.ID                 = "ValidatorRequired";
            _validatorRegEx.ID                    = "ValidatorRegEx";
            _validationLicenceSummary.ID          = "ValidationLicenceSummary";
            _validatorRequired.ControlToValidate  = _validatorRegEx.ControlToValidate = _textBoxLicenceKey.ID;
            _validatorRegEx.ValidationGroup       = _validatorRequired.ValidationGroup = VALIDATION_LICENCE;
            _validatorRegEx.ValidationExpression  = FiftyOne.Foundation.Mobile.Detection.Constants.LicenceKeyValidationRegex;
            _validationLicenceSummary.DisplayMode = ValidationSummaryDisplayMode.SingleParagraph;
            _validationLicenceSummary.Style.Clear();
            _validationLicenceSummary.ValidationGroup = VALIDATION_LICENCE;
            _validatorRequired.Display         = _validatorRegEx.Display = ValidatorDisplay.None;
            _validatorRegEx.EnableClientScript = _validatorRequired.EnableClientScript =
                _validationLicenceSummary.EnableClientScript = true;

            // Set the child controls.
            _upload.FooterEnabled          = false;
            _upload.LogoEnabled            = false;
            _upload.UploadComplete        += new UploadEventHandler(_upload_UploadComplete);
            _shareUsage.LogoEnabled        = false;
            _shareUsage.FooterEnabled      = false;
            _shareUsage.ShareUsageChanged += new ShareUsageChangedEventHandler(_shareUsage_ShareUsageChanged);

            // Add the controls to the user control.
            _container.Controls.Add(_literalResult);
            _container.Controls.Add(_validationLicenceSummary);

            _container.Controls.Add(_literalInstructions);

            if (IsPaidFor == false)
            {
                _container.Controls.Add(_validatorRequired);
                _container.Controls.Add(_validatorRegEx);
                _container.Controls.Add(_textBoxLicenceKey);
                _container.Controls.Add(_buttonActivate);
                _container.Controls.Add(_buttonRefresh);
                _container.Controls.Add(_literalUpload);
                _container.Controls.Add(_upload);
            }

            _container.Controls.Add(_shareUsage);
        }
示例#32
0
        protected void rgFont_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.FilteringItem)
            {
                GridFilteringItem fileterItem = (GridFilteringItem)e.Item;
                for (int i = 0; i < fileterItem.Cells.Count; i++)
                {
                    fileterItem.Cells[i].Style.Add("text-align", "left");
                }
            }
            try
            {
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem        item = e.Item as GridEditableItem;
                    RequiredFieldValidator  validator;
                    GridTextBoxColumnEditor editor;
                    if (item != null)
                    {
                        editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("Name");
                        ImageButton       cmdEdit       = (ImageButton)item["Edit"].Controls[0];
                        ValidationSummary validationsum = new ValidationSummary();
                        validationsum.ID             = "validationsum1";
                        validationsum.ShowMessageBox = true;
                        validationsum.ShowSummary    = false;
                        validationsum.DisplayMode    = ValidationSummaryDisplayMode.SingleParagraph;
                        if (editor != null)
                        {
                            TableCell cell = (TableCell)editor.TextBoxControl.Parent;
                            validator = new RequiredFieldValidator();
                            if (cell != null)
                            {
                                editor.TextBoxControl.ID    = "Name";
                                validator.ControlToValidate = editor.TextBoxControl.ID;
                                validator.ErrorMessage      = "Please Enter Name \n";
                                validator.SetFocusOnError   = true;
                                validator.Display           = ValidatorDisplay.None;
                            }

                            cell.Controls.Add(validator);
                            cell.Controls.Add(validationsum);
                        }
                        TextBox txtSize = e.Item.FindControl("txtSize") as TextBox;
                        if (txtSize != null)
                        {
                            TableCell cell = (TableCell)txtSize.Parent;
                            validator = new RequiredFieldValidator();
                            if (cell != null)
                            {
                                txtSize.ID = "txtSize";
                                validator.ControlToValidate = txtSize.ID;
                                validator.ErrorMessage      = "Please Enter Size\n";
                                validator.SetFocusOnError   = true;
                                validator.Display           = ValidatorDisplay.None;
                            }

                            cell.Controls.Add(validator);
                            cell.Controls.Add(validationsum);
                        }
                        //RadColorPicker rcpColor = e.Item.FindControl("rcpColor") as RadColorPicker;
                        //if (rcpColor != null)
                        //{
                        //    TableCell cell = (TableCell)rcpColor.Parent;
                        //    validator = new RequiredFieldValidator();
                        //    if (cell != null)
                        //    {
                        //        rcpColor.ID = "rcpColor";
                        //        validator.ControlToValidate = rcpColor.ID;
                        //        validator.ErrorMessage = "Please enter size of Font\n";
                        //        validator.InitialValue = "0";
                        //        validator.SetFocusOnError = true;
                        //        validator.Display = ValidatorDisplay.None;
                        //    }

                        //    cell.Controls.Add(validator);
                        //    cell.Controls.Add(validationsum);

                        //}
                    }
                }
            }
            catch
            {
            }
        }
        public void ValidationSummaryProperty_ThrowsWhenSetToInvalidValidationSummaryValue(
            ValidationSummary validationSummary)
        {
            // Arrange
            var generator = new TestableHtmlGenerator(new EmptyModelMetadataProvider());

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator);
            var expectedMessage = string.Format(
                @"The value of argument 'value' ({0}) is invalid for Enum type 'Microsoft.AspNet.Mvc.ValidationSummary'.
Parameter name: value",
                validationSummary);

            // Act & Assert
            var ex = Assert.Throws<ArgumentException>(
                "value",
                () => { validationSummaryTagHelper.ValidationSummary = validationSummary; });
            Assert.Equal(expectedMessage, ex.Message);
        }
 public ValidationSummary Summary(ValidationSummary summary)
 {
     return new ValidationSummary();
 }
    public void CreatetplRowEdit(Object sender, Obout.Grid.GridRuntimeTemplateEventArgs e)
	{
        PlaceHolder ph1 = new PlaceHolder();
        e.Container.Controls.Add(ph1);
	
        Literal inputText = new Literal();
        inputText.Text = "<input type=\"hidden\" id=\"OrderID\" />";
       
        ValidationSummary validateGroup1 = new ValidationSummary();
        validateGroup1.ID = "ValidationSummary1";
        validateGroup1.ValidationGroup = "Group1";

        ph1.Controls.Add(inputText);
        ph1.Controls.Add(validateGroup1);

        SuperForm1 = new SuperForm();
        SuperForm1.ID = "SuperForm1";
        SuperForm1.AutoGenerateRows = false;
        SuperForm1.AutoGenerateInsertButton = false;
        SuperForm1.AutoGenerateEditButton = false;
        SuperForm1.AutoGenerateDeleteButton = false;
        SuperForm1.ValidationGroup = "Group1";
        SuperForm1.Width = Unit.Percentage(99);
        SuperForm1.DataKeyNames = new string[] { "Order ID" };
        SuperForm1.DefaultMode = DetailsViewMode.Insert;

        RequiredFieldValidator requiredFieldValidator1 = new RequiredFieldValidator();
        requiredFieldValidator1.ID = "RequiredFieldValidator1";
        requiredFieldValidator1.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator1.ErrorMessage = "Ship Name is mandatory";
        requiredFieldValidator1.Text = "*";
        requiredFieldValidator1.ValidationGroup = "Group1";

        RequiredFieldValidator requiredFieldValidator2 = new RequiredFieldValidator();
        requiredFieldValidator2.ID = "RequiredFieldValidator2";
        requiredFieldValidator2.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator2.ErrorMessage = "Ship Address is mandatory";
        requiredFieldValidator2.Text = "*";
        requiredFieldValidator2.ValidationGroup = "Group1";

        RequiredFieldValidator requiredFieldValidator3 = new RequiredFieldValidator();
        requiredFieldValidator3.ID = "RequiredFieldValidator3";
        requiredFieldValidator3.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator3.ErrorMessage = "Ship City is mandatory";
        requiredFieldValidator3.Text = "*";
        requiredFieldValidator3.ValidationGroup = "Group1";

        RequiredFieldValidator requiredFieldValidator4 = new RequiredFieldValidator();
        requiredFieldValidator4.ID = "RequiredFieldValidator4";
        requiredFieldValidator4.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator4.ErrorMessage = "Ship Country is mandatory";
        requiredFieldValidator4.Text = "*";
        requiredFieldValidator4.ValidationGroup = "Group1";

        RequiredFieldValidator requiredFieldValidator5 = new RequiredFieldValidator();
        requiredFieldValidator5.ID = "RequiredFieldValidator5";
        requiredFieldValidator5.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator5.ErrorMessage = "Order Date is mandatory";
        requiredFieldValidator5.Text = "*";
        requiredFieldValidator5.ValidationGroup = "Group1";

        RangeValidator rangeValidator1 = new RangeValidator();
        rangeValidator1.ID="RangeValidator1";
        rangeValidator1.Display = ValidatorDisplay.Dynamic; 
        rangeValidator1.MinimumValue = "1900/1/1";
        rangeValidator1.MaximumValue = "2039/12/31";
        rangeValidator1.Type = ValidationDataType.Date;
        rangeValidator1.ErrorMessage = "Order Date needs to be in this format: mm/dd/yyyy";
        rangeValidator1.Text = "*";
        rangeValidator1.ValidationGroup = "Group1";

        RequiredFieldValidator requiredFieldValidator6 = new RequiredFieldValidator();
        requiredFieldValidator6.ID = "RequiredFieldValidator6";
        requiredFieldValidator6.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator6.ErrorMessage = "Required Date is mandatory";
        requiredFieldValidator6.Text = "*";
        requiredFieldValidator6.ValidationGroup = "Group1";

        RangeValidator rangeValidator2 = new RangeValidator();
        rangeValidator2.ID="RangeValidator2";
        rangeValidator2.Display = ValidatorDisplay.Dynamic; 
        rangeValidator2.MinimumValue = "1900/1/1";
        rangeValidator2.MaximumValue = "2039/12/31";
        rangeValidator2.Type = ValidationDataType.Date;
        rangeValidator2.ErrorMessage = "Required Date needs to be in this format: mm/dd/yyyy";
        rangeValidator2.Text = "*";
        rangeValidator2.ValidationGroup = "Group1";

        RequiredFieldValidator requiredFieldValidator7 = new RequiredFieldValidator();
        requiredFieldValidator7.ID = "RequiredFieldValidator7";
        requiredFieldValidator7.Display = ValidatorDisplay.Dynamic;
        requiredFieldValidator7.ErrorMessage = "Shipped Date is mandatory";
        requiredFieldValidator7.Text = "*";
        requiredFieldValidator7.ValidationGroup = "Group1";

        RangeValidator rangeValidator3 = new RangeValidator();
        rangeValidator3.ID = "RangeValidator3";
        rangeValidator3.Display = ValidatorDisplay.Dynamic;
        rangeValidator3.MinimumValue = "1900/1/1";
        rangeValidator3.MaximumValue = "2039/12/31";
        rangeValidator3.Type = ValidationDataType.Date;
        rangeValidator3.ErrorMessage = "Shipped Date needs to be in this format: mm/dd/yyyy";
        rangeValidator3.Text = "*";
        rangeValidator3.ValidationGroup = "Group1";
        
        Obout.SuperForm.BoundField field1 = new Obout.SuperForm.BoundField();
        field1.DataField = "ShipName";
        field1.HeaderText = "Ship Name";
        field1.FieldSetID = "FieldSet1";
        field1.Validators.Add(requiredFieldValidator1);

        Obout.SuperForm.BoundField field2 = new Obout.SuperForm.BoundField();
        field2.DataField = "ShipAddress";
        field2.HeaderText = "Ship Address";
        field2.FieldSetID = "FieldSet1";
        field2.Validators.Add(requiredFieldValidator2);

        Obout.SuperForm.BoundField field3 = new Obout.SuperForm.BoundField();
        field3.DataField = "ShipCity";
        field3.HeaderText = "Ship City";
        field3.FieldSetID = "FieldSet1";
        field3.Validators.Add(requiredFieldValidator3);
      
        Obout.SuperForm.BoundField field4 = new Obout.SuperForm.BoundField();
        field4.DataField = "ShipRegion";
        field4.HeaderText = "Ship Region";
        field4.FieldSetID = "FieldSet1";

        Obout.SuperForm.BoundField field5 = new Obout.SuperForm.BoundField();
        field5.DataField = "ShipPostalCode";
        field5.HeaderText = "Zip Cod";
        field5.FieldSetID = "FieldSet1";

        Obout.SuperForm.DropDownListField field6 = new Obout.SuperForm.DropDownListField();
        field6.DataField = "ShipCountry";
        field6.HeaderText = "Ship Country";
        field6.FieldSetID = "FieldSet1";
        field6.DataSourceID = "SqlDataSource3";
        field6.Validators.Add(requiredFieldValidator4);

        Obout.SuperForm.DateField field7 = new Obout.SuperForm.DateField();
        field7.DataField = "OrderDate";
        field7.HeaderText = "Order Date";
        field7.FieldSetID = "FieldSet2";
        field7.DataFormatString = "{0:MM/dd/yyyy}";
        field7.ApplyFormatInEditMode = true;
        field7.Validators.Add(requiredFieldValidator5);
        field7.Validators.Add(rangeValidator1);

        Obout.SuperForm.DateField field8 = new Obout.SuperForm.DateField();
        field8.DataField = "RequiredDate";
        field8.HeaderText = "Required Date";
        field8.FieldSetID = "FieldSet2";
        field8.DataFormatString = "{0:MM/dd/yyyy}";
        field8.ApplyFormatInEditMode = true;
        field8.Validators.Add(requiredFieldValidator6);
        field8.Validators.Add(rangeValidator2);

        Obout.SuperForm.DateField field9 = new Obout.SuperForm.DateField();
        field9.DataField = "ShippedDate";
        field9.HeaderText = "Shipped Date";
        field9.FieldSetID = "FieldSet2";
        field9.DataFormatString = "{0:MM/dd/yyyy}";
        field9.ApplyFormatInEditMode = true;
        field9.Validators.Add(requiredFieldValidator7);
        field9.Validators.Add(rangeValidator3);

        Obout.SuperForm.BoundField field10 = new Obout.SuperForm.BoundField();
        field10.DataField = "ShipVia";
        field10.HeaderText = "Ship Via";
        field10.FieldSetID = "FieldSet2";

        Obout.SuperForm.CheckBoxField field11 = new Obout.SuperForm.CheckBoxField();
        field11.DataField = "Sent";
        field11.HeaderText = "Sent";
        field11.FieldSetID = "FieldSet2";

        Obout.SuperForm.MultiLineField field12 = new Obout.SuperForm.MultiLineField();
        field12.DataField = "AdditionalInformation";
        field12.HeaderText = "";
        field12.FieldSetID = "FieldSet3";
        field12.HeaderStyle.Width = 1;

        Obout.SuperForm.TemplateField field13 = new Obout.SuperForm.TemplateField();
        field13.FieldSetID = "FieldSet4";
        field13.EditItemTemplate = new btnUpdateEditItemTemplate();
        
        Obout.SuperForm.FieldSetRow fieldSetRow1 = new Obout.SuperForm.FieldSetRow();
        Obout.SuperForm.FieldSet fieldSet1 = new Obout.SuperForm.FieldSet();
        fieldSet1.ID = "FieldSet1";
        fieldSet1.Title = "Ship Information";
        fieldSetRow1.Items.Add(fieldSet1);

        Obout.SuperForm.FieldSet fieldSet2 = new Obout.SuperForm.FieldSet();
        fieldSet2.ID = "FieldSet2";
        fieldSet2.Title = "Order Information";
        fieldSetRow1.Items.Add(fieldSet2);

        Obout.SuperForm.FieldSet fieldSet3 = new Obout.SuperForm.FieldSet();
        fieldSet3.ID = "FieldSet3";
        fieldSet3.Title = "Additional Information";
        fieldSetRow1.Items.Add(fieldSet3);

        Obout.SuperForm.FieldSetRow fieldSetRow2 = new Obout.SuperForm.FieldSetRow();
        Obout.SuperForm.FieldSet fieldSet4 = new Obout.SuperForm.FieldSet();
        fieldSet4.ID = "FieldSet4";
        fieldSet4.ColumnSpan = 3;
        fieldSet4.CssClass = "command-row";
        fieldSetRow2.Items.Add(fieldSet4);
       
        SuperForm1.FieldSets.Add(fieldSetRow1);
        SuperForm1.FieldSets.Add(fieldSetRow2);
       
        SuperForm1.Fields.Add(field1);
        SuperForm1.Fields.Add(field2);
        SuperForm1.Fields.Add(field3);
        SuperForm1.Fields.Add(field4);
        SuperForm1.Fields.Add(field5);
        SuperForm1.Fields.Add(field6);
        SuperForm1.Fields.Add(field7);
        SuperForm1.Fields.Add(field8);
        SuperForm1.Fields.Add(field9);
        SuperForm1.Fields.Add(field10);
        SuperForm1.Fields.Add(field11);
        SuperForm1.Fields.Add(field12);
        SuperForm1.Fields.Add(field13);

        
        ph1.Controls.Add(SuperForm1);

    }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationSummaryAutomationPeer" /> class.
 /// </summary>
 /// <param name="owner">
 /// The <see cref="ValidationSummary" /> that is associated with this <see cref="ValidationSummaryAutomationPeer" />.
 /// </param>
 public ValidationSummaryAutomationPeer(ValidationSummary owner) : base(owner)
 {
 }
        public async Task ProcessAsync_GeneratesValidationSummaryWhenNotNone(ValidationSummary validationSummary)
        {
            // Arrange
            var tagBuilder = new TagBuilder("span2");
            tagBuilder.InnerHtml.SetContentEncoded("New HTML");

            var generator = new Mock<IHtmlGenerator>();
            generator
                .Setup(mock => mock.GenerateValidationSummary(
                    It.IsAny<ViewContext>(),
                    It.IsAny<bool>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<object>()))
                .Returns(tagBuilder)
                .Verifiable();

            var validationSummaryTagHelper = new ValidationSummaryTagHelper(generator.Object)
            {
                ValidationSummary = validationSummary,
            };

            var expectedPreContent = "original pre-content";
            var expectedContent = "original content";
            var output = new TagHelperOutput(
                "div",
                attributes: new TagHelperAttributeList());
            output.PreContent.SetContent(expectedPreContent);
            output.Content.SetContent(expectedContent);
            output.PostContent.SetContent("Content of validation message");

            var viewContext = CreateViewContext();
            validationSummaryTagHelper.ViewContext = viewContext;

            // Act
            await validationSummaryTagHelper.ProcessAsync(context: null, output: output);

            // Assert
            Assert.Equal("div", output.TagName);
            Assert.Empty(output.Attributes);
            Assert.Equal(expectedPreContent, output.PreContent.GetContent());
            Assert.Equal(expectedContent, output.Content.GetContent());
            Assert.Equal("Content of validation messageNew HTML", output.PostContent.GetContent());
            generator.Verify();
        }
示例#38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationException"/> class.
 /// </summary>
 /// <param name="summary">The summary.</param>
 /// <param name="innerException">The inner exception.</param>
 public ValidationException(ValidationSummary summary, Exception innerException)
     : base(summary.ToString(), innerException)
 {
     Summary = summary;
 }
示例#39
0
 internal static string FormatInvalidEnumArgument(string s0, ValidationSummary s1, string s2) => string.Format("The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.", s0, s1, s2);
 public ValidationFailedException(ValidationSummary ValidationSummary)
 {
     this.ValidationSummary = ValidationSummary;
 }