XmlData Name Property Delta Engine Documentation

Namespace: DeltaEngine.Content.Xml
Assembly: DeltaEngine.Content.Xml (in DeltaEngine.Content.Xml.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public string Name { get; set; }

Property Value

Type: String
Remarks

Tests: DeltaEngine.Content.Xml.Tests.XmlDataTests
Examples

5 unit tests call DeltaEngine.Content.Xml.XmlData.Name
[Test]
public void InvalidName()
{
    Assert.Throws<XmlData.InvalidXmlNameException>(() => new XmlData(null));
    Assert.Throws<XmlData.InvalidXmlNameException>(() => new XmlData("Hello World"));
}
[Test]
public void GetDescendant()
{
    XmlData root = CreateDeepTestXmlData();
    Assert.AreEqual(root.Children[1], root.GetDescendant(root.Children[1].Name));
    Assert.AreEqual(root.Children[1].Children[0], root.GetDescendant("grandchild"));
    Assert.AreEqual(null, root.GetDescendant("unknown"));
}
[Test]
public void AddChildViaNameAndValueWillOnlyAddTheValueIfNotNull()
{
    var node = new XmlData("Root");
    Assert.IsNull(node.AddChild("Child").Value);
    Assert.IsNull(node.AddChild("Child", null).Value);
    Assert.IsEmpty(node.AddChild("Child", "").Value);
    Assert.AreEqual(4.ToString(), node.AddChild("Child", 4).Value);
}
See Also