Browse Source

Added new WiX Setup Files Diff feature. The Setup Files pad can now show the difference between the files defined in the setup and the files that actually exist on the file system. Changed the WiXProject class so only WiX source files .wxs and WiX include files .wxi have their build action set to Compile when new files are added to a WiX project.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1903 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
98eec4f64b
  1. BIN
      data/resources/StringResources.cz.resources
  2. BIN
      data/resources/StringResources.de.resources
  3. BIN
      data/resources/StringResources.es-mx.resources
  4. BIN
      data/resources/StringResources.es.resources
  5. BIN
      data/resources/StringResources.nl.resources
  6. 23
      src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/HideDiffCommand.cs
  7. 20
      src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/ShowDiffCommand.cs
  8. 33
      src/AddIns/BackendBindings/WixBinding/Project/Src/DirectoryReader.cs
  9. 126
      src/AddIns/BackendBindings/WixBinding/Project/Src/ExcludedNames.cs
  10. 10
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs
  11. 111
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesControl.cs
  12. 165
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesDiffControl.cs
  13. 5
      src/AddIns/BackendBindings/WixBinding/Project/Src/IDirectoryReader.cs
  14. 13
      src/AddIns/BackendBindings/WixBinding/Project/Src/IWixPackageFilesView.cs
  15. 12
      src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
  16. 16
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixComponentElement.cs
  17. 15
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElementBase.cs
  18. 18
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixFileElement.cs
  19. 158
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiff.cs
  20. 52
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiffResult.cs
  21. 91
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesEditor.cs
  22. 13
      src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin
  23. 7
      src/AddIns/BackendBindings/WixBinding/Project/WixBinding.csproj
  24. 90
      src/AddIns/BackendBindings/WixBinding/Test/Diff/ExcludedFilesTestFixture.cs
  25. 93
      src/AddIns/BackendBindings/WixBinding/Test/Diff/NoDifferentFilesTestFixture.cs
  26. 85
      src/AddIns/BackendBindings/WixBinding/Test/Diff/OneMissingFileTestFixture.cs
  27. 85
      src/AddIns/BackendBindings/WixBinding/Test/Diff/OneNewFileTestFixture.cs
  28. 78
      src/AddIns/BackendBindings/WixBinding/Test/Diff/SameFileReferencedTwiceTestFixture.cs
  29. 61
      src/AddIns/BackendBindings/WixBinding/Test/DirectoryImport/ExcludedNamesTests.cs
  30. 77
      src/AddIns/BackendBindings/WixBinding/Test/Document/ChildComponentsTestFixture.cs
  31. 95
      src/AddIns/BackendBindings/WixBinding/Test/Document/ChildFilesTestFixture.cs
  32. 63
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoDiffShownTestFixture.cs
  33. 7
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoRootDirectoryInWixProductFileTestFixture.cs
  34. 87
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/OneNewFileDiffTestFixture.cs
  35. 5
      src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesTestFixtureBase.cs
  36. 60
      src/AddIns/BackendBindings/WixBinding/Test/Project/CanCompileTests.cs
  37. 24
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWixPackageFilesView.cs
  38. 12
      src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
  39. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.cz.resources

Binary file not shown.

BIN
data/resources/StringResources.de.resources

Binary file not shown.

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

23
src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/HideDiffCommand.cs

@ -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();
}
}
}

20
src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/ShowDiffCommand.cs

@ -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();
}
}
}

33
src/AddIns/BackendBindings/WixBinding/Project/Src/DirectoryReader.cs

@ -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);
}
}
}

126
src/AddIns/BackendBindings/WixBinding/Project/Src/ExcludedNames.cs

@ -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;
}
}
}

10
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs

@ -156,6 +156,16 @@ namespace ICSharpCode.WixBinding @@ -156,6 +156,16 @@ namespace ICSharpCode.WixBinding
packageFilesControl.AddDirectory();
}
public void ShowDiff()
{
packageFilesControl.ShowDiff();
}
public void HideDiff()
{
packageFilesControl.IsDiffVisible = false;
}
/// <summary>
/// Gets the package files view that is already open and displaying the files
/// for the specified project.

111
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesControl.cs

