Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1903 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
39 changed files with 1769 additions and 41 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// <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.Core; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Hides the diff control from the Setup Files window.
|
||||
/// </summary>
|
||||
public class HideDiffCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PackageFilesView.ActiveView.HideDiff(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
// <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.Core; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class ShowDiffCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PackageFilesView.ActiveView.ShowDiff(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the files and directories in the specified path.
|
||||
/// </summary>
|
||||
public class DirectoryReader : IDirectoryReader |
||||
{ |
||||
public string[] GetFiles(string path) |
||||
{ |
||||
return Directory.GetFiles(path); |
||||
} |
||||
|
||||
public string[] GetDirectories(string path) |
||||
{ |
||||
return Directory.GetDirectories(path); |
||||
} |
||||
|
||||
public bool DirectoryExists(string path) |
||||
{ |
||||
return Directory.Exists(path); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,126 @@
@@ -0,0 +1,126 @@
|
||||
// <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; |
||||
using System.Text; |
||||
using System.Text.RegularExpressions; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
/// <summary>
|
||||
/// A list of names (filenames or directory names) that are to
|
||||
/// be excluded.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A name can include the wildcards (*, ?) and these will be
|
||||
/// used when calling the IsExcluded method.
|
||||
/// </remarks>
|
||||
public class ExcludedNames : CollectionBase |
||||
{ |
||||
public ExcludedNames() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a name to the excluded list.
|
||||
/// </summary>
|
||||
public void Add(string name) |
||||
{ |
||||
List.Add(name); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds another ExcludedNames collection to this collection.
|
||||
/// </summary>
|
||||
public void Add(ExcludedNames names) |
||||
{ |
||||
foreach (string name in names) { |
||||
Add(name); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a list of names to the excluded list.
|
||||
/// </summary>
|
||||
public void AddRange(string[] names) |
||||
{ |
||||
foreach (string name in names) { |
||||
Add(name); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks whether the specified name is in the excluded list.
|
||||
/// If any items in the list contain wildcards then these will
|
||||
/// be expanded. This method does not just do a simple Contains
|
||||
/// on the collection of names.
|
||||
/// </summary>
|
||||
public bool IsExcluded(string name) |
||||
{ |
||||
foreach (string excludedName in List) { |
||||
if (IsMatch(excludedName, name)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks whether the specified name matches the
|
||||
/// excluded name. The excluded name can include wildcards.
|
||||
/// </summary>
|
||||
bool IsMatch(string excludedName, string name) |
||||
{ |
||||
if (ContainsWildcard(excludedName)) { |
||||
return IsWildcardMatch(excludedName, name); |
||||
} else { |
||||
return excludedName.Equals(name, StringComparison.InvariantCultureIgnoreCase); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Compares the input string against the wildcard pattern.
|
||||
/// </summary>
|
||||
bool IsWildcardMatch(string pattern, string input) |
||||
{ |
||||
string regexPattern = GetRegexFromWildcardPattern(pattern); |
||||
Regex regex = new Regex(regexPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); |
||||
Match match = regex.Match(input); |
||||
return match.Success; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Converts the wildcard string into a regex string.
|
||||
/// </summary>
|
||||
string GetRegexFromWildcardPattern(string pattern) |
||||
{ |
||||
StringBuilder regex = new StringBuilder(); |
||||
regex.Append("^"); |
||||
foreach (char ch in pattern) { |
||||
switch (ch) { |
||||
case '*': |
||||
regex.Append(".*?"); |
||||
break; |
||||
case '?': |
||||
regex.Append("."); |
||||
break; |
||||
default: |
||||
regex.Append(Regex.Escape(ch.ToString())); |
||||
break; |
||||
} |
||||
} |
||||
regex.Append("$"); |
||||
return regex.ToString(); |
||||
} |
||||
|
||||
bool ContainsWildcard(string input) |
||||
{ |
||||
return input.IndexOf('*') >= 0 || input.IndexOf('?') >= 0; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,165 @@
@@ -0,0 +1,165 @@
|
||||
// <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.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public class WixPackageFilesDiffControl : System.Windows.Forms.UserControl |
||||
{ |
||||
public WixPackageFilesDiffControl() |
||||
{ |
||||
InitializeComponent(); |
||||
InitImageList(); |
||||
InitStrings(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the no difference found message.
|
||||
/// </summary>
|
||||
public void ShowNoDiffMessage() |
||||
{ |
||||
Clear(); |
||||
ListViewItem item = new ListViewItem(); |
||||
item.SubItems.Add(StringParser.Parse("${res:ICSharpCode.WixBinding.WixPackageFilesDiffControl.NoDiffFound}")); |
||||
diffResultListView.Items.Add(item); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the list of diff results.
|
||||
/// </summary>
|
||||
public void ShowDiffResults(WixPackageFilesDiffResult[] diffResults) |
||||
{ |
||||
Clear(); |
||||
foreach (WixPackageFilesDiffResult result in diffResults) { |
||||
AddListItem(result); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Clears all the displayed diff results.
|
||||
/// </summary>
|
||||
public void Clear() |
||||
{ |
||||
diffResultListView.Items.Clear(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the control.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
#region Forms Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
void InitializeComponent() |
||||
{ |
||||
this.components = new System.ComponentModel.Container(); |
||||
this.diffResultListView = new System.Windows.Forms.ListView(); |
||||
this.diffTypeColumnHeader = new System.Windows.Forms.ColumnHeader(); |
||||
this.fileNameColumnHeader = new System.Windows.Forms.ColumnHeader(); |
||||
this.diffResultsImageList = new System.Windows.Forms.ImageList(this.components); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// diffResultListView
|
||||
//
|
||||
this.diffResultListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { |
||||
this.diffTypeColumnHeader, |
||||
this.fileNameColumnHeader}); |
||||
this.diffResultListView.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.diffResultListView.FullRowSelect = true; |
||||
this.diffResultListView.Location = new System.Drawing.Point(0, 0); |
||||
this.diffResultListView.Name = "diffResultListView"; |
||||
this.diffResultListView.Size = new System.Drawing.Size(474, 258); |
||||
this.diffResultListView.TabIndex = 0; |
||||
this.diffResultListView.UseCompatibleStateImageBehavior = false; |
||||
this.diffResultListView.View = System.Windows.Forms.View.Details; |
||||
//
|
||||
// diffTypeColumnHeader
|
||||
//
|
||||
this.diffTypeColumnHeader.Text = ""; |
||||
this.diffTypeColumnHeader.Width = 20; |
||||
//
|
||||
// fileNameColumnHeader
|
||||
//
|
||||
this.fileNameColumnHeader.Text = "File"; |
||||
this.fileNameColumnHeader.Width = 400; |
||||
//
|
||||
// diffResultsImageList
|
||||
//
|
||||
this.diffResultsImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; |
||||
this.diffResultsImageList.ImageSize = new System.Drawing.Size(16, 16); |
||||
this.diffResultsImageList.TransparentColor = System.Drawing.Color.Transparent; |
||||
//
|
||||
// WixPackageFilesDiffControl
|
||||
//
|
||||
this.Controls.Add(this.diffResultListView); |
||||
this.Name = "WixPackageFilesDiffControl"; |
||||
this.Size = new System.Drawing.Size(474, 258); |
||||
this.ResumeLayout(false); |
||||
} |
||||
private System.Windows.Forms.ImageList diffResultsImageList; |
||||
private System.Windows.Forms.ColumnHeader fileNameColumnHeader; |
||||
private System.Windows.Forms.ColumnHeader diffTypeColumnHeader; |
||||
private System.Windows.Forms.ListView diffResultListView; |
||||
|
||||
#endregion
|
||||
|
||||
int GetDiffTypeImageIndex(WixPackageFilesDiffResultType diffType) |
||||
{ |
||||
switch (diffType) { |
||||
case WixPackageFilesDiffResultType.MissingFile: |
||||
return 0; |
||||
default: |
||||
return 1; |
||||
} |
||||
} |
||||
|
||||
void AddListItem(WixPackageFilesDiffResult diffResult) |
||||
{ |
||||
ListViewItem item = new ListViewItem(); |
||||
item.ImageIndex = GetDiffTypeImageIndex(diffResult.DiffType); |
||||
item.SubItems.Add(diffResult.FileName); |
||||
diffResultListView.Items.Add(item); |
||||
} |
||||
|
||||
void InitStrings() |
||||
{ |
||||
fileNameColumnHeader.Text = StringParser.Parse("${res:CompilerResultView.FileText}"); |
||||
} |
||||
|
||||
void InitImageList() |
||||
{ |
||||
try { |
||||
diffResultListView.SmallImageList = diffResultsImageList; |
||||
diffResultsImageList.Images.Add(ResourceService.GetBitmap("Icons.16x16.Error")); |
||||
diffResultsImageList.Images.Add(ResourceService.GetBitmap("Icons.16x16.Question")); |
||||
} catch (ResourceNotFoundException) { } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,158 @@
@@ -0,0 +1,158 @@
|
||||
// <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.Core; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Compares the files specified in the WixDocument against those
|
||||
/// on the file system and returns any differences.
|
||||
/// </summary>
|
||||
public class WixPackageFilesDiff |
||||
{ |
||||
IDirectoryReader directoryReader; |
||||
List<string> searchedDirectories; |
||||
ExcludedNames excludedFileNames = new ExcludedNames(); |
||||
|
||||
public WixPackageFilesDiff() : this(new DirectoryReader()) |
||||
{ |
||||
} |
||||
|
||||
public WixPackageFilesDiff(IDirectoryReader directoryReader) |
||||
{ |
||||
this.directoryReader = directoryReader; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of filenames to exclude.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Each filename in this list does not include its full path.
|
||||
/// </remarks>
|
||||
public ExcludedNames ExcludedFileNames { |
||||
get { |
||||
return excludedFileNames; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Compares the files defined in the WixDirectoryElement against those
|
||||
/// on the file system and returns any differences.
|
||||
/// </summary>
|
||||
public WixPackageFilesDiffResult[] Compare(WixDirectoryElementBase directoryElement) |
||||
{ |
||||
List<string> wixPackageFiles = GetAllFiles(directoryElement); |
||||
List<string> files = new List<string>(); |
||||
|
||||
// Find all files on the file system based on the directories
|
||||
// used in the Wix document.
|
||||
searchedDirectories = new List<string>(); |
||||
foreach (string fileName in wixPackageFiles) { |
||||
string directory = Path.GetDirectoryName(fileName); |
||||
if (!HasDirectoryBeenSearched(directory)) { |
||||
if (directoryReader.DirectoryExists(directory)) { |
||||
foreach (string directoryFileName in directoryReader.GetFiles(directory)) { |
||||
if (!excludedFileNames.IsExcluded(directoryFileName)) { |
||||
files.Add(Path.Combine(directory, directoryFileName)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Look for new files.
|
||||
List<string> missingFiles = new List<string>(); |
||||
List<string> removedFiles = new List<string>(); |
||||
foreach (string fileName in wixPackageFiles) { |
||||
int index = GetFileNameIndex(files, fileName); |
||||
if (index >= 0) { |
||||
removedFiles.Add(files[index]); |
||||
files.RemoveAt(index); |
||||
} else { |
||||
// Check that this file has not already been removed.
|
||||
index = GetFileNameIndex(removedFiles, fileName); |
||||
if (index == -1) { |
||||
missingFiles.Add(fileName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Add new files.
|
||||
List<WixPackageFilesDiffResult> results = new List<WixPackageFilesDiffResult>(); |
||||
foreach (string fileName in files) { |
||||
results.Add(new WixPackageFilesDiffResult(fileName, WixPackageFilesDiffResultType.NewFile)); |
||||
} |
||||
|
||||
// Add missing files.
|
||||
foreach (string fileName in missingFiles) { |
||||
results.Add(new WixPackageFilesDiffResult(fileName, WixPackageFilesDiffResultType.MissingFile)); |
||||
} |
||||
|
||||
return results.ToArray(); |
||||
} |
||||
|
||||
List<string> GetAllFiles(WixDirectoryElementBase directoryElement) |
||||
{ |
||||
List<string> files = new List<string>(); |
||||
|
||||
// Get all the child directory elements.
|
||||
foreach (WixDirectoryElement childDirectoryElement in directoryElement.GetDirectories()) { |
||||
files.AddRange(GetAllFiles(childDirectoryElement)); |
||||
} |
||||
|
||||
// Get all the files from any child components.
|
||||
foreach (WixComponentElement componentElement in directoryElement.GetComponents()) { |
||||
files.AddRange(GetFileNames(componentElement.GetFiles())); |
||||
} |
||||
|
||||
return files; |
||||
} |
||||
|
||||
List<string> GetFileNames(WixFileElement[] fileElements) |
||||
{ |
||||
List<string> fileNames = new List<string>(); |
||||
foreach (WixFileElement fileElement in fileElements) { |
||||
fileNames.Add(fileElement.FileName); |
||||
} |
||||
return fileNames; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the filename in the files list.
|
||||
/// </summary>
|
||||
/// <returns>The index at which the filename exists in the list.</returns>
|
||||
int GetFileNameIndex(List<string> files, string fileName) |
||||
{ |
||||
for (int i = 0; i < files.Count; ++i) { |
||||
string currentFileName = files[i]; |
||||
if (FileUtility.IsEqualFileName(currentFileName, fileName)) { |
||||
return i; |
||||
} |
||||
} |
||||
return -1; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Makes sure that directories are only searched once.
|
||||
/// </summary>
|
||||
bool HasDirectoryBeenSearched(string directory) |
||||
{ |
||||
directory = directory.ToLowerInvariant(); |
||||
if (searchedDirectories.Contains(directory)) { |
||||
return true; |
||||
} |
||||
|
||||
// Directory not found.
|
||||
searchedDirectories.Add(directory); |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
@ -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 System; |
||||
|
||||
namespace ICSharpCode.WixBinding |
||||
{ |
||||
public enum WixPackageFilesDiffResultType |
||||
{ |
||||
/// <summary>
|
||||
/// The file in the Wix document is missing from the file system.
|
||||
/// </summary>
|
||||
MissingFile, |
||||
|
||||
/// <summary>
|
||||
/// The file is new and does not exist in the WixDocument.
|
||||
/// </summary>
|
||||
NewFile |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A difference between what is defined in the WixDocument and the
|
||||
/// files on the local file system.
|
||||
/// </summary>
|
||||
public class WixPackageFilesDiffResult |
||||
{ |
||||
string fileName = String.Empty; |
||||
WixPackageFilesDiffResultType diffType; |
||||
|
||||
public WixPackageFilesDiffResult(string fileName, WixPackageFilesDiffResultType diffType) |
||||
{ |
||||
this.fileName = fileName; |
||||
this.diffType = diffType; |
||||
} |
||||
|
||||
public WixPackageFilesDiffResultType DiffType { |
||||
get { |
||||
return diffType; |
||||
} |
||||
} |
||||
|
||||
public string FileName { |
||||
get { |
||||
return fileName; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.Diff |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that certain files and directories are ignored if they
|
||||
/// match an entry in the WixPackageFilesDiff.ExcludedFileNames.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ExcludedFilesTestFixture : IDirectoryReader |
||||
{ |
||||
WixPackageFilesDiffResult[] diffResults; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
WixPackageFilesDiff diff = new WixPackageFilesDiff(this); |
||||
diff.ExcludedFileNames.Add("*.pdb"); |
||||
diffResults = diff.Compare(doc.RootDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void OneDiffResultFound() |
||||
{ |
||||
Assert.AreEqual(1, diffResults.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void DiffResultFileName() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\Setup\bin\newfile.txt", diffResults[0].FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void DiffResultType() |
||||
{ |
||||
Assert.AreEqual(WixPackageFilesDiffResultType.NewFile, diffResults[0].DiffType); |
||||
} |
||||
|
||||
public string[] GetFiles(string path) |
||||
{ |
||||
return new string[] {"license.rtf", "newfile.txt", "myapp.pdb"}; |
||||
} |
||||
|
||||
public string[] GetDirectories(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
public bool DirectoryExists(string path) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\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,93 @@
@@ -0,0 +1,93 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.Diff |
||||
{ |
||||
[TestFixture] |
||||
public class NoDifferentFilesTestFixture : IDirectoryReader |
||||
{ |
||||
WixPackageFilesDiffResult[] diffResults; |
||||
List<string> directories; |
||||
List<string> directoryExistsChecks; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
directories = new List<string>(); |
||||
directoryExistsChecks = new List<string>(); |
||||
WixDocument doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
WixPackageFilesDiff diff = new WixPackageFilesDiff(this); |
||||
diffResults = diff.Compare(doc.RootDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoDiffResultsFound() |
||||
{ |
||||
Assert.AreEqual(0, diffResults.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void FilesRequestedFromDirectory() |
||||
{ |
||||
Assert.AreEqual(1, directories.Count); |
||||
Assert.AreEqual(@"C:\Projects\Setup\bin", directories[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void DirectoryExistsChecks() |
||||
{ |
||||
Assert.AreEqual(1, directoryExistsChecks.Count); |
||||
Assert.AreEqual(@"C:\Projects\Setup\bin", directoryExistsChecks[0]); |
||||
} |
||||
|
||||
public string[] GetFiles(string path) |
||||
{ |
||||
directories.Add(path); |
||||
return new string[] {@"license.rtf"}; |
||||
} |
||||
|
||||
public string[] GetDirectories(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
public bool DirectoryExists(string path) |
||||
{ |
||||
directoryExistsChecks.Add(path); |
||||
return true; |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\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,85 @@
@@ -0,0 +1,85 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.Diff |
||||
{ |
||||
[TestFixture] |
||||
public class OneMissingFileTestFixture : IDirectoryReader |
||||
{ |
||||
WixPackageFilesDiffResult[] diffResults; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
WixPackageFilesDiff diff = new WixPackageFilesDiff(this); |
||||
diffResults = diff.Compare(doc.RootDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void OneDiffResultFound() |
||||
{ |
||||
Assert.AreEqual(1, diffResults.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void DiffResultFileName() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\Setup\doc\license.rtf", diffResults[0].FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void DiffResultType() |
||||
{ |
||||
Assert.AreEqual(WixPackageFilesDiffResultType.MissingFile, diffResults[0].DiffType); |
||||
} |
||||
|
||||
public string[] GetFiles(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
public string[] GetDirectories(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
public bool DirectoryExists(string path) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='doc\\license.rtf' />\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,85 @@
@@ -0,0 +1,85 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.Diff |
||||
{ |
||||
[TestFixture] |
||||
public class OneNewFileTestFixture : IDirectoryReader |
||||
{ |
||||
WixPackageFilesDiffResult[] diffResults; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
WixPackageFilesDiff diff = new WixPackageFilesDiff(this); |
||||
diffResults = diff.Compare(doc.RootDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void OneDiffResultFound() |
||||
{ |
||||
Assert.AreEqual(1, diffResults.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void DiffResultFileName() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\Setup\bin\newfile.txt", diffResults[0].FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void DiffResultType() |
||||
{ |
||||
Assert.AreEqual(WixPackageFilesDiffResultType.NewFile, diffResults[0].DiffType); |
||||
} |
||||
|
||||
public string[] GetFiles(string path) |
||||
{ |
||||
return new string[] {@"license.rtf", @"newfile.txt"}; |
||||
} |
||||
|
||||
public string[] GetDirectories(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
public bool DirectoryExists(string path) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\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,78 @@
@@ -0,0 +1,78 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.Diff |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that we do not get a missing file diff when the wix document
|
||||
/// refers to the same file twice.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class SameFileReferencedTwiceTestFixture : IDirectoryReader |
||||
{ |
||||
WixPackageFilesDiffResult[] diffResults; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
WixPackageFilesDiff diff = new WixPackageFilesDiff(this); |
||||
diffResults = diff.Compare(doc.RootDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoDiffResultsFound() |
||||
{ |
||||
Assert.AreEqual(0, diffResults.Length); |
||||
} |
||||
|
||||
public string[] GetFiles(string path) |
||||
{ |
||||
return new string[] {@"license.rtf"}; |
||||
} |
||||
|
||||
public string[] GetDirectories(string path) |
||||
{ |
||||
return new string[0]; |
||||
} |
||||
|
||||
public bool DirectoryExists(string path) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile2' Name='license2.rtf' Source='bin\\license.rtf' />\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,61 @@
@@ -0,0 +1,61 @@
|
||||
// <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 |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the ExcludedNames class's IsExcluded method.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ExcludedNamesTests |
||||
{ |
||||
ExcludedNames excludedNames; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
excludedNames = new ExcludedNames(); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTextFilesExcluded() |
||||
{ |
||||
excludedNames.Add("*.txt"); |
||||
|
||||
Assert.IsTrue(excludedNames.IsExcluded("readme.txt")); |
||||
} |
||||
|
||||
[Test] |
||||
public void CaseInsensitive() |
||||
{ |
||||
excludedNames.Add("readme.txt"); |
||||
Assert.IsTrue(excludedNames.IsExcluded("README.TXT")); |
||||
} |
||||
|
||||
[Test] |
||||
public void SingleCharacterWildcard() |
||||
{ |
||||
excludedNames.Add("test?.txt"); |
||||
|
||||
Assert.IsTrue(excludedNames.IsExcluded("test1.txt")); |
||||
Assert.IsFalse(excludedNames.IsExcluded("test.txt")); |
||||
} |
||||
|
||||
[Test] |
||||
public void RegexInExcludedName() |
||||
{ |
||||
excludedNames.Add("?tes(ab)+.txt"); |
||||
|
||||
Assert.IsTrue(excludedNames.IsExcluded("Ates(ab)+.txt")); |
||||
Assert.IsFalse(excludedNames.IsExcluded("Atesababab.txt")); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
// <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.IO; |
||||
using System.Xml; |
||||
|
||||
namespace WixBinding.Tests.Document |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the WixDirectory object correctly identifies its own child
|
||||
/// components.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ChildComponentsTestFixture |
||||
{ |
||||
WixComponentElement[] childComponents; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
WixDocument doc = new WixDocument(); |
||||
doc.LoadXml(GetWixXml()); |
||||
WixDirectoryElement rootDirectory = doc.RootDirectory; |
||||
WixDirectoryElement[] rootChildDirectories = rootDirectory.GetDirectories(); |
||||
WixDirectoryElement programFilesDirectory = rootChildDirectories[0]; |
||||
WixDirectoryElement[] programFilesChildDirectories = programFilesDirectory.GetDirectories(); |
||||
WixDirectoryElement myAppDirectory = programFilesChildDirectories[0]; |
||||
childComponents = myAppDirectory.GetComponents(); |
||||
} |
||||
|
||||
[Test] |
||||
public void TwoChildComponents() |
||||
{ |
||||
Assert.AreEqual(2, childComponents.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void FirstComponentId() |
||||
{ |
||||
Assert.AreEqual("ComponentOne", childComponents[0].Id); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondComponentId() |
||||
{ |
||||
Assert.AreEqual("ComponentTwo", childComponents[1].Id); |
||||
} |
||||
|
||||
string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='DialogTest' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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=\"MyApp\" SourceName=\"MyAppSrc\" Name=\"MyApp\" LongName=\"My Application\">\r\n" + |
||||
"\t\t\t\t\t<Component Id='ComponentOne'/>\r\n"+ |
||||
"\t\t\t\t\t<Component Id='ComponentTwo'/>\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,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 ICSharpCode.WixBinding; |
||||
using NUnit.Framework; |
||||
using System; |
||||
|
||||
namespace WixBinding.Tests.Document |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the WixFileElement GetFiles method and its FileName property.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ChildFilesTestFixture |
||||
{ |
||||
WixDocument doc; |
||||
WixFileElement[] files; |
||||
|
||||
[SetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
doc = new WixDocument(); |
||||
doc.FileName = @"C:\Projects\Setup\Setup.wxs"; |
||||
doc.LoadXml(GetWixXml()); |
||||
WixDirectoryElement rootDirectory = doc.RootDirectory; |
||||
WixDirectoryElement[] rootChildDirectories = rootDirectory.GetDirectories(); |
||||
WixDirectoryElement programFilesDirectory = rootChildDirectories[0]; |
||||
WixDirectoryElement[] programFilesChildDirectories = programFilesDirectory.GetDirectories(); |
||||
WixDirectoryElement myAppDirectory = programFilesChildDirectories[0]; |
||||
WixComponentElement[] childComponents = myAppDirectory.GetComponents(); |
||||
WixComponentElement coreComponent = childComponents[0]; |
||||
files = coreComponent.GetFiles(); |
||||
} |
||||
|
||||
[Test] |
||||
public void TwoFiles() |
||||
{ |
||||
Assert.AreEqual(2, files.Length); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The filename should not include the ".." part.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void FirstFileElementFileName() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\doc\license.rtf", files[0].FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondFileElementFileName() |
||||
{ |
||||
Assert.AreEqual(@"C:\Projects\Setup\bin\myapp.exe", files[1].FileName); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Tests that the WixFileElement.FileName property returns the
|
||||
/// relative filename if no filename is given to the WixDocument.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void RelativeFileNameUsed() |
||||
{ |
||||
doc.FileName = String.Empty; |
||||
Assert.AreEqual(@"..\doc\license.rtf", files[0].FileName); |
||||
Assert.AreEqual(@"bin\myapp.exe", files[1].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\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\">\r\n" + |
||||
"\t\t\t\t\t\t<File Id=\"LicenseFile\" Name=\"license.rtf\" Source=\"..\\doc\\license.rtf\" />\r\n" + |
||||
"\t\t\t\t\t\t<File Id=\"ExeFile\" Name=\"MyApp.exe\" Source=\"bin\\myapp.exe\" />\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,63 @@
@@ -0,0 +1,63 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.PackageFiles |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that no diff is shown in the IWixPackageFilesView via
|
||||
/// the WixPackagesFileEditor
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class NoDiffShownTestFixture : PackageFilesTestFixtureBase |
||||
{ |
||||
List<string> directories; |
||||
|
||||
[Test] |
||||
public void NoDirectorySelected() |
||||
{ |
||||
base.InitFixture(); |
||||
directories = new List<string>(); |
||||
editor.ShowDiff(); |
||||
Assert.IsTrue(view.IsNoDifferencesFoundMessageDisplayed); |
||||
Assert.AreEqual(1, directories.Count); |
||||
Assert.AreEqual(@"C:\Projects\Test\bin", directories[0]); |
||||
} |
||||
|
||||
public override string[] GetFiles(string path) |
||||
{ |
||||
directories.Add(path); |
||||
return new string[] {@"license.rtf"}; |
||||
} |
||||
|
||||
protected override string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\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,87 @@
@@ -0,0 +1,87 @@
|
||||
// <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.Collections.Generic; |
||||
|
||||
namespace WixBinding.Tests.PackageFiles |
||||
{ |
||||
[TestFixture] |
||||
public class OneNewFileDiffTestFixture : PackageFilesTestFixtureBase |
||||
{ |
||||
WixDirectoryElement installDirectory; |
||||
WixDirectoryElement binDirectory; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
base.InitFixture(); |
||||
editor.ExcludedItems.AddRange(new string[] {"*.pdb"}); |
||||
WixDirectoryElement programFilesDirectory = (WixDirectoryElement)editor.Document.RootDirectory.FirstChild; |
||||
installDirectory = (WixDirectoryElement)programFilesDirectory.FirstChild; |
||||
binDirectory = (WixDirectoryElement)installDirectory.LastChild; |
||||
} |
||||
|
||||
[Test] |
||||
public void InstallDirectorySelected() |
||||
{ |
||||
view.SelectedElement = installDirectory; |
||||
editor.ShowDiff(); |
||||
Assert.AreEqual(1, view.DiffResults.Length); |
||||
Assert.AreEqual(@"C:\Projects\Test\doc\files\newfile.txt", view.DiffResults[0].FileName); |
||||
Assert.AreEqual(WixPackageFilesDiffResultType.NewFile, view.DiffResults[0].DiffType); |
||||
Assert.IsTrue(view.SelectedElementAccessed); |
||||
} |
||||
|
||||
[Test] |
||||
public void BinDirectorySelected() |
||||
{ |
||||
view.SelectedElement = binDirectory; |
||||
editor.ShowDiff(); |
||||
Assert.IsTrue(view.IsNoDifferencesFoundMessageDisplayed); |
||||
} |
||||
|
||||
public override string[] GetFiles(string path) |
||||
{ |
||||
if (path == @"C:\Projects\Test\doc\files") { |
||||
return new string[] {@"license.rtf", "readme.txt", "newfile.txt"}; |
||||
} else { |
||||
return new string[] {@"myapp.exe", "myapp.pdb"}; |
||||
} |
||||
} |
||||
|
||||
protected override string GetWixXml() |
||||
{ |
||||
return "<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>\r\n" + |
||||
"\t<Product Name='Test' \r\n" + |
||||
"\t Version='1.0' \r\n" + |
||||
"\t Language='1013' \r\n" + |
||||
"\t Manufacturer='#develop' \r\n" + |
||||
"\t Id='????????-????-????-????-????????????'>\r\n" + |
||||
"\t\t<Package/>\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='YourApp' LongName='Your Application'>\r\n" + |
||||
"\t\t\t\t\t<Component Id='DocComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='doc\\files\\license.rtf' />\r\n" + |
||||
"\t\t\t\t\t\t<File Id='ReadMe' Name='readme.txt' Source='DOC/files\\readme.txt' />\r\n" + |
||||
"\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t<Directory Id='bin' Name='bin'>\r\n" + |
||||
"\t\t\t\t\t\t<Component Id='BinComponent' DiskId='1'>\r\n" + |
||||
"\t\t\t\t\t\t\t<File Id='MyAppExe' Name='myapp.exe' Source='bin\\myapp.exe' />\r\n" + |
||||
"\t\t\t\t\t\t</Component>\r\n" + |
||||
"\t\t\t\t\t</Directory>\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,60 @@
@@ -0,0 +1,60 @@
|
||||
// <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 WixBinding.Tests.Utils; |
||||
|
||||
namespace WixBinding.Tests.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the WixProject.CanCompile method determines that
|
||||
/// .wxs or .wxi files are compilable.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class CanCompileTests |
||||
{ |
||||
WixProject project; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
project = WixBindingTestsHelper.CreateEmptyWixProject(); |
||||
} |
||||
|
||||
[Test] |
||||
public void WixSourceFile() |
||||
{ |
||||
Assert.IsTrue(project.CanCompile("Setup.wxs")); |
||||
} |
||||
|
||||
[Test] |
||||
public void UppercaseWixSourceFileExtension() |
||||
{ |
||||
Assert.IsTrue(project.CanCompile("SETUP.WXS")); |
||||
} |
||||
|
||||
[Test] |
||||
public void WixIncludeFile() |
||||
{ |
||||
Assert.IsTrue(project.CanCompile("files.wxi")); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResourceFile() |
||||
{ |
||||
Assert.IsFalse(project.CanCompile("MainForm.resx")); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextFile() |
||||
{ |
||||
Assert.IsFalse(project.CanCompile("readme.txt")); |
||||
} |
||||
} |
||||
} |
||||
Binary file not shown.
Loading…
Reference in new issue