Browse Source

Fixed failing WixBinding tests after project system changes.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2058 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
c6b64b6445
  1. 14
      src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
  2. 8
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElement.cs
  3. 8
      src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs
  4. 10
      src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs
  5. 24
      src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs
  6. 28
      src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs

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

@ -11,6 +11,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.BuildEngine; using Microsoft.Build.BuildEngine;
@ -50,8 +51,8 @@ namespace ICSharpCode.WixBinding
get { return WixLanguageBinding.LanguageName; } get { return WixLanguageBinding.LanguageName; }
} }
public override ICSharpCode.SharpDevelop.Dom.LanguageProperties LanguageProperties { public override LanguageProperties LanguageProperties {
get { return ICSharpCode.SharpDevelop.Dom.LanguageProperties.None; } get { return LanguageProperties.None; }
} }
public override void Start(bool withDebugging) public override void Start(bool withDebugging)
@ -110,9 +111,9 @@ namespace ICSharpCode.WixBinding
/// </summary> /// </summary>
public string InstallerFullPath { public string InstallerFullPath {
get { get {
string outputPath = GetProperty("OutputPath") ?? ""; string outputPath = GetProperty("OutputPath") ?? String.Empty;
string outputType = GetProperty("OutputType") ?? ""; string outputType = GetProperty("OutputType") ?? String.Empty;
string outputName = GetProperty("OutputName") ?? ""; string outputName = GetProperty("OutputName") ?? String.Empty;
string fileName = String.Concat(outputName, GetInstallerExtension(outputType)); string fileName = String.Concat(outputName, GetInstallerExtension(outputType));
return Path.Combine(Path.Combine(Directory, outputPath), fileName); return Path.Combine(Path.Combine(Directory, outputPath), fileName);
} }
@ -194,7 +195,8 @@ namespace ICSharpCode.WixBinding
/// <returns>An empty string if the name cannot be found.</returns> /// <returns>An empty string if the name cannot be found.</returns>
public string GetVariable(string name) public string GetVariable(string name)
{ {
NameValuePairCollection nameValuePairs = new NameValuePairCollection(GetProperty("DefineConstants")); string constants = GetProperty("DefineConstants") ?? String.Empty;
NameValuePairCollection nameValuePairs = new NameValuePairCollection(constants);
return WixPropertyParser.Parse(nameValuePairs.GetValue(name), this); return WixPropertyParser.Parse(nameValuePairs.GetValue(name), this);
} }

8
src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElement.cs

@ -52,14 +52,6 @@ namespace ICSharpCode.WixBinding
return rootDirectory; return rootDirectory;
} }
/// <summary>
/// Adds a new component element to this directory element.
/// </summary>
public WixComponentElement AddComponent()
{
return AddComponent(String.Empty);
}
/// <summary> /// <summary>
/// Adds a new component element to this directory element. /// Adds a new component element to this directory element.
/// </summary> /// </summary>

8
src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs

@ -45,6 +45,7 @@ namespace WixBinding.Tests.Gui
Color errorDialogTextBackColour; Color errorDialogTextBackColour;
bool hasErrors; bool hasErrors;
bool hasErrorsAtStart;
[TestFixtureSetUp] [TestFixtureSetUp]
public void SetUpFixture() public void SetUpFixture()
@ -55,6 +56,8 @@ namespace WixBinding.Tests.Gui
wixDocumentFileName = @"C:\Projects\Test\setup.wxs"; wixDocumentFileName = @"C:\Projects\Test\setup.wxs";
using (SetupDialogListView control = new SetupDialogListView()) { using (SetupDialogListView control = new SetupDialogListView()) {
control.AddDialogs(wixDocumentFileName, new ReadOnlyCollection<string>(dialogs)); control.AddDialogs(wixDocumentFileName, new ReadOnlyCollection<string>(dialogs));
hasErrorsAtStart = control.HasErrors;
XmlException xmlEx = new XmlException("Error occurred", null, 10, 5); XmlException xmlEx = new XmlException("Error occurred", null, 10, 5);
control.AddError(wixDocumentFileName, xmlEx); control.AddError(wixDocumentFileName, xmlEx);
Exception ex = new Exception("Error"); Exception ex = new Exception("Error");
@ -197,5 +200,10 @@ namespace WixBinding.Tests.Gui
Assert.IsTrue(hasErrors, "SetupDialogListView.HasErrors should be true"); Assert.IsTrue(hasErrors, "SetupDialogListView.HasErrors should be true");
} }
[Test]
public void HasErrorsAtStart()
{
Assert.IsFalse(hasErrorsAtStart, "SetupDialogListView.HasErrors should be false at the start");
}
} }
} }