@ -21,6 +21,7 @@ namespace ICSharpCode.WixBinding @@ -21,6 +21,7 @@ namespace ICSharpCode.WixBinding
public class WixPackageFilesControl : System.Windows.Forms.UserControl, IWixPackageFilesView
{
bool errorMessageTextBoxVisible;
bool diffVisible;
WixPackageFilesEditor editor;
bool dirty;
WixProject project;
@ -30,6 +31,7 @@ namespace ICSharpCode.WixBinding @@ -30,6 +31,7 @@ namespace ICSharpCode.WixBinding
public WixPackageFilesControl()
{
InitializeComponent();
diffControl.ContextMenuStrip = MenuService.CreateContextMenu(this, "/AddIns/WixBinding/WixPackageFilesDiffControl/ContextMenu");
}
public delegate void DirtyChangedEventHandler(object source, EventArgs e);
@ -70,6 +72,25 @@ namespace ICSharpCode.WixBinding @@ -70,6 +72,25 @@ namespace ICSharpCode.WixBinding
}
}
/// <summary>
/// Shows or hides the diff panel.
/// </summary>
public bool IsDiffVisible {
get {
return diffVisible;
}
set {
if (diffVisible != value) {
diffVisible = value;
if (diffVisible) {
ShowDiffPanel();
} else {
HideDiffPanel();
}
}
}
}
/// <summary>
/// Gets the project that is currently being displayed.
/// </summary>
@ -173,7 +194,7 @@ namespace ICSharpCode.WixBinding @@ -173,7 +194,7 @@ namespace ICSharpCode.WixBinding
{
ShowErrorMessage(StringParser.Parse("${res:ICSharpCode.WixBinding.PackageFilesView.AllWixFilesContainErrorsMessage}"));
}
/// <summary>
/// Removes the selected element from the view only. The document is not
/// changed by this method.
@ -250,6 +271,31 @@ namespace ICSharpCode.WixBinding @@ -250,6 +271,31 @@ namespace ICSharpCode.WixBinding
{
editor.Save();
}
public void ShowNoDifferenceFoundMessage()
{
IsDiffVisible = true;
diffControl.ShowNoDiffMessage();
}
/// <summary>
/// Shows the specified diff results.
/// </summary>
public void ShowDiffResults(WixPackageFilesDiffResult[] diffResults)
{
IsDiffVisible = true;
diffControl.ShowDiffResults(diffResults);
}
/// <summary>
/// Determines any differences between the files defined in the
/// Wix document and the files on the file system and displays
/// the results.
/// </summary>
public void ShowDiff()
{
editor.ShowDiff();
}
/// <summary>
/// Disposes resources used by the control.
@ -285,9 +331,13 @@ namespace ICSharpCode.WixBinding @@ -285,9 +331,13 @@ namespace ICSharpCode.WixBinding
this.packageFilesTreeView = new ICSharpCode.WixBinding.WixPackageFilesTreeView();
this.propertyGrid = new System.Windows.Forms.PropertyGrid();
this.errorMessageTextBox = new System.Windows.Forms.RichTextBox();
this.diffSplitContainer = new System.Windows.Forms.SplitContainer();
this.diffControl = new ICSharpCode.WixBinding.WixPackageFilesDiffControl();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.diffSplitContainer.Panel2.SuspendLayout();
this.diffSplitContainer.SuspendLayout();
this.SuspendLayout();
//
// splitContainer
@ -304,6 +354,7 @@ namespace ICSharpCode.WixBinding @@ -304,6 +354,7 @@ namespace ICSharpCode.WixBinding
//
this.splitContainer.Panel2.Controls.Add(this.propertyGrid);
this.splitContainer.Panel2.Controls.Add(this.errorMessageTextBox);
this.splitContainer.Panel2.Controls.Add(this.diffSplitContainer);
this.splitContainer.Size = new System.Drawing.Size(561, 328);
this.splitContainer.SplitterDistance = 186;
this.splitContainer.TabIndex = 0;
@ -320,6 +371,7 @@ namespace ICSharpCode.WixBinding @@ -320,6 +371,7 @@ namespace ICSharpCode.WixBinding
this.packageFilesTreeView.Location = new System.Drawing.Point(0, 0);
this.packageFilesTreeView.Name = "packageFilesTreeView";
this.packageFilesTreeView.NodeSorter = extTreeViewComparer1;
this.packageFilesTreeView.SelectedElement = null;
this.packageFilesTreeView.SelectedImageIndex = 0;
this.packageFilesTreeView.Size = new System.Drawing.Size(186, 328);
this.packageFilesTreeView.TabIndex = 0;
@ -347,6 +399,29 @@ namespace ICSharpCode.WixBinding @@ -347,6 +399,29 @@ namespace ICSharpCode.WixBinding
this.errorMessageTextBox.TabIndex = 2;
this.errorMessageTextBox.Text = "";
//
// diffSplitContainer
//
this.diffSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.diffSplitContainer.Location = new System.Drawing.Point(0, 0);
this.diffSplitContainer.Name = "diffSplitContainer";
this.diffSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// diffSplitContainer.Panel2
//
this.diffSplitContainer.Panel2.Controls.Add(this.diffControl);
this.diffSplitContainer.Size = new System.Drawing.Size(371, 328);
this.diffSplitContainer.SplitterDistance = 159;
this.diffSplitContainer.TabIndex = 3;
this.diffSplitContainer.TabStop = false;
//
// diffControl
//
this.diffControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.diffControl.Location = new System.Drawing.Point(0, 0);
this.diffControl.Name = "diffControl";
this.diffControl.Size = new System.Drawing.Size(371, 165);
this.diffControl.TabIndex = 0;
//
// WixPackageFilesControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -357,8 +432,12 @@ namespace ICSharpCode.WixBinding @@ -357,8 +432,12 @@ namespace ICSharpCode.WixBinding
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
this.splitContainer.ResumeLayout(false);
this.diffSplitContainer.Panel2.ResumeLayout(false);
this.diffSplitContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
private ICSharpCode.WixBinding.WixPackageFilesDiffControl diffControl;
private System.Windows.Forms.SplitContainer diffSplitContainer;
private System.Windows.Forms.RichTextBox errorMessageTextBox;
private System.Windows.Forms.PropertyGrid propertyGrid;
private ICSharpCode.WixBinding.WixPackageFilesTreeView packageFilesTreeView;
@ -419,5 +498,35 @@ namespace ICSharpCode.WixBinding @@ -419,5 +498,35 @@ namespace ICSharpCode.WixBinding
List<string> extensions = AddInTree.BuildItems<string>("/AddIns/WixBinding/ExcludedItems", this);
return extensions.ToArray();
}
void ShowDiffPanel()
{
// Add property grid to split container.
splitContainer.Panel2.Controls.Remove(propertyGrid);
diffSplitContainer.Panel1.Controls.Add(propertyGrid);
// Fix the tab order.
diffSplitContainer.TabStop = true;
// Bring the split container to the front.
diffSplitContainer.BringToFront();
}
void HideDiffPanel()
{
// Remove the property grid from the split container back to
// this control.
diffSplitContainer.Panel1.Controls.Remove(propertyGrid);
splitContainer.Panel2.Controls.Add(propertyGrid);
// Fix the tab order.
diffSplitContainer.TabStop = false;
// Send the diff split container to the back.
diffSplitContainer.SendToBack();
// Bring the property grid back to the front.
propertyGrid.BringToFront();
}
}
}

