1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.ComponentModel;
7
using System.Resources;
9
using ICSharpCode.Core;
10
using ICSharpCode.SharpDevelop.Internal.Templates;
11
using ICSharpCode.SharpDevelop.Project;
12
using ICSharpCode.WixBinding;
14
namespace WixBinding.Tests.Utils
17
/// Helper class for WixBinding tests.
19
public class WixBindingTestsHelper
21
class DummyWixProject : WixProject
23
public DummyWixProject(ProjectCreateInformation info) : base (info)
27
public override bool ReadOnly {
32
WixBindingTestsHelper()
37
/// Creates a WixProject that contains no WixObject or WixLibrary items.
39
public static WixProject CreateEmptyWixProject()
41
// Make sure the MSBuildEngine is initialised correctly.
44
// create the project.
45
ProjectCreateInformation info = new ProjectCreateInformation();
46
info.Solution = new Solution(new MockProjectChangeWatcher());
47
info.ProjectName = "Test";
48
info.OutputProjectFileName = @"C:\Projects\Test\Test.wixproj";
50
return new DummyWixProject(info);
54
/// Returns the EditorAttribute in the AttributeCollection.
56
public static EditorAttribute GetEditorAttribute(AttributeCollection attributes)
58
foreach (Attribute attribute in attributes) {
59
EditorAttribute editorAttribute = attribute as EditorAttribute;
60
if (editorAttribute != null) {
61
return editorAttribute;
68
/// The MSBuildEngine sets the SharpDevelopBinPath so if
69
/// the SharpDevelop.Base assembly is shadow copied it refers
70
/// to the shadow copied assembly not the original. This
71
/// causes problems for wix projects that refer to the
72
/// wix.targets import via $(SharpDevelopBinPath) so here
73
/// we change it so it points to the real SharpDevelop
76
public static void InitMSBuildEngine()
78
// Remove existing SharpDevelopBinPath property.
79
MSBuildEngine.MSBuildProperties.Remove("SharpDevelopBinPath");
81
// Set the SharpDevelopBinPath property so it points to
82
// the actual bin path where SharpDevelop was built not
83
// to the shadow copy folder.
84
string codeBase = typeof(MSBuildEngine).Assembly.CodeBase.Replace("file:///", String.Empty);
85
string folder = Path.GetDirectoryName(codeBase);
86
folder = Path.GetFullPath(Path.Combine(folder, @"..\"));
87
MSBuildEngine.MSBuildProperties["SharpDevelopBinPath"] = folder;
91
/// Registers embedded strings with SharpDevelop's resource Manager
93
public static void RegisterResourceStringsWithSharpDevelopResourceManager()
95
ResourceManager rm = new ResourceManager("WixBinding.Tests.Strings", typeof(WixBindingTestsHelper).Assembly);
96
ResourceService.RegisterNeutralStrings(rm);