~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/XmlEditor/Test/Folding/ShowElementAttributesInFoldTestFixture.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 System;
 
5
using ICSharpCode.SharpDevelop.Dom;
 
6
using NUnit.Framework;
 
7
using XmlEditor.Tests.Utils;
 
8
 
 
9
namespace XmlEditor.Tests.Folding
 
10
{
 
11
        [TestFixture]
 
12
        public class ShowElementAttributesInFoldTestFixture
 
13
        {
 
14
                XmlFoldParserHelper helper;
 
15
                
 
16
                string xml =
 
17
                        "<root a=\"1st\" b=\"2nd\" c='3rd'>\r\n" +
 
18
                        "</root>";
 
19
                
 
20
                [Test]
 
21
                public void GetFolds_ShowAttributesIsTrue_FoldNameIsElementNameWithAttributes()
 
22
                {
 
23
                        GetFoldsWhenShowAttributesSetToTrue();
 
24
                        string name = helper.GetFirstFoldName();
 
25
                        Assert.AreEqual("<root a=\"1st\" b=\"2nd\" c='3rd'>", name);
 
26
                }
 
27
 
 
28
                [Test]
 
29
                public void GetFolds_ShowAttributesIsFalse_FoldNameIsElementNameOnly()
 
30
                {
 
31
                        GetFoldsWhenShowAttributesSetToFalse();
 
32
                        string name = helper.GetFirstFoldName();
 
33
                        Assert.AreEqual("<root>", name);
 
34
                }
 
35
                
 
36
                [Test]
 
37
                public void GetFolds_ShowAttributesSetToTrue_FirstFoldRegionContainsRootElement()
 
38
                {
 
39
                        GetFoldsWhenShowAttributesSetToTrue();
 
40
                        
 
41
                        DomRegion region = helper.GetFirstFoldRegion();
 
42
 
 
43
                        int beginLine = 1;
 
44
                        int beginColumn = 1;
 
45
                        int endLine = 2;
 
46
                        int endColumn = 8;
 
47
                        DomRegion expectedRegion = new DomRegion(beginLine, beginColumn, endLine, endColumn);
 
48
                        
 
49
                        Assert.AreEqual(expectedRegion, region);
 
50
                }
 
51
                
 
52
                void GetFoldsWhenShowAttributesSetToTrue()
 
53
                {
 
54
                        helper = new XmlFoldParserHelper();
 
55
                        helper.Options.ShowAttributesWhenFolded = true;
 
56
                        GetFolds();
 
57
                }
 
58
 
 
59
                void GetFolds()
 
60
                {
 
61
                        helper.CreateParser();
 
62
                        helper.GetFolds(xml);
 
63
                }
 
64
 
 
65
                void GetFoldsWhenShowAttributesSetToFalse()
 
66
                {
 
67
                        helper = new XmlFoldParserHelper();
 
68
                        helper.Options.ShowAttributesWhenFolded = false;
 
69
                        GetFolds();
 
70
                }
 
71
        }
 
72
}