165
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesDiffControl.cs

@ -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) { }
}
}
}

5
src/AddIns/BackendBindings/WixBinding/Project/Src/IDirectoryReader.cs

@ -25,5 +25,10 @@ namespace ICSharpCode.WixBinding @@ -25,5 +25,10 @@ namespace ICSharpCode.WixBinding
/// Gets the directories in the specified path.
/// </summary>
string[] GetDirectories(string path);
/// <summary>
/// Checks whether the specified directory exists.
/// </summary>
bool DirectoryExists(string path);
}
}

13
src/AddIns/BackendBindings/WixBinding/Project/Src/IWixPackageFilesView.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.WixBinding @@ -30,7 +30,7 @@ namespace ICSharpCode.WixBinding
/// files could not be read because they contain errors.
/// </summary>
void ShowSourceFilesContainErrorsMessage();
/// <summary>
/// Adds the directories that will be displayed. Each directory may contain its
/// own directories.
@ -77,5 +77,16 @@ namespace ICSharpCode.WixBinding @@ -77,5 +77,16 @@ namespace ICSharpCode.WixBinding
/// Gets the element names that can be added as children to the selected element.
/// </summary>
StringCollection AllowedChildElements {get;}
/// <summary>
/// Displays the message that no difference was found between
/// the files in the Wix document and those on the file system.
/// </summary>
void ShowNoDifferenceFoundMessage();
/// <summary>
/// Displays the diff results.
/// </summary>
void ShowDiffResults(WixPackageFilesDiffResult[] diffResults);
}
}

