Exemplo n.º 1
0
        public void TestSetup()
        {
            dom = (body = new TestNode(null, "body",
                                       new[] { (section = new TestNode(null, "section", new[]
                {
                    (div = new TestNode(null, "div", new[]
                    {
                        (label1 = new TestNode(null, "label")),
                        (label2 = new TestNode(null, "label", null, null, "label2")),
                        (label3 = new TestNode(null, "label", null, null, null, "required")),
                        (grid = new TestNode(null, "Grid", null, null, null))
                    }))
                })) }));

            Assert.AreEqual("label", label2.TagName);
            Assert.AreEqual("label2", label2.Id);
            Assert.AreEqual("required", label3.ClassName);

            Assert.AreEqual(div, label2.Parent);
        }
Exemplo n.º 2
0
        public TestNode(UIElement dependencyObject, IDomElement <UIElement, PropertyInfo> parent, string tagname, IEnumerable <IDomElement <UIElement, PropertyInfo> > children = null,
                        IDictionary <string, PropertyInfo> attributes = null, string id = null, string @class = null)
            : base(dependencyObject ?? new UIElement(), parent, parent, TestTreeNodeProvider.Instance)
        {
            this.childNodes = this.logicalChildNodes = children?.ToList() ?? new List <IDomElement <UIElement, PropertyInfo> >();
            foreach (TestNode c in ChildNodes)
            {
                c.parent        = this;
                c.logicalParent = this;
            }

            dependencyObject.Children = this.ChildNodes.Select(x => x.Element).ToList();

            this.classList = new HashSet <string>();
            foreach (var item in (@class ?? "").Split(classSplitter, StringSplitOptions.RemoveEmptyEntries))
            {
                this.ClassList.Add(item);
            }

            this.Id = id;
            var namespaceSeparatorIndex = tagname.IndexOf('|');

            if (namespaceSeparatorIndex > -1)
            {
                this.TagName = tagname.Substring(namespaceSeparatorIndex + 1);
                this.assemblyQualifiedNamespaceName = TestNode.GetAssemblyQualifiedNamespaceName(GetType());
            }
            else
            {
                this.TagName = tagname;
                this.assemblyQualifiedNamespaceName = TestNode.GetAssemblyQualifiedNamespaceName(GetType());
            }

            this.attributes = attributes ?? new Dictionary <string, PropertyInfo>();

            this.StyleInfo = new StyleUpdateInfo
            {
                MatchedType = dependencyObject.GetType()
            };
        }