~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/XmlEditor/Test/Tree/GetXmlAttributePropertyDescriptorTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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)
 
3
 
 
4
using ICSharpCode.XmlEditor;
 
5
using NUnit.Framework;
 
6
using System;
 
7
using System.ComponentModel;
 
8
using System.Xml;
 
9
 
 
10
namespace XmlEditor.Tests.Tree
 
11
{
 
12
        [TestFixture]
 
13
        public class GetXmlAttributePropertyDescriptorTestFixture
 
14
        {
 
15
                PropertyDescriptorCollection properties;
 
16
                XmlAttributePropertyDescriptor firstAttributePropertyDescriptor;
 
17
                XmlAttributePropertyDescriptor secondAttributePropertyDescriptor;
 
18
                XmlAttribute firstAttribute;
 
19
                
 
20
                [SetUp]
 
21
                public void Init()
 
22
                {
 
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"];
 
29
                }
 
30
                
 
31
                [Test]
 
32
                public void TwoPropertyDescriptors()
 
33
                {
 
34
                        Assert.AreEqual(2, properties.Count);
 
35
                }
 
36
                
 
37
                [Test]
 
38
                public void FirstPropertyName()
 
39
                {
 
40
                        Assert.AreEqual("first", firstAttributePropertyDescriptor.Name);
 
41
                }
 
42
                
 
43
                [Test]
 
44
                public void FirstPropertyComponentType()
 
45
                {
 
46
                        Assert.AreEqual(typeof(String), firstAttributePropertyDescriptor.ComponentType);
 
47
                }
 
48
                
 
49
                [Test]
 
50
                public void FirstPropertyReadOnly()
 
51
                {
 
52
                        Assert.IsFalse(firstAttributePropertyDescriptor.IsReadOnly);
 
53
                }
 
54
                
 
55
                [Test]
 
56
                public void FirstPropertyType()
 
57
                {
 
58
                        Assert.AreEqual(typeof(String), firstAttributePropertyDescriptor.PropertyType);
 
59
                }
 
60
                
 
61
                [Test]
 
62
                public void FirstPropertyCanResetValue()
 
63
                {
 
64
                        Assert.IsFalse(firstAttributePropertyDescriptor.CanResetValue(null));
 
65
                }
 
66
                
 
67
                [Test]
 
68
                public void FirstPropertyShouldSerializeValue()
 
69
                {
 
70
                        Assert.IsTrue(firstAttributePropertyDescriptor.ShouldSerializeValue(null));
 
71
                }
 
72
                
 
73
                [Test]
 
74
                public void FirstPropertyValue()
 
75
                {
 
76
                        Assert.AreEqual("a", (String)firstAttributePropertyDescriptor.GetValue(null));
 
77
                }
 
78
                
 
79
                [Test]
 
80
                public void SecondPropertyValue()
 
81
                {
 
82
                        Assert.AreEqual("b", (String)secondAttributePropertyDescriptor.GetValue(null));
 
83
                }
 
84
 
 
85
                [Test]
 
86
                public void SetFirstPropertyValue()
 
87
                {
 
88
                        firstAttributePropertyDescriptor.SetValue(null, "new value");
 
89
                        Assert.AreEqual("new value", (String)firstAttributePropertyDescriptor.GetValue(null));
 
90
                        Assert.AreEqual("new value", firstAttribute.Value);
 
91
                }
 
92
                
 
93
                [Test]
 
94
                public void ResetValueDoesNothing()
 
95
                {
 
96
                        firstAttributePropertyDescriptor.SetValue(null, "new value");
 
97
                        firstAttributePropertyDescriptor.ResetValue(null);
 
98
                        Assert.AreEqual("new value", firstAttribute.Value);
 
99
                }
 
100
        }
 
101
}