12
src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs

@ -203,6 +203,18 @@ namespace ICSharpCode.WixBinding @@ -203,6 +203,18 @@ namespace ICSharpCode.WixBinding
return null;
}
/// <summary>
/// Checks whether the specified file can be compiled by the
/// Wix project.
/// </summary>
/// <returns>
/// <see langword="true"/> if the file is a WiX source file (.wxs)
/// or a WiX include file (.wxi).</returns>
public override bool CanCompile(string fileName)
{
return WixDocument.IsWixFileName(fileName);
}
/// <summary>
/// Creates a WixProject with the default settings in its MSBuild file.
/// </summary>

16
src/AddIns/BackendBindings/WixBinding/Project/Src/WixComponentElement.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
@ -134,6 +135,21 @@ namespace ICSharpCode.WixBinding @@ -134,6 +135,21 @@ namespace ICSharpCode.WixBinding
return String.Concat(idStart, idEnd);
}
/// <summary>
/// Gets any child file elements.
/// </summary>
public WixFileElement[] GetFiles()
{
List<WixFileElement> files = new List<WixFileElement>();
foreach (XmlNode childNode in ChildNodes) {
WixFileElement childElement = childNode as WixFileElement;
if (childElement != null) {
files.Add(childElement);
}
}
return files.ToArray();
}
/// <summary>
/// Upper cases first character of string.
/// </summary>

15
src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElementBase.cs

@ -54,6 +54,21 @@ namespace ICSharpCode.WixBinding @@ -54,6 +54,21 @@ namespace ICSharpCode.WixBinding
}
return directories.ToArray();
}
/// <summary>
/// Gets any child component elements.
/// </summary>
public WixComponentElement[] GetComponents()
{
List<WixComponentElement> components = new List<WixComponentElement>();
foreach (XmlNode childNode in ChildNodes) {
WixComponentElement childElement = childNode as WixComponentElement;
if (childElement != null) {
components.Add(childElement);
}
}
return components.ToArray();
}
/// <summary>
/// Adds a new directory with the specified name and id. A short name

18
src/AddIns/BackendBindings/WixBinding/Project/Src/WixFileElement.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.WixBinding @@ -60,7 +60,7 @@ namespace ICSharpCode.WixBinding
/// <summary>
/// Gets the filename where the resource being added to the setup
/// package can be found. Typically this isrelative to the Wix document the
/// package can be found. Typically this is relative to the Wix document the
/// File element is a part of.
/// </summary>
public string Source {
@ -105,6 +105,22 @@ namespace ICSharpCode.WixBinding @@ -105,6 +105,22 @@ namespace ICSharpCode.WixBinding
}
}
/// <summary>
/// Gets the full path to the file. If the parent WixDocument
/// has no filename then the relative path as stored in the
/// wix document is returned.
/// </summary>
public string FileName {
get {
WixDocument document = OwnerDocument as WixDocument;
if (document != null && !String.IsNullOrEmpty(document.FileName)) {
string directory = Path.GetDirectoryName(document.FileName);
return Path.GetFullPath(Path.Combine(directory, Source));
}
return Source;
}
}
/// <summary>
/// Valid Id letters are letters A-Z, a-z, underscores, digits and periods.
/// </summary>

158
src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiff.cs

@ -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;
}
}
}

52
src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiffResult.cs

@ -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;
}
}
}
}

91
src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesEditor.cs

