Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1757 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
21 changed files with 1182 additions and 23 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the files and directories for a specified path. This is used
|
||||
/// to hide the file system from the WixPackageFilesEditor class when
|
||||
/// testing.
|
||||
/// </summary>
|
||||
public interface IDirectoryReader |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the files in the specified path.
|
||||
/// </summary>
|
||||
string[] GetFiles(string path); |
||||
|
||||
/// <summary>
|
||||
/// Gets the directories in the specified path.
|
||||
/// </summary>
|
||||
string[] GetDirectories(string path); |
||||
} |
||||
} |
@ -0,0 +1,187 @@
@@ -0,0 +1,187 @@
|
||||
// <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.SharpDevelop.Project; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using WixBinding.Tests.PackageFiles; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DirectoryImport |
||||
{ |
||||
/// <summary>
|
||||
/// Adds several directories and its contained files to the setup package.
|
||||
/// The original package has no directories, only the root directory is
|
||||
/// defined.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class AddDirectoryTestFixture : PackageFilesTestFixtureBase |
||||
{ |
||||
WixDirectoryElement appDirectoryElement; |
||||
WixComponentElement myAppExeFileComponentElement; |
||||
WixFileElement myAppExeFileElement; |
||||
WixDirectoryElement docsDirectoryElement; |
||||
WixDirectoryElement srcDirectoryElement; |
||||
WixDirectoryElement cssDirectoryElement; |
||||
WixFileElement readmeFileElement; |
||||
string docsDirectory = @"C:\Projects\Test\MyApp\docs"; |
||||
string cssDirectory = @"C:\Projects\Test\MyApp\docs\css"; |
||||
string srcDirectory = @"C:\Projects\Test\MyApp\src"; |
||||
string directory = @"C:\Projects\Test\MyApp"; |
||||
string myAppExeFile = "MyApp.exe"; |
||||
string[] srcFiles = new string[] {"MyProj.sln", "MyProj.csproj", "Main.cs"}; |
||||
string[] docFiles = new string[] {"readme.txt", "license.txt"}; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
base.InitFixture(); |
||||
editor.AddDirectory(directory); |
||||
|
||||
WixNamespaceManager nsManager = new WixNamespaceManager(editor.Document.NameTable); |
||||
appDirectoryElement = (WixDirectoryElement)editor.Document.RootDirectory.FirstChild; |
||||
myAppExeFileComponentElement = (WixComponentElement)appDirectoryElement.SelectSingleNode("w:Component", nsManager); |
||||
myAppExeFileElement = (WixFileElement)myAppExeFileComponentElement.LastChild; |
||||
docsDirectoryElement = (WixDirectoryElement)appDirectoryElement.SelectSingleNode("w:Directory[@Name='docs']", nsManager); |
||||
srcDirectoryElement = (WixDirectoryElement)appDirectoryElement.SelectSingleNode("w:Directory[@Name='src']", nsManager); |
||||
cssDirectoryElement = (docsDirectoryElement.GetDirectories())[0]; |
||||
readmeFileElement = (WixFileElement)docsDirectoryElement.SelectSingleNode("w:Component/w:File[@Name='readme.txt']", nsManager); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsDirty() |
||||
{ |
||||
Assert.IsTrue(view.IsDirty); |
||||
} |
||||
|
||||
[Test] |
||||
public void DirectoryElementAddedToView() |
||||
{ |
||||
Assert.IsInstanceOfType(typeof(WixDirectoryElement), view.ElementsAdded[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppDirectoryName() |
||||
{ |
||||
Assert.AreEqual("MyApp", appDirectoryElement.ShortName); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppDirectoryLongName() |
||||
{ |
||||
Assert.AreEqual(String.Empty, appDirectoryElement.LongName); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppDirectoryId() |
||||
{ |
||||
Assert.AreEqual("MyApp", appDirectoryElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppDirectoryHasChildComponent() |
||||
{ |
||||
Assert.IsNotNull(myAppExeFileComponentElement); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppExeComponentDiskId() |
||||
{ |
||||
Assert.AreEqual("1", myAppExeFileComponentElement.DiskId); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppExeFileElementShortName() |
||||
{ |
||||
Assert.AreEqual("MyApp.exe", myAppExeFileElement.ShortName); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppExeFileElementId() |
||||
{ |
||||
Assert.AreEqual("MyApp.exe", myAppExeFileElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddExeSourceFile() |
||||
{ |
||||
Assert.AreEqual(@"MyApp\MyApp.exe", myAppExeFileElement.Source); |
||||
} |
||||
|
||||
[Test] |
||||
public void DocDirectoryElementExists() |
||||
{ |
||||
Assert.IsNotNull(docsDirectoryElement); |
||||
} |
||||
|
||||
[Test] |
||||
public void SrcDirectoryElementExists() |
||||
{ |
||||
Assert.IsNotNull(srcDirectoryElement); |
||||
} |
||||
|
||||
[Test] |
||||
public void CssDirectoryElementExists() |
||||
{ |
||||
Assert.IsNotNull(cssDirectoryElement); |
||||
} |
||||
|
||||
[Test] |
||||
public void ReadmeFileElementExists() |
||||
{ |
||||
Assert.IsNotNull(readmeFileElement); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppExeComponentId() |
||||
{ |
||||
Assert.AreEqual("MyAppExe", myAppExeFileComponentElement.Id); |
||||
} |
||||
|
||||
public override string[] GetFiles(string path) |
||||
{ |
||||
if (path == docsDirectory) { |
||||
return docFiles; |
||||
} else if (path == srcDirectory) { |
||||
return srcFiles; |
||||
} else if (path == cssDirectory) { |
||||
return new string[0]; |
||||
} |
||||
return new string[] {myAppExeFile}; |
||||
} |
||||
|
||||
public override string[] GetDirectories(string path) |
||||
{ |
||||
if (path == directory) { |
||||
return new string[] {"docs", "src"}; |
||||
} else if (path == docsDirectory) { |
||||
return new string[] {"css"}; |
||||
} |
||||
return new string[0]; |
||||
} |
||||
|
||||
protected override 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,103 @@
@@ -0,0 +1,103 @@
|
||||
// <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.SharpDevelop.Project; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using WixBinding.Tests.PackageFiles; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DirectoryImport |
||||
{ |
||||
/// <summary>
|
||||
/// Adds a subdirectory to an existing directory in the package files editor.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class AddSubDirectoryTestFixture : PackageFilesTestFixtureBase |
||||
{ |
||||
WixDirectoryElement appDirectoryElement; |
||||
WixFileElement exeFileElement; |
||||
WixFileElement readmeFileElement; |
||||
string directory = @"C:\Projects\Setup\MyApp"; |
||||
string[] files = new string[] {"MyApp.exe", "readme.txt"}; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
base.InitFixture(); |
||||
WixDirectoryElement programFilesFolderElement = (WixDirectoryElement)editor.Document.RootDirectory.FirstChild; |
||||
view.SelectedElement = programFilesFolderElement; |
||||
editor.AddDirectory(directory); |
||||
|
||||
appDirectoryElement = (WixDirectoryElement)programFilesFolderElement.FirstChild; |
||||
exeFileElement = (WixFileElement)appDirectoryElement.SelectSingleNode("w:Component/w:File[@Name='MyApp.exe']", new WixNamespaceManager(editor.Document.NameTable)); |
||||
readmeFileElement = (WixFileElement)appDirectoryElement.SelectSingleNode("w:Component/w:File[@Name='readme.txt']", new WixNamespaceManager(editor.Document.NameTable)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsDirty() |
||||
{ |
||||
Assert.IsTrue(view.IsDirty); |
||||
} |
||||
|
||||
[Test] |
||||
public void DirectoryElementAddedToView() |
||||
{ |
||||
Assert.IsInstanceOfType(typeof(WixDirectoryElement), view.ElementsAdded[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppDirectoryName() |
||||
{ |
||||
Assert.AreEqual("MyApp", appDirectoryElement.ShortName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExeFileElementAdded() |
||||
{ |
||||
Assert.IsNotNull(exeFileElement); |
||||
} |
||||
|
||||
[Test] |
||||
public void ReadmeFileElementAdded() |
||||
{ |
||||
Assert.IsNotNull(readmeFileElement); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the MyApp directory files.
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public override string[] GetFiles(string path) |
||||
{ |
||||
return files; |
||||
} |
||||
|
||||
protected override 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\t<Directory Id='ProgramFiles' SourceName='ProgramFiles'>\r\n" + |
||||
"\t\t\t</Directory>\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
// <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.SharpDevelop.Project; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using WixBinding.Tests.PackageFiles; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.DirectoryImport |
||||
{ |
||||
/// <summary>
|
||||
/// Adds several directories and its contained files to the setup package.
|
||||
/// The original package has several components already defined. This
|
||||
/// test fixture checks that unique component ids are generated for the new
|
||||
/// files.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class DuplicateComponentIdTestFixture : PackageFilesTestFixtureBase |
||||
{ |
||||
WixDirectoryElement appDirectoryElement; |
||||
WixComponentElement readmeComponentElement; |
||||
WixComponentElement licenseComponentElement; |
||||
WixComponentElement exeComponentElement; |
||||
string directory = @"C:\Projects\Test\MyApp"; |
||||
string[] files = new string[] {"MyApp.exe", "readme.txt", "license.txt"}; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
base.InitFixture(); |
||||
editor.AddDirectory(directory); |
||||
|
||||
WixNamespaceManager nsManager = new WixNamespaceManager(editor.Document.NameTable); |
||||
appDirectoryElement = (WixDirectoryElement)editor.Document.RootDirectory.SelectSingleNode("w:Directory[@Name='MyApp']", nsManager);; |
||||
XmlNode fileElement = appDirectoryElement.SelectSingleNode("w:Component/w:File[@Name='readme.txt']", nsManager); |
||||
readmeComponentElement = (WixComponentElement)fileElement.ParentNode; |
||||
|
||||
fileElement = appDirectoryElement.SelectSingleNode("w:Component/w:File[@Name='license.txt']", nsManager); |
||||
licenseComponentElement = (WixComponentElement)fileElement.ParentNode; |
||||
|
||||
exeComponentElement = (WixComponentElement)appDirectoryElement.SelectSingleNode("w:Component[w:File/@Name='MyApp.exe']", nsManager); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Parent directory is added to component id.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void ReadmeComponentId() |
||||
{ |
||||
Assert.AreEqual("MyAppReadmeTxt", readmeComponentElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void LicenseComponentId() |
||||
{ |
||||
Assert.AreEqual("MyAppLicenseTxt1", licenseComponentElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void AppExeComponentId() |
||||
{ |
||||
Assert.AreEqual("MyAppMyAppExe2", exeComponentElement.Id); |
||||
} |
||||
|
||||
public override string[] GetFiles(string path) |
||||
{ |
||||
if (path == directory) { |
||||
return files; |
||||
} |
||||
return new string[0]; |
||||
} |
||||
|
||||
public override string[] GetDirectories(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
protected override 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\t<Directory Id=\"ProgramFilesFolder\" Name=\"PFiles\">\r\n" + |
||||
"\t\t\t\t<Directory Id=\"INSTALLDIR\" Name=\"OtherFolder\">\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"MyAppExe\" Guid=\"999DE542-C4A9-48DA-ACF8-09949CDCD808\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"MyAppMyAppExe\" Guid=\"111DE542-C4A9-48DA-ACF8-09949CDCD808\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"MyAppMyAppExe1\" Guid=\"888DE542-C4A9-48DA-ACF8-09949CDCD808\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"MyAppLicenseTxt\" Guid=\"777DE542-C4A9-48DA-ACF8-09949CDCD808\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"LicenseTxt\" Guid=\"555DE542-C4A9-48DA-ACF8-09949CDCD808\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"ReadmeTxt\" Guid=\"370DE542-C4A9-48DA-ACF8-09949CDCD808\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t</Directory>\r\n" + |
||||
"\t\t\t</Directory>\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <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.Document |
||||
{ |
||||
[TestFixture] |
||||
public class AddRootDirectoryWithNoProductElementTestFixture |
||||
{ |
||||
[Test] |
||||
public void AddRootDirectory() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
WixDirectoryElement element = doc.AddRootDirectory(); |
||||
Assert.IsNotNull(element); |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2003/01/wi\">\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
// <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.Xml; |
||||
|
||||
namespace WixBinding.Tests.Document |
||||
{ |
||||
[TestFixture] |
||||
public class ExistingFileIdGenerationTests |
||||
{ |
||||
WixDocument doc; |
||||
WixComponentElement component; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
component = (WixComponentElement)doc.SelectSingleNode("//w:Component", new WixNamespaceManager(doc.NameTable)); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdAlreadyExists() |
||||
{ |
||||
WixFileElement fileElement = new WixFileElement(doc, @"C:\Projects\Setup\doc\license.txt"); |
||||
Assert.AreEqual("doc.license.txt", fileElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdExists() |
||||
{ |
||||
WixFileElement fileElement = new WixFileElement(doc, @"C:\Projects\Setup\doc\license.txt"); |
||||
Assert.IsTrue(doc.FileIdExists("license.txt")); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdAlreadyExistsAndParentDirectoryUsingAltDirSeparator() |
||||
{ |
||||
WixFileElement fileElement = new WixFileElement(doc, @"C:/Projects/Setup/doc/license.txt"); |
||||
Assert.AreEqual("doc.license.txt", fileElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdAlreadyExistsAndNoParentDirectory() |
||||
{ |
||||
WixFileElement fileElement = new WixFileElement(doc, @"license.txt"); |
||||
Assert.AreEqual("license1.txt", fileElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdAlreadyExistsAndParentDirectoryIsRoot() |
||||
{ |
||||
WixFileElement fileElement = new WixFileElement(doc, @"C:\license.txt"); |
||||
Assert.AreEqual("license1.txt", fileElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdWithNumberAlreadyExists() |
||||
{ |
||||
component.AddFile(@"license.txt"); |
||||
WixFileElement fileElement = new WixFileElement(doc, @"license.txt"); |
||||
Assert.AreEqual("license2.txt", fileElement.Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileIdWithParentDirectoryAndNumberExists() |
||||
{ |
||||
component.AddFile(@"C:/Projects/Setup/doc/license.txt"); |
||||
WixFileElement fileElement = new WixFileElement(doc, @"C:/Projects/Setup/doc/license.txt"); |
||||
Assert.AreEqual("doc.license1.txt", fileElement.Id); |
||||
} |
||||
|
||||
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\t<Directory Id=\"ProgramFilesFolder\" Name=\"PFiles\">\r\n" + |
||||
"\t\t\t\t\t<Directory Id=\"INSTALLDIR\" Name=\"MyApp\">\r\n" + |
||||
"\t\t\t\t\t\t<Component Guid=\"370DE542-C4A9-48DA-ACF8-09949CDCD808\" Id=\"SharpDevelopDocFiles\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\AssemblyBaseAddresses.txt\" Name=\"baseaddr.txt\" Id=\"AssemblyBaseAddresses.txt\" LongName=\"AssemblyBaseAddresses.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\BuiltWithSharpDevelop.png\" Name=\"bw-sd.PNG\" Id=\"BuiltWithSharpDevelop.png\" LongName=\"BuiltWithSharpDevelop.png\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\ChangeLog.xml\" Name=\"change.xml\" Id=\"ChangeLog.xml\" LongName=\"ChangeLog.xml\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\copyright.txt\" Name=\"cpyright.txt\" Id=\"copyright.txt\" LongName=\"copyright.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\license.txt\" Name=\"license.txt\" Id=\"license.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\readme.rtf\" Name=\"readme.rtf\" Id=\"readme.rtf\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\SharpDevelopInfoResources.txt\" Name=\"Resource.txt\" Id=\"SharpDevelopInfoResources.txt\" LongName=\"SharpDevelopInfoResources.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t</Directory>\r\n" + |
||||
"\t\t\t</Directory>\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
// <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.Xml; |
||||
|
||||
namespace WixBinding.Tests.Document |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the short filename generated takes into account existing
|
||||
/// short filenames in the document. Note that only those files inside the
|
||||
/// same directory are considered. It is perfectly valid to have the same
|
||||
/// short filename installed to a different directory.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ExistingShortNameTests |
||||
{ |
||||
WixDocument doc; |
||||
WixComponentElement component; |
||||
WixComponentElement myAppComponent; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
component = (WixComponentElement)doc.SelectSingleNode("//w:Component[@Id='SharpDevelopDocFiles']", new WixNamespaceManager(doc.NameTable)); |
||||
myAppComponent = (WixComponentElement)doc.SelectSingleNode("//w:Component[@Id='SharpDevelopMyAppFiles']", new WixNamespaceManager(doc.NameTable)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShortNameAlreadyExists() |
||||
{ |
||||
component.AddFile(@"C:\Projects\Setup\doc\changelog.xml"); |
||||
WixFileElement fileElement = (WixFileElement)component.LastChild; |
||||
Assert.AreEqual("CHANGE_2.XML", fileElement.ShortName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ShortNameDoesNotExistInParentDirectory() |
||||
{ |
||||
myAppComponent.AddFile(@"C:\Projects\Setup\doc\changelog.xml"); |
||||
WixFileElement fileElement = (WixFileElement)myAppComponent.LastChild; |
||||
Assert.AreEqual("CHANGE_1.XML", fileElement.ShortName); |
||||
} |
||||
|
||||
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\t<Directory Id=\"ProgramFilesFolder\" Name=\"PFiles\">\r\n" + |
||||
"\t\t\t\t\t\t<Component Guid=\"370DE542-C4A9-48DA-ACF8-09949CDCD808\" Id=\"SharpDevelopMyAppFiles\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\AssemblyBaseAddresses.txt\" Name=\"baseaddr.txt\" Id=\"AssemblyBaseAddresses.txt\" LongName=\"AssemblyBaseAddresses.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\BuiltWithSharpDevelop.png\" Name=\"bw-sd.PNG\" Id=\"BuiltWithSharpDevelop.png\" LongName=\"BuiltWithSharpDevelop.png\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\ChangeLog.xml\" Name=\"CHANGE.XML\" Id=\"ChangeLog.xml\" LongName=\"ChangeLog.xml\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\copyright.txt\" Name=\"cpyright.txt\" Id=\"copyright.txt\" LongName=\"copyright.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\license.txt\" Name=\"license.txt\" Id=\"license.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\readme.rtf\" Name=\"readme2.rtf\" Id=\"readme.rtf\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\SharpDevelopInfoResources.txt\" Name=\"Resource.txt\" Id=\"SharpDevelopInfoResources.txt\" LongName=\"SharpDevelopInfoResources.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Directory Id=\"INSTALLDIR\" Name=\"MyApp\">\r\n" + |
||||
"\t\t\t\t\t\t<Component Guid=\"77777777-C4A9-48DA-ACF8-09949CDCD808\" Id=\"SharpDevelopDocFiles\" DiskId=\"1\">\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\AssemblyBaseAddresses.txt\" Name=\"baseaddr.txt\" Id=\"AssemblyBaseAddresses2.txt\" LongName=\"AssemblyBaseAddresses.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\BuiltWithSharpDevelop.png\" Name=\"bw-sd.PNG\" Id=\"BuiltWithSharpDevelop2.png\" LongName=\"BuiltWithSharpDevelop.png\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\ChangeLog.xml\" Name=\"CHANGE_1.XML\" Id=\"ChangeLog2.xml\" LongName=\"ChangeLog.xml\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\copyright.txt\" Name=\"cpyright.txt\" Id=\"copyright2.txt\" LongName=\"copyright.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\license.txt\" Name=\"license.txt\" Id=\"license2.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\readme.rtf\" Name=\"readme.rtf\" Id=\"readme2.rtf\" />\r\n" + |
||||
"\t\t\t\t\t\t\t<File Source=\"doc\\SharpDevelopInfoResources.txt\" Name=\"Resource.txt\" Id=\"SharpDevelopInfoResources.txt\" LongName=\"SharpDevelopInfoResources.txt\" />\r\n" + |
||||
"\t\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t</Directory>\r\n" + |
||||
"\t\t\t</Directory>\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// <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.SharpDevelop.Project; |
||||
using ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Specialized; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.PackageFiles |
||||
{ |
||||
/// <summary>
|
||||
/// Adds several files to the selected component node when the component's
|
||||
/// disk id is already set. This makes sure we do not change the disk id.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ComponentDiskIdSetBeforeFilesAddedTestFixture : PackageFilesTestFixtureBase |
||||
{ |
||||
XmlElement componentElement; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
base.InitFixture(); |
||||
componentElement = (XmlElement)editor.Document.RootDirectory.ChildNodes[0].ChildNodes[0].ChildNodes[0]; |
||||
view.SelectedElement = componentElement; |
||||
editor.SelectedElementChanged(); |
||||
string exeFileName = Path.Combine(project.Directory, @"bin\TestApplication.exe"); |
||||
string readmeFileName = Path.Combine(project.Directory, @"docs\readme.rtf"); |
||||
string[] fileNames = new string[] {exeFileName, readmeFileName}; |
||||
editor.AddFiles(fileNames); |
||||
} |
||||
|
||||
[Test] |
||||
public void ComponentElementDiskId() |
||||
{ |
||||
Assert.AreEqual("2", componentElement.GetAttribute("DiskId")); |
||||
} |
||||
|
||||
protected override 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\t<Directory Id=\"ProgramFilesFolder\" Name=\"PFiles\">\r\n" + |
||||
"\t\t\t\t<Directory Id=\"INSTALLDIR\" Name=\"MyApp\">\r\n" + |
||||
"\t\t\t\t\t<Component Id=\"CoreComponents\" DiskId=\"2\">\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t</Directory>\r\n" + |
||||
"\t\t\t</Directory>\r\n" + |
||||
"\t\t</Directory>\r\n" + |
||||
"\t</Product>\r\n" + |
||||
"</Wix>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// <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.PackageFiles |
||||
{ |
||||
[TestFixture] |
||||
public class GenerateComponentIdTests |
||||
{ |
||||
[Test] |
||||
public void SimpleFileName() |
||||
{ |
||||
string fileName = "myapp.exe"; |
||||
Assert.AreEqual("MyappExe", WixComponentElement.GenerateIdFromFileName(fileName)); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoExtension() |
||||
{ |
||||
string fileName = "myapp"; |
||||
Assert.AreEqual("Myapp", WixComponentElement.GenerateIdFromFileName(fileName)); |
||||
} |
||||
|
||||
[Test] |
||||
public void OnlyExtension() |
||||
{ |
||||
string fileName = ".bat"; |
||||
Assert.AreEqual("Bat", WixComponentElement.GenerateIdFromFileName(fileName)); |
||||
} |
||||
|
||||
[Test] |
||||
public void SingleCharacterFileName() |
||||
{ |
||||
string fileName = "a.bat"; |
||||
Assert.AreEqual("ABat", WixComponentElement.GenerateIdFromFileName(fileName)); |
||||
} |
||||
|
||||
[Test] |
||||
public void EmptyString() |
||||
{ |
||||
Assert.AreEqual(String.Empty, WixComponentElement.GenerateIdFromFileName(String.Empty)); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue