~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/XmlEditor/Test/Folding/AttributeTextInFoldIsXmlEncodedTestFixture.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 System.Collections.Generic;
 
6
using ICSharpCode.SharpDevelop.Dom;
 
7
using ICSharpCode.XmlEditor;
 
8
using NUnit.Framework;
 
9
using XmlEditor.Tests.Utils;
 
10
 
 
11
namespace XmlEditor.Tests.Folding
 
12
{
 
13
        [TestFixture]
 
14
        public class AttributeTextInFoldIsXmlEncodedTestFixture
 
15
        {
 
16
                XmlFoldParserHelper helper;
 
17
                                
 
18
                [Test]
 
19
                public void GetFolds_AttributeValueHasSingleQuoteEncoded_FoldNameHasSingleQuoteEncoded()
 
20
                {
 
21
                        string xml = 
 
22
                                "<root a='Single &apos; Quote'>\r\n" +
 
23
                                "</root>";
 
24
                        
 
25
                        GetFoldsWhenShowAttributesIsSetToTrue(xml);
 
26
                        string name = helper.GetFirstFoldName();
 
27
                        
 
28
                        Assert.AreEqual("<root a='Single &apos; Quote'>", name);
 
29
                }
 
30
                
 
31
                void GetFoldsWhenShowAttributesIsSetToTrue(string xml)
 
32
                {
 
33
                        helper = new XmlFoldParserHelper();
 
34
                        helper.Options.ShowAttributesWhenFolded = true;
 
35
                        
 
36
                        helper.CreateParser();
 
37
                        helper.GetFolds(xml);
 
38
                }
 
39
 
 
40
                [Test]
 
41
                public void GetFolds_AttributeTextHasDoubleQuoteEncoded_FoldNameHasDoubleQuoteEncoded()
 
42
                {
 
43
                        string xml = 
 
44
                                "<root a=\"Double &quot; Quote\">\r\n" +
 
45
                                "</root>";
 
46
                        
 
47
                        GetFoldsWhenShowAttributesIsSetToTrue(xml);
 
48
                        string name = helper.GetFirstFoldName();
 
49
                        
 
50
                        Assert.AreEqual("<root a=\"Double &quot; Quote\">", name);
 
51
                }
 
52
                
 
53
                [Test]
 
54
                public void GetFolds_AttributeTextHasAmpersandEncoded_FoldNameHasAmpersandEncoded()
 
55
                {
 
56
                        string xml = 
 
57
                                "<root a='Ampersand &amp;'>\r\n" +
 
58
                                "</root>";
 
59
                        
 
60
                        GetFoldsWhenShowAttributesIsSetToTrue(xml);
 
61
                        string name = helper.GetFirstFoldName();
 
62
                        
 
63
                        Assert.AreEqual("<root a='Ampersand &amp;'>", name);
 
64
                }
 
65
                
 
66
                [Test]
 
67
                public void GetFolds_AttributeTextHasLessThanTagEncoded_FoldNameHasLessThanTagEncoded()
 
68
                {
 
69
                        string xml = 
 
70
                                "<root a='&lt;'>\r\n" +
 
71
                                "</root>";
 
72
                        
 
73
                        GetFoldsWhenShowAttributesIsSetToTrue(xml);
 
74
                        string name = helper.GetFirstFoldName();
 
75
                        
 
76
                        Assert.AreEqual("<root a='&lt;'>", name);
 
77
                }
 
78
                
 
79
                [Test]
 
80
                public void GetFolds_AttributeTextHasGreaterThanTagEncoded_FoldNameHasGreaterThanTagEncoded()
 
81
                {
 
82
                        string xml = 
 
83
                                "<root a='&gt;'>\r\n" +
 
84
                                "</root>";
 
85
                        
 
86
                        GetFoldsWhenShowAttributesIsSetToTrue(xml);
 
87
                        string name = helper.GetFirstFoldName();
 
88
                        
 
89
                        Assert.AreEqual("<root a='&gt;'>", name);
 
90
                }
 
91
        }
 
92
}