@ -28,23 +28,7 @@ namespace ICSharpCode.WixBinding @@ -28,23 +28,7 @@ namespace ICSharpCode.WixBinding
static WixDocument document;
WixSchemaCompletionData wixSchemaCompletionData;
bool usingRootDirectoryRef;
StringCollection excludedItems = new StringCollection();
/// <summary>
/// Gets the files and directories in the specified path.
/// </summary>
class DefaultDirectoryReader : IDirectoryReader
{
public string[] GetFiles(string path)
{
return Directory.GetFiles(path);
}
public string[] GetDirectories(string path)
{
return Directory.GetDirectories(path);
}
}
ExcludedNames excludedNames = new ExcludedNames();
/// <summary>
/// Creates a new instance of the WixPackageFilesEditor.
@ -70,7 +54,7 @@ namespace ICSharpCode.WixBinding @@ -70,7 +54,7 @@ namespace ICSharpCode.WixBinding
/// the default directory reader which just uses the Directory class.
/// </summary>
public WixPackageFilesEditor(IWixPackageFilesView view, ITextFileReader fileReader, IWixDocumentWriter documentWriter)
: this(view, fileReader, documentWriter, new DefaultDirectoryReader())
: this(view, fileReader, documentWriter, new DirectoryReader())
{
}
@ -227,9 +211,39 @@ namespace ICSharpCode.WixBinding @@ -227,9 +211,39 @@ namespace ICSharpCode.WixBinding
/// List of files and directory names that will be excluded when
/// adding a directory to the package.
/// </summary>
public StringCollection ExcludedItems {
public ExcludedNames ExcludedItems {
get {
return excludedItems;
return excludedNames;
}
}
/// <summary>
/// Works out any differences betweent the files specified in
/// the Wix document and the files on the file system and
/// shows the differences.
/// </summary>
public void ShowDiff()
{
WixPackageFilesDiff diff = new WixPackageFilesDiff(directoryReader);
diff.ExcludedFileNames.Add(excludedNames);
WixDirectoryElementBase directoryElement = view.SelectedElement as WixDirectoryElementBase;
if (directoryElement == null) {
directoryElement = RootDirectoryElement;
}
// Directory element selected?
if (directoryElement == null) {
view.ShowNoDifferenceFoundMessage();
return;
}
// Show diff results
WixPackageFilesDiffResult[] diffResults = diff.Compare(directoryElement);
if (diffResults.Length > 0) {
view.ShowDiffResults(diffResults);
} else {
view.ShowNoDifferenceFoundMessage();
}
}
@ -298,18 +312,28 @@ namespace ICSharpCode.WixBinding @@ -298,18 +312,28 @@ namespace ICSharpCode.WixBinding
WixDirectoryElement AddDirectory(WixDirectoryElementBase parentElement, string name)
{
if (parentElement == null) {
if (usingRootDirectoryRef) {
parentElement = document.RootDirectoryRef;
} else {
parentElement = document.RootDirectory;
if (parentElement == null) {
parentElement = document.AddRootDirectory();
}
parentElement = RootDirectoryElement;
if (parentElement == null) {
parentElement = document.AddRootDirectory();
}
}
return parentElement.AddDirectory(name);
}
/// <summary>
/// Gets the root directory element being used in the document.
/// Takes into account whether the WixDocument is using a
/// DirectoryRef element.
/// </summary>
WixDirectoryElementBase RootDirectoryElement {
get {
if (usingRootDirectoryRef) {
return document.RootDirectoryRef;
}
return document.RootDirectory;
}
}
WixSchemaCompletionData WixSchemaCompletionData {
get {
if (wixSchemaCompletionData == null) {
@ -391,7 +415,7 @@ namespace ICSharpCode.WixBinding @@ -391,7 +415,7 @@ namespace ICSharpCode.WixBinding
void AddFiles(WixDirectoryElement directoryElement, string directory)
{
foreach (string fileName in DirectoryReader.GetFiles(directory)) {
if (!IsExcluded(fileName)) {
if (!excludedNames.IsExcluded(fileName)) {
string path = Path.Combine(directory, fileName);
string id = WixComponentElement.GenerateIdFromFileName(document, path);
WixComponentElement component = AddComponent(directoryElement, id);
@ -416,7 +440,7 @@ namespace ICSharpCode.WixBinding @@ -416,7 +440,7 @@ namespace ICSharpCode.WixBinding
{
foreach (string subDirectory in DirectoryReader.GetDirectories(directory)) {
string subDirectoryName = WixDirectoryElement.GetLastDirectoryName(subDirectory);
if (!IsExcluded(subDirectoryName)) {
if (!excludedNames.IsExcluded(subDirectoryName)) {
WixDirectoryElement subDirectoryElement = AddDirectory(directoryElement, subDirectoryName);
AddFiles(subDirectoryElement, subDirectory);
@ -425,14 +449,5 @@ namespace ICSharpCode.WixBinding @@ -425,14 +449,5 @@ namespace ICSharpCode.WixBinding
}
}
}
/// <summary>
/// Checks whether the specified filename or directory name should be
/// excluded.
/// </summary>
bool IsExcluded(string name)
{
return excludedItems.Contains(name);
}
}
}

13
src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin

@ -191,6 +191,9 @@ @@ -191,6 +191,9 @@
<MenuItem id = "AddDirectory"
label = "${res:ICSharpCode.WixBinding.PackagesFilesView.ContextMenu.AddDirectory}"
class = "ICSharpCode.WixBinding.AddDirectoryCommand"/>
<MenuItem id = "Diff"
label = "Diff"
class = "ICSharpCode.WixBinding.ShowDiffCommand"/>
<Include path = "/AddIns/WixBinding/PackageFilesView/ContextMenu/Common"/>
</Path>
@ -218,6 +221,9 @@ @@ -218,6 +221,9 @@
<MenuItem id = "AddDirectory"
label = "${res:ICSharpCode.WixBinding.PackagesFilesView.ContextMenu.AddDirectory}"
class = "ICSharpCode.WixBinding.AddDirectoryCommand"/>
<MenuItem id = "Diff"
label = "Diff"
class = "ICSharpCode.WixBinding.ShowDiffCommand"/>
</ComplexCondition>
<ComplexCondition action = "Exclude">
<Or>
@ -244,6 +250,12 @@ @@ -244,6 +250,12 @@
</ComplexCondition>
</Path>
<Path name = "/AddIns/WixBinding/WixPackageFilesDiffControl/ContextMenu">
<MenuItem id = "HideDiffControl"
label = "${res:Global.CloseButtonText}"
class = "ICSharpCode.WixBinding.HideDiffCommand"/>
</Path>
<!--
Standard compiler extensions. These are displayed in the add
compiler extensions dialog.
@ -261,5 +273,6 @@ @@ -261,5 +273,6 @@
<Path name="/AddIns/WixBinding/ExcludedItems">
<String id="svn" text=".svn"/>
<String id="obj" text="obj"/>
<String id="pdb" text="*.pdb"/>
</Path>
</AddIn>

7
src/AddIns/BackendBindings/WixBinding/Project/WixBinding.csproj

@ -144,6 +144,13 @@ @@ -144,6 +144,13 @@
<Compile Include="Src\PropertyGrid\RelativeFileNameEditor.cs" />
<Compile Include="Src\PropertyGrid\DropDownEditor.cs" />
<Compile Include="Src\PropertyGrid\DropDownEditorListBox.cs" />
<Compile Include="Src\WixPackageFilesDiff.cs" />
<Compile Include="Src\WixPackageFilesDiffResult.cs" />
<Compile Include="Src\DirectoryReader.cs" />
<Compile Include="Src\Commands\ShowDiffCommand.cs" />
<Compile Include="Src\Gui\WixPackageFilesDiffControl.cs" />
<Compile Include="Src\Commands\HideDiffCommand.cs" />
<Compile Include="Src\ExcludedNames.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="WixBinding.addin">

90
src/AddIns/BackendBindings/WixBinding/Test/Diff/ExcludedFilesTestFixture.cs

@ -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>";
}
}
}

93
src/AddIns/BackendBindings/WixBinding/Test/Diff/NoDifferentFilesTestFixture.cs

@ -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>";
}
}
}

85
src/AddIns/BackendBindings/WixBinding/Test/Diff/OneMissingFileTestFixture.cs

@ -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>";
}
}
}

