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)
4
using ICSharpCode.XmlEditor;
7
using System.ComponentModel;
10
namespace XmlEditor.Tests.Tree
13
public class GetXmlAttributePropertyDescriptorTestFixture
15
PropertyDescriptorCollection properties;
16
XmlAttributePropertyDescriptor firstAttributePropertyDescriptor;
17
XmlAttributePropertyDescriptor secondAttributePropertyDescriptor;
18
XmlAttribute firstAttribute;
23
XmlDocument document = new XmlDocument();
24
document.LoadXml("<root first='a' second='b'/>");
25
firstAttribute = document.DocumentElement.GetAttributeNode("first");
26
properties = XmlAttributePropertyDescriptor.GetProperties(document.DocumentElement.Attributes);
27
firstAttributePropertyDescriptor = (XmlAttributePropertyDescriptor)properties["first"];
28
secondAttributePropertyDescriptor = (XmlAttributePropertyDescriptor)properties["second"];
32
public void TwoPropertyDescriptors()
34
Assert.AreEqual(2, properties.Count);
38
public void FirstPropertyName()
40
Assert.AreEqual("first", firstAttributePropertyDescriptor.Name);
44
public void FirstPropertyComponentType()
46
Assert.AreEqual(typeof(String), firstAttributePropertyDescriptor.ComponentType);
50
public void FirstPropertyReadOnly()
52
Assert.IsFalse(firstAttributePropertyDescriptor.IsReadOnly);
56
public void FirstPropertyType()
58
Assert.AreEqual(typeof(String), firstAttributePropertyDescriptor.PropertyType);
62
public void FirstPropertyCanResetValue()
64
Assert.IsFalse(firstAttributePropertyDescriptor.CanResetValue(null));
68
public void FirstPropertyShouldSerializeValue()
70
Assert.IsTrue(firstAttributePropertyDescriptor.ShouldSerializeValue(null));
74
public void FirstPropertyValue()
76
Assert.AreEqual("a", (String)firstAttributePropertyDescriptor.GetValue(null));
80
public void SecondPropertyValue()
82
Assert.AreEqual("b", (String)secondAttributePropertyDescriptor.GetValue(null));
86
public void SetFirstPropertyValue()
88
firstAttributePropertyDescriptor.SetValue(null, "new value");
89
Assert.AreEqual("new value", (String)firstAttributePropertyDescriptor.GetValue(null));
90
Assert.AreEqual("new value", firstAttribute.Value);
94
public void ResetValueDoesNothing()
96
firstAttributePropertyDescriptor.SetValue(null, "new value");
97
firstAttributePropertyDescriptor.ResetValue(null);
98
Assert.AreEqual("new value", firstAttribute.Value);