~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Paths/TwoElementPathTestFixture.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using MonoDevelop.XmlEditor;
 
3
using NUnit.Framework;
 
4
using System;
 
5
 
 
6
namespace MonoDevelop.XmlEditor.Tests.Paths
 
7
{
 
8
        [TestFixture]
 
9
        public class TwoElementPathTestFixture
 
10
        {
 
11
                XmlElementPath path;
 
12
                QualifiedName firstQualifiedName;
 
13
                QualifiedName secondQualifiedName;
 
14
                
 
15
                [SetUp]
 
16
                public void Init()
 
17
                {
 
18
                        path = new XmlElementPath();
 
19
                        firstQualifiedName = new QualifiedName("foo", "http://foo", "f");
 
20
                        path.Elements.Add(firstQualifiedName);
 
21
                        
 
22
                        secondQualifiedName = new QualifiedName("bar", "http://bar", "b");
 
23
                        path.Elements.Add(secondQualifiedName);
 
24
                }
 
25
                
 
26
                [Test]
 
27
                public void HasTwoItems()
 
28
                {
 
29
                        Assert.AreEqual(2, path.Elements.Count, 
 
30
                                        "Should have 2 elements.");
 
31
                }
 
32
                
 
33
                [Test]
 
34
                public void RemoveLastItem()
 
35
                {
 
36
                        path.Elements.RemoveLast();
 
37
                        Assert.AreEqual(firstQualifiedName, path.Elements[0],
 
38
                                        "Wrong item removed.");
 
39
                }       
 
40
                
 
41
                [Test]
 
42
                public void LastPrefix()
 
43
                {
 
44
                        Assert.AreEqual("b", path.Elements.LastPrefix, "Incorrect last prefix.");
 
45
                }
 
46
                
 
47
                [Test]
 
48
                public void LastPrefixAfterLastItemRemoved()
 
49
                {
 
50
                        path.Elements.RemoveLast();
 
51
                        Assert.AreEqual("f", path.Elements.LastPrefix, "Incorrect last prefix.");
 
52
                }       
 
53
                
 
54
                [Test]
 
55
                public void Equality()
 
56
                {
 
57
                        XmlElementPath newPath = new XmlElementPath();
 
58
                        newPath.Elements.Add(new QualifiedName("foo", "http://foo", "f"));
 
59
                        newPath.Elements.Add(new QualifiedName("bar", "http://bar", "b"));
 
60
                        
 
61
                        Assert.IsTrue(newPath.Equals(path), "Should be equal.");
 
62
                }
 
63
                
 
64
                [Test]
 
65
                public void NotEqual()
 
66
                {
 
67
                        XmlElementPath newPath = new XmlElementPath();
 
68
                        newPath.Elements.Add(new QualifiedName("aaa", "a", "a"));
 
69
                        newPath.Elements.Add(new QualifiedName("bbb", "b", "b"));
 
70
                        
 
71
                        Assert.IsFalse(newPath.Equals(path), "Should not be equal.");
 
72
                }
 
73
                
 
74
                [Test]
 
75
                public void CompactedPathItemCount()
 
76
                {
 
77
                        path.Compact();
 
78
                        Assert.AreEqual(1, path.Elements.Count, "Should only be one item.");
 
79
                }
 
80
                
 
81
                [Test]
 
82
                public void CompactPathItem()
 
83
                {
 
84
                        XmlElementPath newPath = new XmlElementPath();
 
85
                        newPath.Elements.Add(new QualifiedName("bar", "http://bar", "b"));
 
86
                        
 
87
                        path.Compact();
 
88
                        Assert.IsTrue(newPath.Equals(path), "Should be equal.");
 
89
                }
 
90
        }
 
91
}