Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1864 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
20 changed files with 554 additions and 14 deletions
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using WixBinding; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DialogLoading |
||||
{ |
||||
[TestFixture] |
||||
public class TextStyleNameWithSpecialXmlCharsTestFixture : DialogLoadingTestFixtureBase |
||||
{ |
||||
[Test] |
||||
public void CreateDialog() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
WixDialog wixDialog = doc.GetDialog("WelcomeDialog"); |
||||
using (Form dialog = wixDialog.CreateDialog(this)) { |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Property Id='BigFont'>{&BigFont'Style}</Property>\r\n" + |
||||
"\t\t\t<TextStyle Id=\"BigFont'Style\" FaceName='Verdana' Size='13' Bold='yes' />\r\n" + |
||||
"\t\t\t<Property Id='SmallFont'>{\\SmallFontStyle}</Property>\r\n" + |
||||
"\t\t\t<TextStyle Id='SmallFontStyle' FaceName='Arial' Size='10'/>\r\n" + |
||||
"\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" + |
||||
"\t\t\t\t<Control Id='Title' Type='Text' X='135' Y='20' Width='220' Height='60' Transparent='yes' NoPrefix='yes'>\r\n" + |
||||
"\t\t\t\t\t<Text>[BigFont]Welcome to the [ProductName] installation</Text>\r\n" + |
||||
"\t\t\t\t</Control>\r\n" + |
||||
"\t\t\t\t<Control Id='Description' Type='Text' X='135' Y='20' Width='220' Height='60' Transparent='yes' NoPrefix='yes'>\r\n" + |
||||
"\t\t\t\t\t<Text>[SmallFont]Install text...</Text>\r\n" + |
||||
"\t\t\t\t</Control>\r\n" + |
||||
"\t\t\t</Dialog>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using WixBinding; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DialogXmlGeneration |
||||
{ |
||||
[TestFixture] |
||||
public class ComboBoxPropertyWithSpecialXmlCharsTestFixture : DialogLoadingTestFixtureBase |
||||
{ |
||||
[Test] |
||||
public void UpdateDialogElement() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
CreatedComponents.Clear(); |
||||
WixDialog wixDialog = doc.GetDialog("WelcomeDialog"); |
||||
using (Form dialog = wixDialog.CreateDialog(this)) { |
||||
XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog); |
||||
} |
||||
} |
||||
|
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" + |
||||
"\t\t\t\t<Control Id='ComboBox1' Type='ComboBox' X='20' Y='187' Width='330' Height='40' Property=\"ComboBox'Property\"/>\r\n" + |
||||
"\t\t\t</Dialog>\r\n" + |
||||
"\t\t\t<ComboBox Property=\"ComboBox'Property\">\r\n" + |
||||
"\t\t\t</ComboBox>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using WixBinding; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DialogXmlGeneration |
||||
{ |
||||
[TestFixture] |
||||
public class ListBoxPropertyWithSpecialXmlCharsTestFixture : DialogLoadingTestFixtureBase |
||||
{ |
||||
[Test] |
||||
public void UpdateDialogElement() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
CreatedComponents.Clear(); |
||||
WixDialog wixDialog = doc.GetDialog("WelcomeDialog"); |
||||
using (Form dialog = wixDialog.CreateDialog(this)) { |
||||
XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" + |
||||
"\t\t\t\t<Control Id='ListBox1' Type='ListBox' X='20' Y='187' Width='330' Height='40' Property=\"ListBox'Property\"/>\r\n" + |
||||
"\t\t\t</Dialog>\r\n" + |
||||
"\t\t\t<ListBox Property=\"ListBox'Property\">\r\n" + |
||||
"\t\t\t\t<ListItem Text='first'/>\r\n" + |
||||
"\t\t\t\t<ListItem Text='second'/>\r\n" + |
||||
"\t\t\t</ListBox>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using WixBinding; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DialogXmlGeneration |
||||
{ |
||||
[TestFixture] |
||||
public class ListViewPropertyWithSpecialXmlCharsTestFixture : DialogLoadingTestFixtureBase |
||||
{ |
||||
[Test] |
||||
public void UpdateDialogElement() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
CreatedComponents.Clear(); |
||||
WixDialog wixDialog = doc.GetDialog("WelcomeDialog"); |
||||
using (Form dialog = wixDialog.CreateDialog(this)) { |
||||
XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" + |
||||
"\t\t\t\t<Control Id='ListView1' Type='ListView' X='20' Y='187' Width='330' Height='40' Property=\"ListView'Property\"/>\r\n" + |
||||
"\t\t\t</Dialog>\r\n" + |
||||
"\t\t\t<ListView Property=\"ListView'Property\">\r\n" + |
||||
"\t\t\t</ListView>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using WixBinding; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DialogXmlGeneration |
||||
{ |
||||
[TestFixture] |
||||
public class RadioButtonGroupPropertyWithSpecialXmlCharTestFixture : DialogLoadingTestFixtureBase |
||||
{ |
||||
[Test] |
||||
public void UpdateDialogElement() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
CreatedComponents.Clear(); |
||||
WixDialog wixDialog = doc.GetDialog("AcceptLicenseDialog"); |
||||
using (Form dialog = wixDialog.CreateDialog(this)) { |
||||
XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog); |
||||
} |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Fragment>\r\n" + |
||||
"\t\t<UI>\r\n" + |
||||
"\t\t\t<Dialog Id='AcceptLicenseDialog' Height='270' Width='370'>\r\n" + |
||||
"\t\t\t\t<Control Id='Buttons' Type='RadioButtonGroup' X='20' Y='187' Width='330' Height='40' Property=\"Accept'License\"/>\r\n" + |
||||
"\t\t\t</Dialog>\r\n" + |
||||
"\t\t\t<RadioButtonGroup Property=\"Accept'License\">\r\n" + |
||||
"\t\t\t\t<RadioButton Text='I accept' X='5' Y='0' Width='300' Height='15' Value='Yes'/>\r\n" + |
||||
"\t\t\t\t<RadioButton Text='I do not accept' X='5' Y='20' Width='300' Height='15' Value='No'/>\r\n" + |
||||
"\t\t\t</RadioButtonGroup>\r\n" + |
||||
"\t\t</UI>\r\n" + |
||||
"\t</Fragment>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
|
||||
namespace WixBinding.Tests.DirectoryImport |
||||
{ |
||||
[TestFixture] |
||||
public class AddDirectoryWithSpecialXmlCharsTestFixture |
||||
{ |
||||
WixDocument document; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
document = new WixDocument(); |
||||
document.FileName = @"C:\Projects\Test\Setup.wxs"; |
||||
document.LoadXml(GetWixXml()); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddDirectoryWithSingleQuoteChar() |
||||
{ |
||||
string directoryName = "Test'directory"; |
||||
WixDirectoryElement element = document.RootDirectory.AddDirectory(directoryName); |
||||
Assert.AreEqual(directoryName, element.DirectoryName); |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2003/01/wi\">\r\n" + |
||||
"\t<Product Name=\"MySetup\" \r\n" + |
||||
"\t Manufacturer=\"\" \r\n" + |
||||
"\t Id=\"F4A71A3A-C271-4BE8-B72C-F47CC956B3AA\" \r\n" + |
||||
"\t Language=\"1033\" \r\n" + |
||||
"\t Version=\"1.0.0.0\">\r\n" + |
||||
"\t\t<Package Id=\"6B8BE64F-3768-49CA-8BC2-86A76424DFE9\"/>\r\n" + |
||||
"\t\t<Directory Id=\"TARGETDIR\" SourceName=\"SourceDir\">\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
|
||||
namespace WixBinding.Tests.DirectoryImport |
||||
{ |
||||
[TestFixture] |
||||
public class ShortFileNameExistsWithSpecialXmlCharsTestFixture |
||||
{ |
||||
WixDocument document; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
document = new WixDocument(); |
||||
document.FileName = @"C:\Projects\Test\Setup.wxs"; |
||||
document.LoadXml(GetWixXml()); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileNameWithSingleQuote() |
||||
{ |
||||
string fileName = "Test'file"; |
||||
Assert.IsFalse(document.RootDirectory.ShortFileNameExists(fileName)); |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2003/01/wi\">\r\n" + |
||||
"\t<Product Name=\"MySetup\" \r\n" + |
||||
"\t Manufacturer=\"\" \r\n" + |
||||
"\t Id=\"F4A71A3A-C271-4BE8-B72C-F47CC956B3AA\" \r\n" + |
||||
"\t Language=\"1033\" \r\n" + |
||||
"\t Version=\"1.0.0.0\">\r\n" + |
||||
"\t\t<Package Id=\"6B8BE64F-3768-49CA-8BC2-86A76424DFE9\"/>\r\n" + |
||||
"\t\t<Directory Id=\"TARGETDIR\" SourceName=\"SourceDir\">\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// <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.IO; |
||||
using System.Text; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Utility class that will encode special XML characters.
|
||||
/// </summary>
|
||||
public sealed class XmlEncoder |
||||
{ |
||||
XmlEncoder() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Encodes any special characters in the xml string.
|
||||
/// </summary>
|
||||
public static string Encode(string xml, char quoteCharacter) |
||||
{ |
||||
XmlEncoderTextWriter encoderWriter = new XmlEncoderTextWriter(); |
||||
using (XmlTextWriter writer = new XmlTextWriter(encoderWriter)) { |
||||
writer.WriteStartElement("root"); |
||||
writer.WriteStartAttribute("attribute"); |
||||
writer.QuoteChar = quoteCharacter; |
||||
|
||||
encoderWriter.BeginMarkup(); |
||||
writer.WriteString(xml); |
||||
return encoderWriter.Markup; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Special XmlTextWriter that will return the last item written to
|
||||
/// it from a certain point. This is used by the XmlEncoder to
|
||||
/// get the encoded attribute string so the XmlEncoder does not
|
||||
/// have to do the special character encoding itself, but can
|
||||
/// use the .NET framework to do the work.
|
||||
/// </summary>
|
||||
class XmlEncoderTextWriter : EncodedStringWriter |
||||
{ |
||||
StringBuilder markup = new StringBuilder(); |
||||
bool saveMarkupText; |
||||
|
||||
public XmlEncoderTextWriter() : base(Encoding.UTF8) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the point from which we are interested in
|
||||
/// saving the string written to the text writer.
|
||||
/// </summary>
|
||||
public void BeginMarkup() |
||||
{ |
||||
saveMarkupText = true; |
||||
markup = new StringBuilder(); |
||||
} |
||||
|
||||
public void EndMarkup() |
||||
{ |
||||
saveMarkupText = false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the string written to this text writer after the
|
||||
/// BeginMarkup method was called.
|
||||
/// </summary>
|
||||
public string Markup { |
||||
get { |
||||
return markup.ToString(); |
||||
} |
||||
} |
||||
|
||||
public override void Write(string text) |
||||
{ |
||||
base.Write(text); |
||||
markup.Append(text); |
||||
} |
||||
|
||||
public override void Write(char value) |
||||
{ |
||||
base.Write(value); |
||||
markup.Append(value); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// <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 ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using System; |
||||
|
||||
namespace XmlEditor.Tests.XPathQuery |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the XmlEncoder class's Encode method which
|
||||
/// makes sure that a parameter being used in an xpath string is
|
||||
/// correctly encoded.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class EncodeXPathParameterTests |
||||
{ |
||||
[Test] |
||||
public void SingleQuote() |
||||
{ |
||||
Assert.AreEqual("'", XmlEncoder.Encode("'", '\'')); |
||||
} |
||||
|
||||
[Test] |
||||
public void Ampersand() |
||||
{ |
||||
Assert.AreEqual("&", XmlEncoder.Encode("&", '\'')); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue