本文整理汇总了C#中System.Xml.Linq.XAttribute.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# XAttribute.Verify方法的具体用法?C# XAttribute.Verify怎么用?C# XAttribute.Verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XAttribute
的用法示例。
在下文中一共展示了XAttribute.Verify方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveStandaloneAttribute
//[Variation(Priority = 2, Desc = "Remove standalone attribute - def namespace", Params = new object[] { "xmlns", "value" })]
//[Variation(Priority = 2, Desc = "Remove standalone attribute - namespace", Params = new object[] { "{http://www.w3.org/2000/xmlns/}p", "value" })]
//[Variation(Priority = 2, Desc = "Remove standalone attribute I.", Params = new object[] { "{a}aa", "value" })]
//[Variation(Priority = 2, Desc = "Remove standalone attribute II.", Params = new object[] { "aa", "value" })]
public void RemoveStandaloneAttribute()
{
_runWithEvents = (bool)Params[0];
var name = (string)Variation.Params[0];
var value = (string)Variation.Params[1];
var a = new XAttribute(name, value);
try
{
if (_runWithEvents)
{
_eHelper = new EventsHelper(a);
}
a.Remove();
if (_runWithEvents)
{
_eHelper.Verify(XObjectChange.Remove, a);
}
TestLog.Compare(false, "Exception was expected here");
}
catch (InvalidOperationException)
{
// Expected exception
}
a.Verify();
}
示例2: CreateXAttribute8
// 22. Xml prefix: Enforce
// � http://www.w3.org/XML/1998/namespace
// � Must not be bound to any other namespace name.
// � No other prefix may be bound to this namespace name.
// 23. Xmlns prefix: Enforce, but some concern about performance
// � http://www.w3.org/2000/xmlns/
// � It must not be declared
// � No other prefix may be bound to this namespace name.
//[Variation(Priority = 1, Desc = "XAttribute - xml namespace - prefix redef", Params = new object[] { "xml", "another", true })]
//[Variation(Priority = 1, Desc = "XAttribute - xml namespace - bound to diff. prefix", Params = new object[] { "p", "http://www.w3.org/XML/1998/namespace", true })]
//[Variation(Priority = 1, Desc = "XAttribute - xml namespace - redeclared (positive).", Params = new object[] { "xml", "http://www.w3.org/XML/1998/namespace", false })]
//[Variation(Priority = 1, Desc = "XAttribute - xmlns namespace - bound to diff. prefix", Params = new object[] { "p", "http://www.w3.org/2000/xmlns/", true })]
public void CreateXAttribute8()
{
var prefix = (string)Variation.Params[0];
var value = (string)Variation.Params[1];
var shouldFail = (bool)Variation.Params[2];
try
{
var a = new XAttribute(XNamespace.Xmlns + prefix, value);
TestLog.Compare(!shouldFail, "Should fail");
a.Verify();
}
catch (ArgumentException)
{
TestLog.Compare(shouldFail, "NOT EXPECTED EXCEPTION");
}
}
示例3: CreateXAttribute5
//[Variation(Priority = 1, Desc = "XAttribute - copy - namespace decl - connected", Params = new object[] { true, "p" })]
//[Variation(Priority = 1, Desc = "XAttribute - copy - namespace decl - not connected", Params = new object[] { false, "p" })]
public void CreateXAttribute5()
{
var isConnected = (bool)Variation.Params[0];
var prefix = (string)Variation.Params[1];
XName name = XNamespace.Xmlns + prefix;
var attr1 = new XAttribute(name, "value");
if (isConnected)
{
var dummmy = new XElement("dummy", attr1);
}
var attr = new XAttribute(attr1);
TestLog.Compare(attr != null, "attr!=null");
TestLog.Compare(attr1 != attr, "(object)attr1!=(object)attr");
TestLog.Compare(attr.Value.Equals(attr1.Value), "attr.Value.Equals(attr1.Value)");
TestLog.Compare(attr.Name, name, "Name");
TestLog.Compare(attr.Value, "value", "value");
TestLog.Compare(attr.Parent == null, "Parent");
TestLog.Compare(attr.IsNamespaceDeclaration, "IsNamespaceDeclaration");
attr.Verify();
}
示例4: CreateXAttribute3
//[Variation(Priority = 0, Desc = "XAttribute - copy - not namespace decl - connected", Param = true)]
//[Variation(Priority = 0, Desc = "XAttribute - copy - not namespace decl - not connected", Param = false)]
public void CreateXAttribute3()
{
var isConnected = (bool)Variation.Param;
XName name = "{ns1}id";
var attr1 = new XAttribute(name, "value");
if (isConnected)
{
var x = new XElement("parent", attr1);
}
var attr = new XAttribute(attr1);
TestLog.Compare(attr != null, "attr!=null");
TestLog.Compare(attr1 != attr, "(object)attr1!=(object)attr");
TestLog.Compare(attr1.Value.Equals(attr.Value), "attr1.Value.Equals(attr.Value)");
TestLog.Compare(attr.Value.Equals(attr1.Value), "attr.Equals(attr1)");
TestLog.Compare(attr.Name, name, "Name");
TestLog.Compare(attr.Value, "value", "value");
TestLog.Compare(attr.Parent == null, "Parent");
TestLog.Compare(!attr.IsNamespaceDeclaration, "IsNamespaceDeclaration");
attr.Verify();
}
示例5: CreateXAttribute2
//[Variation(Priority = 1, Desc = "XAttribute - xname - namespace decl - normal", Param = "p")]
public void CreateXAttribute2()
{
var prefix = (string)Variation.Param;
XName name = XNamespace.Xmlns + prefix;
var attr = new XAttribute(name, "value");
TestLog.Compare(attr != null, "attr!=null");
TestLog.Compare(attr.Name, name, "Name");
TestLog.Compare(attr.Value, "value", "value");
TestLog.Compare(attr.Parent == null, "Parent");
TestLog.Compare(attr.IsNamespaceDeclaration, "IsNamespaceDeclaration");
attr.Verify();
}
示例6: CreateXAttribute
// XDocument constructors
//[Variation(Priority = 0, Desc = "Empty XDocument")]
public void CreateXAttribute()
{
XName name = "{ns1}id";
var attr = new XAttribute(name, "value");
TestLog.Compare(attr != null, "attr!=null");
TestLog.Compare(attr.Name, name, "Name");
TestLog.Compare(attr.Value, "value", "value");
TestLog.Compare(attr.Parent == null, "Parent");
TestLog.Compare(!attr.IsNamespaceDeclaration, "IsNamespaceDeclaration");
attr.Verify();
}