public void AddAttribute_AttributeParametersInvalid_ReturnNull(string name, string value) { //Arrange //Act var result = XmlUtility.AddAttribute(_document.DocumentElement, name, value, _document); //Assert Assert.IsNull(result); }
public XmlNode ToStartXml() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<dummy/>"); XmlNode testNode = XmlUtility.AddElement(doc.ChildNodes[0], "start"); XmlUtility.AddAttribute(testNode, "name", DisplayName); return(testNode); }
public void AddAttribute_NodeIsInvalid_ReturnNull() { //Arrange string name = "AttrName"; string value = "AttrValue"; //Act var result = XmlUtility.AddAttribute(_document.DocumentElement, name, value, null); //Assert Assert.IsNull(result); }
public virtual XmlNode ToStartXml() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<dummy/>"); XmlNode testNode = XmlUtility.AddElement(doc.ChildNodes[0], "start"); XmlUtility.AddAttribute(testNode, "name", DisplayName); XmlUtility.AddAttribute(testNode, "type", method.ReflectedType.FullName); XmlUtility.AddAttribute(testNode, "method", method.Name); return(testNode); }
public void AddAttribute_WhenCalledValid_ReturnParentWithNewChildrens() { //Arrange string name = "AttrName"; string value = "AttrValue"; //Act var result = XmlUtility.AddAttribute(_document.DocumentElement, name, value, _document); //Assert Assert.That(result.Attributes.Count, Is.EqualTo(1)); Assert.That(result.Attributes[0].Name, Is.EqualTo(name)); Assert.That(result.Attributes[0].Value, Is.EqualTo(value)); }
public void Addttribute_NodeNotBelongToDoc_ReturnNull() { //Arrange XmlDocument tmp = new XmlDocument(); tmp.AppendChild(tmp.CreateElement("otherRoot")); string name = "AttrName"; string value = "AttrValue"; //Act //Assert Assert.That(() => XmlUtility.AddAttribute(_document.DocumentElement, name, value, tmp), Throws.Exception); }
public virtual XmlNode ToStartXml() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<dummy/>"); XmlNode testNode = XmlUtility.AddElement(doc.ChildNodes[0], "start"); string typeName = method.TypeName; string methodName = method.Name; XmlUtility.AddAttribute(testNode, "name", typeName + "." + methodName); XmlUtility.AddAttribute(testNode, "type", typeName); XmlUtility.AddAttribute(testNode, "method", methodName); return(testNode); }