1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
7
using ICSharpCode.NRefactory.VB.Parser;
8
using ICSharpCode.NRefactory.VB.Ast;
10
namespace ICSharpCode.NRefactory.VB.Tests.Ast
13
public class XmlMemberAccessExpressionTests
17
public void VBNetSimpleElementReferenceTest()
19
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>("xml.<ns:MyElement>");
20
Assert.AreEqual("ns:MyElement", xmae.Identifier);
21
Assert.IsTrue(xmae.IsXmlIdentifier);
22
Assert.AreEqual(XmlAxisType.Element, xmae.AxisType);
23
Assert.IsTrue(xmae.TargetObject is IdentifierExpression);
24
Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier);
28
public void VBNetSimpleAttributeReferenceTest()
30
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>("xml.@attribute");
31
Assert.AreEqual("attribute", xmae.Identifier);
32
Assert.IsFalse(xmae.IsXmlIdentifier);
33
Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType);
34
Assert.IsTrue(xmae.TargetObject is IdentifierExpression);
35
Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier);
39
public void VBNetXmlNameAttributeReferenceTest()
41
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>("xml.@<ns:attribute>");
42
Assert.AreEqual("ns:attribute", xmae.Identifier);
43
Assert.IsTrue(xmae.IsXmlIdentifier);
44
Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType);
45
Assert.IsTrue(xmae.TargetObject is IdentifierExpression);
46
Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier);
50
public void VBNetSimpleDescendentsReferenceTest()
52
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>("xml...<ns:Element>");
53
Assert.AreEqual("ns:Element", xmae.Identifier);
54
Assert.IsTrue(xmae.IsXmlIdentifier);
55
Assert.AreEqual(XmlAxisType.Descendents, xmae.AxisType);
56
Assert.IsTrue(xmae.TargetObject is IdentifierExpression);
57
Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier);
61
public void VBNetSimpleElementReferenceWithDotTest()
63
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>(".<ns:MyElement>");
64
Assert.AreEqual("ns:MyElement", xmae.Identifier);
65
Assert.IsTrue(xmae.IsXmlIdentifier);
66
Assert.AreEqual(XmlAxisType.Element, xmae.AxisType);
67
Assert.IsTrue(xmae.TargetObject.IsNull);
71
public void VBNetSimpleAttributeReferenceWithDotTest()
73
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>(".@attribute");
74
Assert.AreEqual("attribute", xmae.Identifier);
75
Assert.IsFalse(xmae.IsXmlIdentifier);
76
Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType);
77
Assert.IsTrue(xmae.TargetObject.IsNull);
81
public void VBNetXmlNameAttributeReferenceWithDotTest()
83
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>(".@<ns:attribute>");
84
Assert.AreEqual("ns:attribute", xmae.Identifier);
85
Assert.IsTrue(xmae.IsXmlIdentifier);
86
Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType);
87
Assert.IsTrue(xmae.TargetObject.IsNull);
91
public void VBNetSimpleDescendentsReferenceWithDotTest()
93
XmlMemberAccessExpression xmae = ParseUtil.ParseExpression<XmlMemberAccessExpression>("...<ns:Element>");
94
Assert.AreEqual("ns:Element", xmae.Identifier);
95
Assert.IsTrue(xmae.IsXmlIdentifier);
96
Assert.AreEqual(XmlAxisType.Descendents, xmae.AxisType);
97
Assert.IsTrue(xmae.TargetObject.IsNull);