10
src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs

@ -29,7 +29,15 @@ namespace WixBinding.Tests.Gui
[TestFixtureSetUp] [TestFixtureSetUp]
public void SetUpFixture() public void SetUpFixture()
{ {
wixProject = WixBindingTestsHelper.CreateEmptyWixProject(); WixBindingTestsHelper.InitMSBuildEngine();
// create the project.
ProjectCreateInformation info = new ProjectCreateInformation();
info.Solution = new Solution();
info.ProjectName = "Test";
info.OutputProjectFileName = @"C:\Projects\Test\Test.wixproj";
wixProject = new WixProjectWithOverriddenSave(info);
// Add wix library item. // Add wix library item.
wixLibraryItem = new WixLibraryProjectItem(wixProject); wixLibraryItem = new WixLibraryProjectItem(wixProject);

24
src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs

@ -5,11 +5,13 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using System;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.WixBinding; using ICSharpCode.WixBinding;
using NUnit.Framework; using NUnit.Framework;
using System; using WixBinding.Tests.Utils;
namespace WixBinding.Tests.Project namespace WixBinding.Tests.Project
{ {
@ -25,6 +27,8 @@ namespace WixBinding.Tests.Project
[TestFixtureSetUp] [TestFixtureSetUp]
public void SetUpFixture() public void SetUpFixture()
{ {
WixBindingTestsHelper.InitMSBuildEngine();
info = new ProjectCreateInformation(); info = new ProjectCreateInformation();
info.Solution = new Solution(); info.Solution = new Solution();
info.ProjectName = "Test"; info.ProjectName = "Test";
@ -96,5 +100,23 @@ namespace WixBinding.Tests.Project
{ {
Assert.AreEqual(info.OutputProjectFileName, project.FileName); Assert.AreEqual(info.OutputProjectFileName, project.FileName);
} }
[Test]
public void AssemblyName()
{
Assert.AreEqual("Test", project.AssemblyName);
}
[Test]
public void UnknownProperty()
{
Assert.IsNull(project.GetValue("UnknownMSBuildProperty"));
}
[Test]
public void ProjectLanguageProperties()
{
Assert.AreEqual(LanguageProperties.None, project.LanguageProperties);
}
} }
} }

28
src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs

@ -10,6 +10,7 @@ using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.WixBinding; using ICSharpCode.WixBinding;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
namespace WixBinding.Tests.Utils namespace WixBinding.Tests.Utils
{ {
@ -27,6 +28,10 @@ namespace WixBinding.Tests.Utils
/// </summary> /// </summary>
public static WixProject CreateEmptyWixProject() public static WixProject CreateEmptyWixProject()
{ {
// Make sure the MSBuildEngine is initialised correctly.
InitMSBuildEngine();
// create the project.
ProjectCreateInformation info = new ProjectCreateInformation(); ProjectCreateInformation info = new ProjectCreateInformation();
info.Solution = new Solution(); info.Solution = new Solution();
info.ProjectName = "Test"; info.ProjectName = "Test";
@ -48,5 +53,28 @@ namespace WixBinding.Tests.Utils
} }
return null; return null;
} }
/// <summary>
/// The MSBuildEngine sets the SharpDevelopBinPath so if
/// the SharpDevelop.Base assembly is shadow copied it refers
/// to the shadow copied assembly not the original. This
/// causes problems for wix projects that refer to the
/// wix.targets import via $(SharpDevelopBinPath) so here
/// we change it so it points to the real SharpDevelop
/// binary.
/// </summary>
public static void InitMSBuildEngine()
{
// Remove existing SharpDevelopBinPath property.
MSBuildEngine.MSBuildProperties.Remove("SharpDevelopBinPath");
// Set the SharpDevelopBinPath property so it points to
// the actual bin path where SharpDevelop was built not
// to the shadow copy folder.
string codeBase = typeof(MSBuildEngine).Assembly.CodeBase.Replace("file:///", String.Empty);
string folder = Path.GetDirectoryName(codeBase);
folder = Path.GetFullPath(Path.Combine(folder, @"..\"));
MSBuildEngine.MSBuildProperties["SharpDevelopBinPath"] = folder;
}
} }
} }

Loading…
Cancel
Save