85
src/AddIns/BackendBindings/WixBinding/Test/Diff/OneNewFileTestFixture.cs

@ -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>";
}
}
}

78
src/AddIns/BackendBindings/WixBinding/Test/Diff/SameFileReferencedTwiceTestFixture.cs

@ -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>";
}
}
}

61
src/AddIns/BackendBindings/WixBinding/Test/DirectoryImport/ExcludedNamesTests.cs

@ -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"));
}
}
}

77
src/AddIns/BackendBindings/WixBinding/Test/Document/ChildComponentsTestFixture.cs

@ -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>";
}
}
}

95
src/AddIns/BackendBindings/WixBinding/Test/Document/ChildFilesTestFixture.cs

@ -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>";
}
}
}

63
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoDiffShownTestFixture.cs

@ -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>";
}
}
}

7
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/NoRootDirectoryInWixProductFileTestFixture.cs

@ -39,6 +39,13 @@ namespace WixBinding.Tests.PackageFiles @@ -39,6 +39,13 @@ namespace WixBinding.Tests.PackageFiles
Assert.IsFalse(view.IsNoSourceFileFoundMessageDisplayed);
}
[Test]
public void ShowDiff()
{
editor.ShowDiff();
Assert.IsTrue(view.IsNoDifferencesFoundMessageDisplayed);
}
protected override string GetWixXml()
{
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2003/01/wi\">\r\n" +

87
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/OneNewFileDiffTestFixture.cs

@ -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>";
}
}
}

