Beispiel #1
0
        private bool AttributesAreEqual(INamedNodeMap attributeMapX, INamedNodeMap attributeMapY)
        {
            if (_options.IgnoreAdditionalAttributes)
            {
                if (attributeMapX.Length > attributeMapY.Length)
                {
                    return(false);
                }
            }
            else if (attributeMapX.Length != attributeMapY.Length)
            {
                return(false);
            }

            foreach (var attributeX in attributeMapX)
            {
                // Id & Class are handled separately
                if (attributeX.Name == ClassAttributeName || attributeX.Name == IdAttributeName)
                {
                    continue;
                }

                var attributeY = attributeMapY.GetNamedItem(attributeX.NamespaceUri, attributeX.Name);
                if (attributeY == null || !_options.AttributeComparer.Equals(attributeX.Value, attributeY.Value))
                {
                    return(false);
                }
            }

            return(true);
        }
        public async Task BeClosedByDefault()
        {
            // Arrange
            IRenderedComponent <BfTreeView> cut = RenderComponent <BfTreeView>(
                p => p.AddChildContent <BfTreeItem>()
                );

            // Assert
            INamedNodeMap attrs = cut.Find(BfComponentApis.BfTreeItem.Html.BfTreeItem).Attributes;

            attrs.GetNamedItem(BfComponentApis.BfTreeItem.Attributes.Expanded)
            .Should().BeNull();
        }
        public async Task BeOpenWhenConfiguredSo()
        {
            // Arrange
            IRenderedComponent <BfTreeView> cut = RenderComponent <BfTreeView>(
                p => p.AddChildContent <BfTreeItem>(
                    pa => { pa.Add(b => b.Expanded, true); })
                );

            // Assert
            INamedNodeMap attrs = cut.Find(BfComponentApis.BfTreeItem.Html.BfTreeItem).Attributes;

            attrs.GetNamedItem(BfComponentApis.BfTreeItem.Attributes.Expanded)
            .Should().NotBeNull();
        }
        /// <summary>Searches for children that have the given name and attribute</summary>
        protected internal static INode GetChildByNameAndAttribute(INode node, string name, string attributeName, string attributeValue)
        {
            INodeList     children  = node.GetChildNodes();
            INamedNodeMap attribs   = node.GetAttributes();
            INode         attribute = null;

            // this node matches
            if (node.GetNodeName().Equals(name) && attribs != null && (attribute = attribs.GetNamedItem(attributeName)) != null && attribute.GetNodeValue().Equals(attributeValue))
            {
                return(node);
            }
            // search children
            for (int i = 0; i < children.GetLength(); i++)
            {
                INode found = GetChildByAttribute(children.Item(i), attributeName, attributeValue);
                if (found != null)
                {
                    return(found);
                }
            }
            // failed
            return(null);
        }