From c6b64b64459d3a95fe29a1ab8f0e9519b10a8cfe Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 19 Nov 2006 16:59:01 +0000 Subject: [PATCH] Fixed failing WixBinding tests after project system changes. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2058 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Project/WixProject.cs | 14 ++++++---- .../Project/Src/WixDirectoryElement.cs | 8 ------ .../AddDialogsToSetupDialogListTestFixture.cs | 10 ++++++- .../Gui/DeleteWixLibraryNodeTestFixture.cs | 10 ++++++- .../CreateNewWixProjectObjectTestFixture.cs | 24 +++++++++++++++- .../Test/Utils/WixBindingTestsHelper.cs | 28 +++++++++++++++++++ 6 files changed, 77 insertions(+), 17 deletions(-) diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs index 2e60af97f7..27679c497b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs @@ -11,6 +11,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; +using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using Microsoft.Build.BuildEngine; @@ -50,8 +51,8 @@ namespace ICSharpCode.WixBinding get { return WixLanguageBinding.LanguageName; } } - public override ICSharpCode.SharpDevelop.Dom.LanguageProperties LanguageProperties { - get { return ICSharpCode.SharpDevelop.Dom.LanguageProperties.None; } + public override LanguageProperties LanguageProperties { + get { return LanguageProperties.None; } } public override void Start(bool withDebugging) @@ -110,9 +111,9 @@ namespace ICSharpCode.WixBinding /// public string InstallerFullPath { get { - string outputPath = GetProperty("OutputPath") ?? ""; - string outputType = GetProperty("OutputType") ?? ""; - string outputName = GetProperty("OutputName") ?? ""; + string outputPath = GetProperty("OutputPath") ?? String.Empty; + string outputType = GetProperty("OutputType") ?? String.Empty; + string outputName = GetProperty("OutputName") ?? String.Empty; string fileName = String.Concat(outputName, GetInstallerExtension(outputType)); return Path.Combine(Path.Combine(Directory, outputPath), fileName); } @@ -194,7 +195,8 @@ namespace ICSharpCode.WixBinding /// An empty string if the name cannot be found. 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); } diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElement.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElement.cs index 978dc2e6e3..40726f205b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElement.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/WixDirectoryElement.cs @@ -52,14 +52,6 @@ namespace ICSharpCode.WixBinding return rootDirectory; } - /// - /// Adds a new component element to this directory element. - /// - public WixComponentElement AddComponent() - { - return AddComponent(String.Empty); - } - /// /// Adds a new component element to this directory element. /// diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs index 6e510d1ecb..1ff7e111d2 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs @@ -45,6 +45,7 @@ namespace WixBinding.Tests.Gui Color errorDialogTextBackColour; bool hasErrors; + bool hasErrorsAtStart; [TestFixtureSetUp] public void SetUpFixture() @@ -55,6 +56,8 @@ namespace WixBinding.Tests.Gui wixDocumentFileName = @"C:\Projects\Test\setup.wxs"; using (SetupDialogListView control = new SetupDialogListView()) { control.AddDialogs(wixDocumentFileName, new ReadOnlyCollection(dialogs)); + + hasErrorsAtStart = control.HasErrors; XmlException xmlEx = new XmlException("Error occurred", null, 10, 5); control.AddError(wixDocumentFileName, xmlEx); Exception ex = new Exception("Error"); @@ -196,6 +199,11 @@ namespace WixBinding.Tests.Gui { Assert.IsTrue(hasErrors, "SetupDialogListView.HasErrors should be true"); } - + + [Test] + public void HasErrorsAtStart() + { + Assert.IsFalse(hasErrorsAtStart, "SetupDialogListView.HasErrors should be false at the start"); + } } } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs index 2d3d1632e8..4456f7001e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DeleteWixLibraryNodeTestFixture.cs @@ -29,7 +29,15 @@ namespace WixBinding.Tests.Gui [TestFixtureSetUp] 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. wixLibraryItem = new WixLibraryProjectItem(wixProject); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs index 3e40c5dc8d..0f2abcd4f5 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs @@ -5,11 +5,13 @@ // $Revision$ // +using System; +using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; using NUnit.Framework; -using System; +using WixBinding.Tests.Utils; namespace WixBinding.Tests.Project { @@ -25,6 +27,8 @@ namespace WixBinding.Tests.Project [TestFixtureSetUp] public void SetUpFixture() { + WixBindingTestsHelper.InitMSBuildEngine(); + info = new ProjectCreateInformation(); info.Solution = new Solution(); info.ProjectName = "Test"; @@ -96,5 +100,23 @@ namespace WixBinding.Tests.Project { 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); + } } } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs index 90bcebb396..53915d450e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs @@ -10,6 +10,7 @@ using ICSharpCode.SharpDevelop.Project; using ICSharpCode.WixBinding; using System; using System.ComponentModel; +using System.IO; namespace WixBinding.Tests.Utils { @@ -27,6 +28,10 @@ namespace WixBinding.Tests.Utils /// public static WixProject CreateEmptyWixProject() { + // Make sure the MSBuildEngine is initialised correctly. + InitMSBuildEngine(); + + // create the project. ProjectCreateInformation info = new ProjectCreateInformation(); info.Solution = new Solution(); info.ProjectName = "Test"; @@ -48,5 +53,28 @@ namespace WixBinding.Tests.Utils } return null; } + + /// + /// 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. + /// + 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; + } } }