Beispiel #1
0
        private TableNode VerifyHeader(bool expected, bool filterRow = false)
        {
            TableNode headerRow = null;
            TableNode header    = this.Node("thead");

            if (expected)
            {
                header.Should().NotBeNull();
                header.InnerContent.Should().HaveCount(filterRow ? 2 : 1);
                headerRow = header.InnerContent.First();
                headerRow.Element.TagName.Should().Be("tr");
                headerRow.InnerContent.Should().HaveCount(3);
                headerRow.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(s => s == "th");
                if (filterRow)
                {
                    headerRow = header.InnerContent.Last();
                    headerRow.Element.TagName.Should().Be("tr");
                    headerRow.InnerContent.Should().HaveCount(3);
                    headerRow.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(s => s == "td");
                }
            }
            else
            {
                header.Should().BeNull();
            }

            return(headerRow);
        }
Beispiel #2
0
        public void ColumnHeaders(bool anyConfigured)
        {
            _tableConfig.Columns.Add("Property", new ColumnConfig
            {
                Header = anyConfigured ? "Header1" : ""
            });
            _tableConfig.Columns.Add("Property2", new ColumnConfig
            {
                Header = anyConfigured ? "Header2" : null
            });
            _tableConfig.Columns.Add("Property3", new ColumnConfig());
            _tableConfig.Columns["Property2"].CssClasses.Add("CssClass1");
            _tableConfig.Columns["Property2"].CssClasses.Add("CssClass2");

            this.ActAndValidate();

            TableNode header = this.Node("thead");

            if (anyConfigured)
            {
                header.Should().NotBeNull();
                header.InnerContent.Should().HaveCount(1);
                TableNode headerRow = header.InnerContent.First();
                headerRow.Element.TagName.Should().Be("tr");
                headerRow.InnerContent.Should().HaveCount(3);
                headerRow.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(s => s == "th");
                this.VerifyInnerHtml(headerRow.InnerContent.ElementAt(0).Element, "Header1");
                this.VerifyInnerHtml(headerRow.InnerContent.ElementAt(1).Element, "Header2");
                this.VerifyInnerHtml(headerRow.InnerContent.ElementAt(2).Element, "");
            }
            else
            {
                header.Should().BeNull();
            }
        }
Beispiel #3
0
        public void Caption(bool caption)
        {
            _tableConfig.Caption = caption ? "Caption" : null;

            this.ActAndValidate();

            TableNode table = this.Node("table");

            if (caption)
            {
                TableNode captionNode = table.InnerContent.SingleOrDefault(n => n.Element.TagName == "caption");

                captionNode.Should().NotBeNull();
                this.VerifyInnerHtml(captionNode.Element, "Caption");
            }
            else
            {
                table.InnerContent.Any(n => n.Element.TagName == "caption").Should().BeFalse();
            }
        }
Beispiel #4
0
        public void FooterElements(bool text, bool css, bool paging, bool multiplePages, bool pageInfo,
                                   bool directPageAccess)
        {
            FooterConfig config = new FooterConfig
            {
                Text  = text ? "Text" : null,
                State = css ? ContextualState.Danger : ContextualState.Default,
            };

            if (css)
            {
                config.CssClasses.Add("Css1");
                config.CssClasses.Add("Css2");
            }
            _tableConfig.Footer.Returns(config);
            _tableConfig.Paging.Returns(new PagingConfig
            {
                PageSize = paging ? 2 : 0, DirectPageAccess = directPageAccess, PageInfo = pageInfo,
            });

            this.ActAndValidate(multiplePages ? 5 : 2);

            TableNode footer = this.Node("tfoot");

            if (text || (paging && (multiplePages || pageInfo)))
            {
                IEnumerable <string> cssClasses = css
                    ? config.CssClasses.Concat(new [] { "danger" })
                    : Enumerable.Empty <string>();
                List <Action <TableNode> > verifyActions = new List <Action <TableNode> >();

                footer.Should().NotBeNull();
                TableNode footerRow  = this.OnlyInner(footer, "tr");
                TableNode footerCell = this.OnlyInner(footerRow, "td");
                this.VerifyCssClasses(footerCell.Element, cssClasses);
                this.VerifyAttribute(footerCell.Element, "colspan", "3");

                if (pageInfo)
                {
                    verifyActions.Add(this.VerifyFooterPageInfo);
                }
                if (paging && multiplePages)
                {
                    if (directPageAccess)
                    {
                        verifyActions.Add(this.VerifyFooterDirectPageAccess);
                    }
                    verifyActions.Add(this.VerifyFooterNavLast);
                    verifyActions.Add(this.VerifyFooterNavNext);
                    verifyActions.Add(this.VerifyFooterNavPrev);
                    verifyActions.Add(this.VerifyFooterNavFirst);
                }
                if (text)
                {
                    verifyActions.Add(this.VerifyFooterText);
                }
                footerCell.InnerContent.Should().HaveSameCount(verifyActions);
                for (int i = 0; i < verifyActions.Count; i++)
                {
                    verifyActions[i](footerCell.InnerContent[i]);
                }
            }
            else
            {
                footer.Should().BeNull();
            }
        }
