#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
2.5 KiB

// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Folding
{
[TestFixture]
public class AttributeTextInFoldIsXmlEncodedTestFixture
{
XmlFoldParser parser;
ICompilationUnit unit;
DefaultXmlFileExtensions extensions;
DefaultProjectContent projectContent;
MockTextBuffer textBuffer;
XmlEditorOptions options;
[SetUp]
public void Init()
{
projectContent = new DefaultProjectContent();
extensions = new DefaultXmlFileExtensions(null);
options = new XmlEditorOptions(new Properties());
parser = new XmlFoldParser(extensions, options);
}
void ParseWithShowAttributesSetToTrue(string xml)
{
options.ShowAttributesWhenFolded = true;
textBuffer = new MockTextBuffer(xml);
unit = parser.Parse(projectContent, @"d:\projects\a.xml", textBuffer);
}
[Test]
public void FoldAttributeTextHasSingleQuoteEncoded()
{
string xml =
"<root a='Single &apos; Quote'>\r\n" +
"</root>";
ParseWithShowAttributesSetToTrue(xml);
Assert.AreEqual("<root a='Single &apos; Quote'>", unit.FoldingRegions[0].Name);
}
[Test]
public void FoldAttributeTextHasDoubleQuoteEncoded()
{
string xml =
"<root a=\"Double &quot; Quote\">\r\n" +
"</root>";
ParseWithShowAttributesSetToTrue(xml);
Assert.AreEqual("<root a=\"Double &quot; Quote\">", unit.FoldingRegions[0].Name);
}
[Test]
public void FoldAttributeTextHasAmpersandEncoded()
{
string xml =
"<root a='Ampersand &amp;'>\r\n" +
"</root>";
ParseWithShowAttributesSetToTrue(xml);
Assert.AreEqual("<root a='Ampersand &amp;'>", unit.FoldingRegions[0].Name);
}
[Test]
public void FoldAttributeTextHasLessThanTagEncoded()
{
string xml =
"<root a='&lt;'>\r\n" +
"</root>";
ParseWithShowAttributesSetToTrue(xml);
Assert.AreEqual("<root a='&lt;'>", unit.FoldingRegions[0].Name);
}
[Test]
public void FoldAttributeTextHasGreaterThanTagEncoded()
{
string xml =
"<root a='&gt;'>\r\n" +
"</root>";
ParseWithShowAttributesSetToTrue(xml);
Assert.AreEqual("<root a='&gt;'>", unit.FoldingRegions[0].Name);
}
}
}