5
src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/PackageFilesTestFixtureBase.cs

@ -72,5 +72,10 @@ namespace WixBinding.Tests.PackageFiles @@ -72,5 +72,10 @@ namespace WixBinding.Tests.PackageFiles
{
return new string[0];
}
public bool DirectoryExists(string path)
{
return true;
}
}
}

60
src/AddIns/BackendBindings/WixBinding/Test/Project/CanCompileTests.cs

@ -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"));
}
}
}

24
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWixPackageFilesView.cs

@ -18,6 +18,7 @@ namespace WixBinding.Tests.Utils @@ -18,6 +18,7 @@ namespace WixBinding.Tests.Utils
{
bool noSourceFileFoundMessageDisplayed;
bool sourceFilesContainErrorsMessageDisplayed;
bool noDifferencesFoundMessageDisplayed;
string projectName;
WixDirectoryElement rootDirectory;
bool selectedItemAccessed;
@ -30,6 +31,7 @@ namespace WixBinding.Tests.Utils @@ -30,6 +31,7 @@ namespace WixBinding.Tests.Utils
bool attributesChangedCalled;
List<XmlElement> directoriesAdded = new List<XmlElement>();
bool clearDirectoriesCalled;
WixPackageFilesDiffResult[] diffResults;
public MockWixPackageFilesView()
{
@ -46,6 +48,11 @@ namespace WixBinding.Tests.Utils @@ -46,6 +48,11 @@ namespace WixBinding.Tests.Utils
sourceFilesContainErrorsMessageDisplayed = true;
}
public void ShowNoDifferenceFoundMessage()
{
noDifferencesFoundMessageDisplayed = true;
}
public WixDirectoryElement RootDirectory {
get {
return rootDirectory;
@ -119,6 +126,11 @@ namespace WixBinding.Tests.Utils @@ -119,6 +126,11 @@ namespace WixBinding.Tests.Utils
clearDirectoriesCalled = true;
}
public void ShowDiffResults(WixPackageFilesDiffResult[] diffResults)
{
this.diffResults = diffResults;
}
/// <summary>
/// Gets whether the No source file found error message is displayed in the
/// view.
@ -180,5 +192,17 @@ namespace WixBinding.Tests.Utils @@ -180,5 +192,17 @@ namespace WixBinding.Tests.Utils
return clearDirectoriesCalled;
}
}
public bool IsNoDifferencesFoundMessageDisplayed {
get {
return noDifferencesFoundMessageDisplayed;
}
}
public WixPackageFilesDiffResult[] DiffResults {
get {
return diffResults;
}
}
}
}

12
src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

@ -218,6 +218,17 @@ @@ -218,6 +218,17 @@
<Compile Include="DialogXmlGeneration\ComboBoxPropertyWithSpecialXmlCharsTestFixture.cs" />
<Compile Include="DialogXmlGeneration\ListViewPropertyWithSpecialXmlCharsTestFixture.cs" />
<Compile Include="DialogLoading\TextStyleNameWithSpecialXmlCharsTestFixture.cs" />
<Compile Include="Diff\NoDifferentFilesTestFixture.cs" />
<Compile Include="Document\ChildComponentsTestFixture.cs" />
<Compile Include="Document\ChildFilesTestFixture.cs" />
<Compile Include="Diff\OneNewFileTestFixture.cs" />
<Compile Include="Diff\OneMissingFileTestFixture.cs" />
<Compile Include="PackageFiles\NoDiffShownTestFixture.cs" />
<Compile Include="PackageFiles\OneNewFileDiffTestFixture.cs" />
<Compile Include="DirectoryImport\ExcludedNamesTests.cs" />
<Compile Include="Diff\ExcludedFilesTestFixture.cs" />
<Compile Include="Diff\SameFileReferencedTwiceTestFixture.cs" />
<Compile Include="Project\CanCompileTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project\WixBinding.csproj">
@ -276,6 +287,7 @@ @@ -276,6 +287,7 @@
</Content>
<Folder Include="PropertyGrid" />
<Folder Include="DirectoryImport" />
<Folder Include="Diff" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save