Beispiel #5
0
        public void Rows(bool values, bool rowClick, bool globalRowClick)
        {
            TableEntity entity = new TableEntity
            {
                Property = "Value1", Property2 = values ? "Value2" : null, Property3 = 123,
            };
            RowConfig <TableEntity> row = new RowConfig <TableEntity>(entity)
            {
                State         = values ? ContextualState.Danger : ContextualState.Default,
                NavigationUrl = values ? "NavUrl" : null,
                RowClick      = rowClick ? "RowClick" : null,
            };

            if (values)
            {
                row.CssClasses.Add("C1");
                row.CssClasses.Add("C2");
                row.CellConfigs.Add("Property", new CellConfig {
                    State = ContextualState.Warning
                });
                row.CellConfigs.ElementAt(0).Value.CssClasses.Add("Css1");
                row.CellConfigs.ElementAt(0).Value.CssClasses.Add("Css2");
            }
            _tableConfig.RowClick.Returns(globalRowClick ? "GlobalRowClick" : null);
            _tableConfig.Rows.Returns(new[]
            {
                new RowConfig <TableEntity>(new TableEntity()),
                row,
                new RowConfig <TableEntity>(new TableEntity()),
            });

            this.ActAndValidate();

            TableNode body = this.Node("tbody");

            body.Should().NotBeNull();
            body.InnerContent.Should().HaveCount(3);
            body.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(tn => tn == "tr");
            for (int i = 0; i < body.InnerContent.Count; i++)
            {
                TableNode     rowNode    = body.InnerContent.ElementAt(i);
                List <string> cssClasses = new List <string>(_tableConfig.Rows.ElementAt(i).CssClasses);
                bool          rowValues  = i == 1 && values;

                if (rowValues)
                {
                    cssClasses.Add("danger");
                }
                this.VerifyCssClasses(rowNode.Element, cssClasses);
                this.VerifyAttribute(rowNode.Element, "style", rowValues || (i == 1 && rowClick) || globalRowClick
                    ? "cursor: pointer" : null);
                if (rowValues)
                {
                    this.VerifyAttribute(rowNode.Element, "onclick", "window.location.href = 'NavUrl'");
                }
                else if (i == 1 && rowClick)
                {
                    this.VerifyAttribute(rowNode.Element, "onclick", "RowClick");
                }
                else if (globalRowClick)
                {
                    this.VerifyAttribute(rowNode.Element, "onclick", "GlobalRowClick(this)");
                }
                else
                {
                    this.VerifyAttribute(rowNode.Element, "onclick");
                }

                rowNode.InnerContent.Should().HaveCount(3);
                rowNode.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(tn => tn == "td");
                if (i == 1)
                {
                    this.VerifyInnerHtml(rowNode.InnerContent.ElementAt(0).Element, entity.Property);
                    this.VerifyInnerHtml(rowNode.InnerContent.ElementAt(1).Element,
                                         values ? entity.Property2 : string.Empty);
                    this.VerifyInnerHtml(rowNode.InnerContent.ElementAt(2).Element,
                                         entity.Property3.ToString());

                    this.VerifyCssClasses(rowNode.InnerContent.ElementAt(0).Element,
                                          values ? new[] { "warning", "Css1", "Css2" } : Enumerable.Empty <string>());
                    this.VerifyCssClasses(rowNode.InnerContent.ElementAt(1).Element, Enumerable.Empty <string>());
                    this.VerifyCssClasses(rowNode.InnerContent.ElementAt(2).Element, Enumerable.Empty <string>());
                }
            }
        }