public XPathTypeRootNode GetRootNode(Type root, XPathTypeContext context) { if (_RootNodes.ContainsKey(root)) { return((XPathTypeRootNode)_RootNodes[root].Copy(context)); } var ret = new XPathTypeRootNode(root, context); _RootNodes.Add(root, ret); return(ret); }
public void Constructor_ShouldAcceptXmlRootTypes(Type root, string expectedNamespace, string expectedName) { var node = new XPathTypeRootNode(root, new XPathTypeContext(XPathTypeNodeProvider.Instance, XPathTypeNodeTests.RecordsNamespacesManager)); Assert.NotNull(node.AttributeChildrenNodes); Assert.Equal <int>(0, node.AttributeChildrenNodes.Length); Assert.NotNull(node.ElementChildrenNodes); Assert.Equal <int>(1, node.ElementChildrenNodes.Length); Assert.Equal <int>(-1, node.Index); Assert.Equal <string>(expectedName.Substring(expectedName.LastIndexOf(':') + 1), node.LocalName); Assert.Equal <string>(expectedName, node.Name); Assert.Equal <string>(expectedNamespace, node.Namespace); Assert.Null(node.MemberInfo); Assert.Equal <Type>(root, node.Node); Assert.Equal <XmlNodeType>(XmlNodeType.Element, node.NodeType); Assert.Null(node.Parent); Assert.Equal <Type>(root, node.Type); }
public void Constructor_ShouldAcceptCommonRootTypes(Type root) { var node = new XPathTypeRootNode(root, new XPathTypeContext(XPathTypeNodeProvider.Instance)); Assert.NotNull(node.AttributeChildrenNodes); Assert.Equal <int>(0, node.AttributeChildrenNodes.Length); Assert.NotNull(node.ElementChildrenNodes); Assert.Equal <int>(1, node.ElementChildrenNodes.Length); Assert.Equal <int>(-1, node.Index); Assert.Equal <string>(root.Name, node.LocalName); Assert.Equal <string>(root.Name, node.Name); Assert.Equal <string>(string.Empty, node.Namespace); Assert.Null(node.MemberInfo); Assert.Equal <Type>(root, node.Node); Assert.Equal <XmlNodeType>(XmlNodeType.Element, node.NodeType); Assert.Null(node.Parent); Assert.Equal <Type>(root, node.Type); }
public void Constructor_ShouldAcceptXmlRootTypes(Type root, string expectedNamespace, string expectedName) { var node=new XPathTypeRootNode(root, new XPathTypeContext(XPathTypeNodeProvider.Instance, XPathTypeNodeTests.RecordsNamespacesManager)); Assert.NotNull(node.AttributeChildrenNodes); Assert.Equal<int>(0, node.AttributeChildrenNodes.Length); Assert.NotNull(node.ElementChildrenNodes); Assert.Equal<int>(1, node.ElementChildrenNodes.Length); Assert.Equal<int>(-1, node.Index); Assert.Equal<string>(expectedName.Substring(expectedName.LastIndexOf(':')+1), node.LocalName); Assert.Equal<string>(expectedName, node.Name); Assert.Equal<string>(expectedNamespace, node.Namespace); Assert.Null(node.MemberInfo); Assert.Equal<Type>(root, node.Node); Assert.Equal<XmlNodeType>(XmlNodeType.Element, node.NodeType); Assert.Null(node.Parent); Assert.Equal<Type>(root, node.Type); }
public void Constructor_ShouldAcceptCommonRootTypes(Type root) { var node=new XPathTypeRootNode(root, new XPathTypeContext(XPathTypeNodeProvider.Instance)); Assert.NotNull(node.AttributeChildrenNodes); Assert.Equal<int>(0, node.AttributeChildrenNodes.Length); Assert.NotNull(node.ElementChildrenNodes); Assert.Equal<int>(1, node.ElementChildrenNodes.Length); Assert.Equal<int>(-1, node.Index); Assert.Equal<string>(root.Name, node.LocalName); Assert.Equal<string>(root.Name, node.Name); Assert.Equal<string>(string.Empty, node.Namespace); Assert.Null(node.MemberInfo); Assert.Equal<Type>(root, node.Node); Assert.Equal<XmlNodeType>(XmlNodeType.Element, node.NodeType); Assert.Null(node.Parent); Assert.Equal<Type>(root, node.Type); }
public void Constructor_ShouldCommonRootTypesHaveValidSingleChildElement(Type root, int expectedAttributes, int expectedElements) { var node=new XPathTypeRootNode(root, new XPathTypeContext(XPathTypeNodeProvider.Instance)).ElementChildrenNodes[0]; Assert.NotNull(node.AttributeChildrenNodes); Assert.Equal<int>(expectedAttributes, node.AttributeChildrenNodes.Length); Assert.NotNull(node.ElementChildrenNodes); Assert.Equal<int>(expectedElements, node.ElementChildrenNodes.Length); Assert.Equal<int>(0, node.Index); Assert.Equal<string>(root.Name, node.LocalName); Assert.Equal<string>(root.Name, node.Name); Assert.Equal<string>(string.Empty, node.Namespace); Assert.Null(node.MemberInfo); Assert.Equal<Type>(root, node.Node); Assert.Equal<XmlNodeType>(XmlNodeType.Element, node.NodeType); Assert.NotNull(node.Parent); Assert.Equal<Type>(root, node.Type); }
public void Constructor_ShouldCommonRootTypesHaveValidSingleChildElement(Type root, int expectedAttributes, int expectedElements) { var node = new XPathTypeRootNode(root, new XPathTypeContext(XPathTypeNodeProvider.Instance)).ElementChildrenNodes[0]; Assert.NotNull(node.AttributeChildrenNodes); Assert.Equal <int>(expectedAttributes, node.AttributeChildrenNodes.Length); Assert.NotNull(node.ElementChildrenNodes); Assert.Equal <int>(expectedElements, node.ElementChildrenNodes.Length); Assert.Equal <int>(0, node.Index); Assert.Equal <string>(root.Name, node.LocalName); Assert.Equal <string>(root.Name, node.Name); Assert.Equal <string>(string.Empty, node.Namespace); Assert.Null(node.MemberInfo); Assert.Equal <Type>(root, node.Node); Assert.Equal <XmlNodeType>(XmlNodeType.Element, node.NodeType); Assert.NotNull(node.Parent); Assert.Equal <Type>(root, node.Type); }